[NativeAOT] Use TCP transport for EventPipe on mobile platforms (#90315)
authorFilip Navara <navara@emclient.com>
Mon, 14 Aug 2023 16:08:55 +0000 (18:08 +0200)
committerGitHub <noreply@github.com>
Mon, 14 Aug 2023 16:08:55 +0000 (18:08 +0200)
* [NativeAOT] Use TCP transport for EventPipe on mobile platforms

* Update src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt

---------

Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt
src/mono/mono/eventpipe/eventpipe.cmake
src/native/eventpipe/ds-ipc-pal-socket.c
src/native/eventpipe/eventpipe.cmake

index ab6f781..cedb910 100644 (file)
@@ -14,6 +14,12 @@ set (EVENTPIPE_SOURCES "")
 set (EVENTPIPE_HEADERS "")
 set (GEN_EVENTPIPE_SOURCES "")
 
+# Use TCP for EventPipe on mobile platforms
+if (CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_ANDROID)
+  set(FEATURE_PERFTRACING_PAL_TCP 1)
+  set(FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT 1)
+endif()
+
 set (SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers")
 set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe")
 set (SHARED_MINIPAL_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/minipal")
index 0fc46a0..6f3c0bf 100644 (file)
@@ -6,22 +6,6 @@ include(${SHARED_EVENTPIPE_SOURCE_PATH}configure.cmake)
 
 if(ENABLE_PERFTRACING)
 
-    if (FEATURE_PERFTRACING_PAL_TCP)
-        add_definitions(-DENABLE_PERFTRACING_PAL_TCP)
-    endif (FEATURE_PERFTRACING_PAL_TCP)
-
-    if (FEATURE_PERFTRACING_DISABLE_PERFTRACING_LISTEN_PORTS)
-        add_definitions(-DDISABLE_PERFTRACING_LISTEN_PORTS)
-    endif (FEATURE_PERFTRACING_DISABLE_PERFTRACING_LISTEN_PORTS)
-
-    if (FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT)
-        add_definitions(-DDISABLE_PERFTRACING_DEFAULT_LISTEN_PORT)
-    endif (FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT)
-
-    if (FEATURE_PERFTRACING_DISABLE_CONNECT_PORTS)
-        add_definitions(-DDISABLE_PERFTRACING_CONNECT_PORTS)
-    endif (FEATURE_PERFTRACING_DISABLE_CONNECT_PORTS)
-
     if (TARGET_S390X)
         add_definitions(-DBIGENDIAN)
     endif (TARGET_S390X)
index ca7b828..d93233c 100644 (file)
@@ -844,12 +844,15 @@ ipc_alloc_tcp_address (
        ds_ipc_addrinfo_t *info = NULL;
        ep_char8_t *address = NULL;
        int32_t port = 0;
+       int result_getaddrinfo = -1;
+       const ep_char8_t *host_address = NULL;
+       const ep_char8_t *host_port = NULL;
 
        address = ep_rt_utf8_string_dup (ipc_name);
        ep_raise_error_if_nok (address != NULL);
 
-       const ep_char8_t *host_address = address;
-       const ep_char8_t *host_port = strrchr (address, ':');
+       host_address = address;
+       host_port = strrchr (address, ':');
 
        if (host_port && host_port != host_address) {
                size_t host_address_len = host_port - address;
@@ -863,7 +866,6 @@ ipc_alloc_tcp_address (
        hints.ai_socktype = SOCK_STREAM;
        hints.ai_flags = (mode == DS_IPC_CONNECTION_MODE_LISTEN) ? AI_PASSIVE : 0;
 
-       int result_getaddrinfo = -1;
        DS_ENTER_BLOCKING_PAL_SECTION;
        if (mode == DS_IPC_CONNECTION_MODE_LISTEN && *host_address == '*') {
 #ifdef DS_IPC_PAL_AF_INET6
index c320b61..fa54d8c 100644 (file)
@@ -4,6 +4,22 @@ if(ENABLE_PERFTRACING OR FEATURE_PERFTRACING)
     set (SHARED_DIAGNOSTIC_SERVER_SOURCES "")
     set (SHARED_DIAGNOSTIC_SERVER_HEADERS "")
 
+    if (FEATURE_PERFTRACING_PAL_TCP)
+        add_definitions(-DENABLE_PERFTRACING_PAL_TCP)
+    endif (FEATURE_PERFTRACING_PAL_TCP)
+
+    if (FEATURE_PERFTRACING_DISABLE_PERFTRACING_LISTEN_PORTS)
+        add_definitions(-DDISABLE_PERFTRACING_LISTEN_PORTS)
+    endif (FEATURE_PERFTRACING_DISABLE_PERFTRACING_LISTEN_PORTS)
+
+    if (FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT)
+        add_definitions(-DDISABLE_PERFTRACING_DEFAULT_LISTEN_PORT)
+    endif (FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT)
+
+    if (FEATURE_PERFTRACING_DISABLE_CONNECT_PORTS)
+        add_definitions(-DDISABLE_PERFTRACING_CONNECT_PORTS)
+    endif (FEATURE_PERFTRACING_DISABLE_CONNECT_PORTS)
+
     list(APPEND SHARED_EVENTPIPE_SOURCES
         ep-sources.c
         ep.c