Skip to content

Commit 391858d

Browse files
committed
Lets print the port too
1 parent c7b93e6 commit 391858d

File tree

6 files changed

+65
-1
lines changed

6 files changed

+65
-1
lines changed

src/native/eventpipe/ds-ipc-pal-namedpipe.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,16 @@ ds_ipc_to_string (
653653
return (result > 0 && result < (int32_t)buffer_len) ? result : 0;
654654
}
655655

656+
int32_t
657+
ds_ipc_get_uds_path (
658+
DiagnosticsIpc *ipc,
659+
ep_char8_t *buffer,
660+
uint32_t buffer_len)
661+
{
662+
// Not supported
663+
return 0;
664+
}
665+
656666
/*
657667
* DiagnosticsIpcStream.
658668
*/

src/native/eventpipe/ds-ipc-pal-socket.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,34 @@ ds_ipc_to_string (
13691369
return (result > 0 && result < (int32_t)buffer_len) ? result : 0;
13701370
}
13711371

1372+
int32_t
1373+
ds_ipc_get_uds_path (
1374+
DiagnosticsIpc *ipc,
1375+
ep_char8_t *buffer,
1376+
uint32_t buffer_len)
1377+
{
1378+
#if defined(DS_IPC_PAL_AF_UNIX)
1379+
EP_ASSERT (ipc != NULL);
1380+
EP_ASSERT (buffer != NULL);
1381+
EP_ASSERT (buffer_len <= DS_IPC_MAX_TO_STRING_LEN);
1382+
1383+
const struct sockaddr_un *server_address = (const struct sockaddr_un *)ipc->server_address;
1384+
if (!server_address) {
1385+
if (buffer_len > 0)
1386+
buffer[0] = '\0';
1387+
return 0;
1388+
}
1389+
1390+
int32_t result = snprintf (buffer, buffer_len, "%s", server_address->sun_path);
1391+
return (result > 0 && result < (int32_t)buffer_len) ? result : 0;
1392+
#else
1393+
// No Unix Domain Socket path for non-AF_UNIX transports.
1394+
if (buffer && buffer_len > 0)
1395+
buffer[0] = '\0';
1396+
return 0;
1397+
#endif
1398+
}
1399+
13721400
/*
13731401
* DiagnosticsIpcStream.
13741402
*/

src/native/eventpipe/ds-ipc-pal-websocket.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,16 @@ ds_ipc_to_string (
335335
return 0;
336336
}
337337

338+
int32_t
339+
ds_ipc_get_uds_path (
340+
DiagnosticsIpc *ipc,
341+
ep_char8_t *buffer,
342+
uint32_t buffer_len)
343+
{
344+
// NOT SUPPORTED
345+
return 0;
346+
}
347+
338348
/*
339349
* DiagnosticsIpcStream.
340350
*/

src/native/eventpipe/ds-ipc-pal.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ ds_ipc_to_string (
9292
DiagnosticsIpc *ipc,
9393
ep_char8_t *buffer,
9494
uint32_t buffer_len);
95+
96+
// Retrieves the Unix Domain Socket path for a DiagnosticsIpc when applicable.
97+
// On non-socket PAL implementations or when no UDS path is available, this
98+
// returns 0 and writes an empty string to buffer.
99+
int32_t
100+
ds_ipc_get_uds_path (
101+
DiagnosticsIpc *ipc,
102+
ep_char8_t *buffer,
103+
uint32_t buffer_len);
95104
/*
96105
* DiagnosticsIpcStream.
97106
*/

src/native/eventpipe/ds-ipc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ ipc_stream_factory_build_and_add_port (
178178
ipc = ds_ipc_alloc (builder->path, DS_IPC_CONNECTION_MODE_LISTEN, callback);
179179
ep_raise_error_if_nok (ipc != NULL);
180180
ep_raise_error_if_nok (ds_ipc_listen (ipc, callback));
181+
ep_char8_t uds_path [DS_IPC_MAX_TO_STRING_LEN];
182+
if (ds_ipc_get_uds_path (ipc, uds_path, (uint32_t)ARRAY_SIZE (uds_path)) > 0) {
183+
DS_LOG_DEBUG_1 ("ipc_stream_factory_build_and_add_port - LISTEN port created for uds path '%s'", uds_path);
184+
} else {
185+
DS_LOG_DEBUG_1 ("ipc_stream_factory_build_and_add_port - LISTEN port created for path '%s'", builder->path ? builder->path : "(default)");
186+
}
181187
ep_raise_error_if_nok (dn_vector_ptr_push_back (_ds_port_array, (DiagnosticsPort *)ds_listen_port_alloc (ipc, builder)));
182188
#else
183189
DS_LOG_INFO_0 ("ipc_stream_factory_build_and_add_port - LISTEN ports disabled");
@@ -187,6 +193,7 @@ ipc_stream_factory_build_and_add_port (
187193
#ifndef DS_IPC_DISABLE_CONNECT_PORTS
188194
ipc = ds_ipc_alloc (builder->path, DS_IPC_CONNECTION_MODE_CONNECT, callback);
189195
ep_raise_error_if_nok (ipc != NULL);
196+
DS_LOG_DEBUG_1 ("ipc_stream_factory_build_and_add_port - CONNECT port created for path '%s'", builder->path ? builder->path : "(null)");
190197
ep_raise_error_if_nok (dn_vector_ptr_push_back (_ds_port_array, (DiagnosticsPort *)ds_connect_port_alloc (ipc, builder)));
191198
#else
192199
DS_LOG_INFO_0 ("ipc_stream_factory_build_and_add_port - CONNECT ports disabled");

src/tests/tracing/eventpipe/userevents/userevents.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static int TestEntryPoint()
103103

104104
traceeStartInfo.Environment["DOTNET_LogEnable"] = "1";
105105
traceeStartInfo.Environment["DOTNET_LogFacility"] = "0x00001000";
106-
traceeStartInfo.Environment["DOTNET_LogLevel"] = "4";
106+
traceeStartInfo.Environment["DOTNET_LogLevel"] = "10";
107107
traceeStartInfo.Environment["DOTNET_LogToFile"] = "1";
108108
traceeStartInfo.Environment["DOTNET_LogFile"] = logFilePath;
109109
traceeStartInfo.Environment["DOTNET_LogWithPid"] = "1";

0 commit comments

Comments
 (0)