Skip to content

Commit 94a1208

Browse files
authored
Fix missing GC counter data on non-Windows (#87430)
This sets FEATURE_EVENT_TRACE on non-Windows platforms as well, such that GC counter information is tracked and provided when requested. This does not fully enable runtime event tracing via EventPipe on non-Windows.
1 parent bec3b04 commit 94a1208

File tree

5 files changed

+15
-28
lines changed

5 files changed

+15
-28
lines changed

src/coreclr/nativeaot/Runtime/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,17 @@ include_directories(${ARCH_SOURCES_DIR})
213213

214214
if(NOT CLR_CMAKE_TARGET_ARCH_WASM)
215215
set(FEATURE_PERFTRACING 1)
216+
set(FEATURE_EVENT_TRACE 1)
216217
endif()
217218

218219
if(FEATURE_PERFTRACING)
219220
add_definitions(-DFEATURE_PERFTRACING)
220221
endif()
221222

223+
if(FEATURE_EVENT_TRACE)
224+
add_definitions(-DFEATURE_EVENT_TRACE)
225+
endif()
226+
222227
add_definitions(-DFEATURE_BASICFREEZE)
223228
add_definitions(-DFEATURE_CONSERVATIVE_GC)
224229
add_definitions(-DFEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP)
@@ -238,7 +243,6 @@ add_definitions(-D_LIB)
238243

239244
if(WIN32)
240245
add_definitions(-DFEATURE_ETW)
241-
add_definitions(-DFEATURE_EVENT_TRACE)
242246
add_definitions(-DFEATURE_SUSPEND_REDIRECTION)
243247
add_definitions(-DFEATURE_SPECIAL_USER_MODE_APC)
244248
else()

src/coreclr/nativeaot/Runtime/clretwallmain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// @TODO: Audit native events in NativeAOT Runtime
88

99
#include "clreventpipewriteevents.h"
10-
#include "etwevents.h"
10+
#include "EtwEvents.h"
1111

1212
inline BOOL EventEnabledDestroyGCHandle(void) {return EventPipeEventEnabledDestroyGCHandle();}
1313

src/coreclr/nativeaot/Runtime/eventtrace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ inline BOOL ETW::GCLog::ShouldWalkStaticsAndCOMForEtw() { return FALSE; }
325325
inline void ETW::GCLog::FireGcStart(ETW_GC_INFO * pGcInfo) { }
326326
inline void ETW::GCLog::EndHeapDump(ProfilerWalkHeapContext * profilerWalkHeapContext) { }
327327
inline void ETW::GCLog::BeginMovedReferences(size_t * pProfilingContext) { }
328-
inline void ETW::GCLog::MovedReference(BYTE * pbMemBlockStart, BYTE * pbMemBlockEnd, ptrdiff_t cbRelocDistance, size_t profilingContext, BOOL fCompacting) { }
329-
inline void ETW::GCLog::EndMovedReferences(size_t profilingContext) { }
328+
inline void ETW::GCLog::MovedReference(BYTE * pbMemBlockStart, BYTE * pbMemBlockEnd, ptrdiff_t cbRelocDistance, size_t profilingContext, BOOL fCompacting, BOOL fAllowProfApiNotification) { }
329+
inline void ETW::GCLog::EndMovedReferences(size_t profilingContext, BOOL fAllowProfApiNotification) { }
330330
inline void ETW::GCLog::WalkStaticsAndCOMForETW() { }
331331
inline void ETW::GCLog::RootReference(
332332
LPVOID pvHandle,

src/coreclr/nativeaot/Runtime/gcenv.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
#include "gcenv.inl"
4545

4646
#include "stressLog.h"
47-
#ifdef FEATURE_ETW
48-
47+
#ifdef FEATURE_EVENT_TRACE
4948
#ifndef _INC_WINDOWS
5049
typedef void* LPVOID;
5150
typedef uint32_t UINT;
@@ -58,15 +57,14 @@
5857
#endif // _INC_WINDOWS
5958

6059
#include "clretwallmain.h"
61-
#include "etwevents.h"
6260
#include "eventtrace.h"
6361

64-
#else // FEATURE_ETW
62+
#else // FEATURE_EVENT_TRACE
6563

6664
#include "etmdummy.h"
6765
#define ETW_EVENT_ENABLED(e,f) false
6866

69-
#endif // FEATURE_ETW
67+
#endif // FEATURE_EVENT_TRACE
7068

7169
#define LOG(x)
7270

@@ -88,7 +86,11 @@ class ArrayBase : Array
8886
EXTERN_C uint32_t _tls_index;
8987
inline uint16_t GetClrInstanceId()
9088
{
89+
#ifdef HOST_WINDOWS
9190
return (uint16_t)_tls_index;
91+
#else
92+
return 0;
93+
#endif
9294
}
9395

9496
class IGCHeap;

src/coreclr/nativeaot/Runtime/gcrhenv.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,6 @@
4949
#include "holder.h"
5050
#include "volatile.h"
5151

52-
#ifdef FEATURE_ETW
53-
#ifndef _INC_WINDOWS
54-
typedef void* LPVOID;
55-
typedef uint32_t UINT;
56-
typedef void* PVOID;
57-
typedef uint64_t ULONGLONG;
58-
typedef uint32_t ULONG;
59-
typedef int64_t LONGLONG;
60-
typedef uint8_t BYTE;
61-
typedef uint16_t UINT16;
62-
#endif // _INC_WINDOWS
63-
64-
#include "etwevents.h"
65-
#include "eventtrace.h"
66-
#else // FEATURE_ETW
67-
#include "etmdummy.h"
68-
#define ETW_EVENT_ENABLED(e,f) false
69-
#endif // FEATURE_ETW
70-
7152
GPTR_IMPL(MethodTable, g_pFreeObjectEEType);
7253

7354
#include "gctoclreventsink.h"

0 commit comments

Comments
 (0)