Skip to content

Commit acafb20

Browse files
authored
Fix missing GC events on non-Windows for nativeaot (#88282)
1 parent caff01c commit acafb20

16 files changed

+3261
-3317
lines changed

src/coreclr/nativeaot/Runtime/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ if (WIN32)
111111
windows/PalRedhawkCommon.cpp
112112
windows/PalRedhawkMinWin.cpp
113113
${GC_DIR}/windows/gcenv.windows.cpp
114-
eventtrace.cpp
115-
rheventtrace.cpp
116114
)
117115

118116
list(APPEND FULL_RUNTIME_SOURCES windows/CoffNativeCodeManager.cpp)
@@ -222,6 +220,18 @@ endif()
222220

223221
if(FEATURE_EVENT_TRACE)
224222
add_definitions(-DFEATURE_EVENT_TRACE)
223+
list(APPEND COMMON_RUNTIME_SOURCES
224+
eventtrace.cpp
225+
)
226+
# These are carry-overs from .NET Native and only included on Windows currently
227+
# bulktype : directly emits via ETW with EventWrite
228+
# gcheap : GCHeapDump, GCHeapSurvivalAndMovement - not prioritizing for nativeaot yet
229+
if (WIN32)
230+
list(APPEND COMMON_RUNTIME_SOURCES
231+
eventtrace_bulktype.cpp
232+
eventtrace_gcheap.cpp
233+
)
234+
endif()
225235
endif()
226236

227237
add_definitions(-DFEATURE_BASICFREEZE)

src/coreclr/nativeaot/Runtime/eventpipe/disableddotnetruntime.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,3 +632,8 @@ ULONG EventPipeWriteEventGCFitBucketInfo(
632632
{
633633
return 0;
634634
}
635+
636+
bool DotNETRuntimeProvider_IsEnabled(unsigned char level, unsigned long long keyword)
637+
{
638+
return false;
639+
}

src/coreclr/nativeaot/Runtime/eventpipe/dotnetruntime.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,3 +3147,18 @@ void InitDotNETRuntime(void)
31473147
EventPipeEventGCLOHCompact = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,208,1,0,EP_EVENT_LEVEL_INFORMATIONAL,true);
31483148
EventPipeEventGCFitBucketInfo = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,209,1,0,EP_EVENT_LEVEL_VERBOSE,true);
31493149
}
3150+
3151+
bool DotNETRuntimeProvider_IsEnabled(unsigned char level, unsigned long long keyword)
3152+
{
3153+
if (!EventPipeAdapter::Enabled())
3154+
return false;
3155+
3156+
EVENTPIPE_TRACE_CONTEXT& context = MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context.EventPipeProvider;
3157+
if (!context.IsEnabled)
3158+
return false;
3159+
3160+
if (level > context.Level)
3161+
return false;
3162+
3163+
return (keyword == (ULONGLONG)0) || (keyword & context.EnabledKeywordsBitmask) != 0;
3164+
}

0 commit comments

Comments
 (0)