Skip to content

Commit 47a4767

Browse files
Make GCDump work on Linux (#116816)
Fixes #116686. Turns out the test was failing because everything involved in GCDump was disabled outside Windows.
1 parent 0bd4424 commit 47a4767

File tree

8 files changed

+14
-51
lines changed

8 files changed

+14
-51
lines changed

src/coreclr/nativeaot/Runtime/disabledeventtrace.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ bool IsRuntimeProviderEnabled(uint8_t level, uint64_t keyword)
2020

2121
void ETW::GCLog::FireGcStart(ETW_GC_INFO * pGcInfo) { }
2222
void ETW::LoaderLog::ModuleLoad(HANDLE pModule) { }
23-
24-
#ifdef FEATURE_ETW
2523
BOOL ETW::GCLog::ShouldTrackMovementForEtw() { return FALSE; }
2624
void ETW::GCLog::BeginMovedReferences(size_t * pProfilingContext) { }
2725
void ETW::GCLog::EndMovedReferences(size_t profilingContext, BOOL fAllowProfApiNotification) { }
2826
void ETW::GCLog::WalkHeap() { }
29-
#endif // FEATURE_ETW

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,11 @@ list(APPEND AOT_EVENTPIPE_MANAGED_TO_NATIVE_SOURCES
136136
if (FEATURE_EVENT_TRACE)
137137
list(APPEND AOT_EVENTTRACE_SOURCES
138138
${NATIVEAOT_RUNTIME_DIR}/eventtrace.cpp
139+
${NATIVEAOT_RUNTIME_DIR}/eventtrace_bulktype.cpp
140+
${NATIVEAOT_RUNTIME_DIR}/eventtrace_gcheap.cpp
139141
${NATIVEAOT_RUNTIME_DIR}/profheapwalkhelper.cpp
140142
)
141143

142-
# These are carry-overs from .NET Native and only included for ETW currently
143-
# bulktype : directly emits via ETW with EventWrite
144-
# gcheap : GCHeapDump, GCHeapSurvivalAndMovement - not prioritizing for nativeaot yet
145-
if (FEATURE_ETW)
146-
list(APPEND AOT_EVENTTRACE_SOURCES
147-
${NATIVEAOT_RUNTIME_DIR}/eventtrace_bulktype.cpp
148-
${NATIVEAOT_RUNTIME_DIR}/eventtrace_gcheap.cpp
149-
)
150-
endif()
151-
152144
if(CLR_CMAKE_TARGET_WIN32)
153145
set_source_files_properties(${GEN_EVENTPIPE_PROVIDER_SOURCES} PROPERTIES COMPILE_FLAGS "/FI\"${NATIVEAOT_RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h\"")
154146
set_source_files_properties(${GEN_EVENTPIPE_PLAT_AGNOSTIC_SOURCES} PROPERTIES COMPILE_FLAGS "/FI\"${NATIVEAOT_RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h\"")

src/coreclr/nativeaot/Runtime/eventtrace.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ void EtwCallbackCommon(
250250
GCHeapUtilities::RecordEventStateChange(bIsPublicTraceHandle, keywords, level);
251251
}
252252

253-
// NativeAOT currently only supports forcing a GC with ManagedHeapCollectKeyword via ETW
254-
#ifdef FEATURE_ETW
255253
// Special check for a profiler requested GC.
256254
// A full GC will be forced if:
257255
// 1. The GC Heap is initialized.
@@ -273,10 +271,11 @@ void EtwCallbackCommon(
273271
// Profilers may (optionally) specify extra data in the filter parameter
274272
// to log with the GCStart event.
275273
LONGLONG l64ClientSequenceNumber = 0;
274+
#if !defined(HOST_UNIX)
276275
ParseFilterDataClientSequenceNumber((EVENT_FILTER_DESCRIPTOR*)pFilterData, &l64ClientSequenceNumber);
276+
#endif // !defined(HOST_UNIX)
277277
ETW::GCLog::ForceGC(l64ClientSequenceNumber);
278278
}
279-
#endif
280279
}
281280

282281
#ifdef FEATURE_ETW

src/coreclr/nativeaot/Runtime/eventtrace.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -202,25 +202,4 @@ namespace ETW
202202
inline void ETW::GCLog::FireGcStart(ETW_GC_INFO * pGcInfo) { }
203203
#endif
204204

205-
#ifndef FEATURE_ETW
206-
inline BOOL ETW::GCLog::ShouldWalkHeapObjectsForEtw() { return FALSE; }
207-
inline BOOL ETW::GCLog::ShouldWalkHeapRootsForEtw() { return FALSE; }
208-
inline BOOL ETW::GCLog::ShouldTrackMovementForEtw() { return FALSE; }
209-
inline BOOL ETW::GCLog::ShouldWalkStaticsAndCOMForEtw() { return FALSE; }
210-
inline void ETW::GCLog::EndHeapDump(ProfilerWalkHeapContext * profilerWalkHeapContext) { }
211-
inline void ETW::GCLog::BeginMovedReferences(size_t * pProfilingContext) { }
212-
inline void ETW::GCLog::MovedReference(BYTE * pbMemBlockStart, BYTE * pbMemBlockEnd, ptrdiff_t cbRelocDistance, size_t profilingContext, BOOL fCompacting, BOOL fAllowProfApiNotification) { }
213-
inline void ETW::GCLog::EndMovedReferences(size_t profilingContext, BOOL fAllowProfApiNotification) { }
214-
inline void ETW::GCLog::WalkStaticsAndCOMForETW() { }
215-
inline void ETW::GCLog::RootReference(
216-
LPVOID pvHandle,
217-
Object * pRootedNode,
218-
Object * pSecondaryNodeForDependentHandle,
219-
BOOL fDependentHandle,
220-
ProfilingScanContext * profilingScanContext,
221-
DWORD dwGCFlags,
222-
DWORD rootFlags) { }
223-
inline void ETW::GCLog::WalkHeap() { }
224-
#endif
225-
226205
#endif //_VMEVENTTRACE_H_

src/coreclr/nativeaot/Runtime/eventtrace_bulktype.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "eventtrace_etw.h"
88
#include "rhbinder.h"
99
#include "slist.h"
10-
#include "runtimeinstance.h"
10+
#include "RuntimeInstance.h"
1111
#include "shash.h"
1212
#include "eventtracebase.h"
1313
#include "eventtracepriv.h"
@@ -216,8 +216,9 @@ static CorElementType ElementTypeToCorElementType(EETypeElementType elementType)
216216
return CorElementType::ELEMENT_TYPE_I;
217217
case EETypeElementType::ElementType_UIntPtr:
218218
return CorElementType::ELEMENT_TYPE_U;
219+
default:
220+
return CorElementType::ELEMENT_TYPE_END;
219221
}
220-
return CorElementType::ELEMENT_TYPE_END;
221222
}
222223

223224
// Avoid reporting the same type twice by keeping a hash of logged types.
@@ -243,7 +244,11 @@ int BulkTypeEventLogger::LogSingleType(MethodTable * pEEType)
243244
#endif
244245
//Avoid logging the same type twice, but using the hash of loggged types.
245246
if (s_loggedTypesHash == NULL)
246-
s_loggedTypesHash = new SHash<LoggedTypesTraits>();
247+
s_loggedTypesHash = new (nothrow) SHash<LoggedTypesTraits>();
248+
249+
if (s_loggedTypesHash == NULL)
250+
return -1;
251+
247252
MethodTable* preexistingType = s_loggedTypesHash->Lookup(pEEType);
248253
if (preexistingType != NULL)
249254
{
@@ -260,7 +265,7 @@ int BulkTypeEventLogger::LogSingleType(MethodTable * pEEType)
260265
FireBulkTypeEvent();
261266
}
262267

263-
_ASSERTE(m_nBulkTypeValueCount < _countof(m_rgBulkTypeValues));
268+
_ASSERTE(m_nBulkTypeValueCount < (int)_countof(m_rgBulkTypeValues));
264269

265270
BulkTypeValue * pVal = &m_rgBulkTypeValues[m_nBulkTypeValueCount];
266271

src/coreclr/nativeaot/Runtime/eventtrace_gcheap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ void ETW::GCLog::ForceGC(LONGLONG l64ClientSequenceNumber)
415415
if (!GCHeapUtilities::IsGCHeapInitialized())
416416
return;
417417

418-
InterlockedExchange64(&s_l64LastClientSequenceNumber, l64ClientSequenceNumber);
418+
PalInterlockedExchange64(&s_l64LastClientSequenceNumber, l64ClientSequenceNumber);
419419

420420
ForceGCForDiagnostics();
421421
}

src/coreclr/nativeaot/Runtime/profheapwalkhelper.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ bool HeapWalkHelper(Object * pBO, void * pvContext)
172172

173173
HRESULT hr = E_FAIL;
174174

175-
#ifdef FEATURE_ETW
176175
if (ETW::GCLog::ShouldWalkHeapObjectsForEtw())
177176
{
178177
ETW::GCLog::ObjectReference(
@@ -182,7 +181,6 @@ bool HeapWalkHelper(Object * pBO, void * pvContext)
182181
cNumRefs,
183182
(Object **) arrObjRef);
184183
}
185-
#endif // FEATURE_ETW
186184

187185
// If the data was not allocated on the stack, need to clean it up.
188186
if ((arrObjRef != NULL) && !bOnStack)

src/tests/issues.targets

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,13 +1074,6 @@
10741074
</ExcludeList>
10751075
</ItemGroup>
10761076

1077-
<!-- NativeAOT Linux specific -->
1078-
<ItemGroup Condition="'$(XunitTestBinBase)' != '' and '$(TestBuildMode)' == 'nativeaot' and '$(RuntimeFlavor)' == 'coreclr' and '$(TargetOS)' == 'linux'">
1079-
<ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/gcdump/**">
1080-
<Issue>https://github.com/dotnet/runtime/issues/116686</Issue>
1081-
</ExcludeList>
1082-
</ItemGroup>
1083-
10841077
<!-- NativeAOT arm32 specific -->
10851078
<ItemGroup Condition="'$(XunitTestBinBase)' != '' and '$(TestBuildMode)' == 'nativeaot' and '$(RuntimeFlavor)' == 'coreclr' and '$(TargetArchitecture)' == 'arm'">
10861079
<ExcludeList Include="$(XunitTestBinBase)/GC/API/GC/GetTotalAllocatedBytes/**">

0 commit comments

Comments
 (0)