Skip to content

Commit c582320

Browse files
authored
dont try to capture threadId for NativeAOT (#108045)
* dont try to capture threadId for NativeAOT * add config to capture bgc threadid
1 parent 602e6ea commit c582320

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/coreclr/gc/gc.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -26685,16 +26685,19 @@ void gc_heap::add_to_hc_history_worker (hc_history* hist, int* current_index, hc
2668526685
current_hist->concurrent_p = (bool)settings.concurrent;
2668626686
current_hist->bgc_thread_running = (bool)bgc_thread_running;
2668726687

26688-
#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS) && !defined(_DEBUG)
26689-
int bgc_thread_os_id = 0;
26690-
26691-
if (bgc_thread)
26688+
#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS) && !defined(_DEBUG) && !defined(FEATURE_NATIVEAOT)
26689+
if (GCConfig::GetGCLogBGCThreadId())
2669226690
{
26693-
bgc_thread_os_id = (int)(*(size_t*)((uint8_t*)bgc_thread + 0x130));
26694-
}
26691+
int bgc_thread_os_id = 0;
26692+
26693+
if (bgc_thread)
26694+
{
26695+
bgc_thread_os_id = (int)(*(size_t*)((uint8_t*)bgc_thread + 0x130));
26696+
}
2669526697

26696-
current_hist->bgc_thread_os_id = bgc_thread_os_id;
26697-
#endif //TARGET_AMD64 && TARGET_WINDOWS && !_DEBUG
26698+
current_hist->bgc_thread_os_id = bgc_thread_os_id;
26699+
}
26700+
#endif //TARGET_AMD64 && TARGET_WINDOWS && !_DEBUG && !FEATURE_NATIVEAOT
2669826701
#endif //BACKGROUND_GC
2669926702

2670026703
*current_index = (*current_index + 1) % max_hc_history_count;

src/coreclr/gc/gcconfig.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ class GCConfigStringHolder
141141
STRING_CONFIG(GCPath, "GCPath", "System.GC.Path", "Specifies the path of the standalone GC implementation.") \
142142
INT_CONFIG (GCSpinCountUnit, "GCSpinCountUnit", NULL, 0, "Specifies the spin count unit used by the GC.") \
143143
INT_CONFIG (GCDynamicAdaptationMode, "GCDynamicAdaptationMode", "System.GC.DynamicAdaptationMode", 1, "Enable the GC to dynamically adapt to application sizes.") \
144-
INT_CONFIG (GCDTargetTCP, "GCDTargetTCP", "System.GC.DTargetTCP", 0, "Specifies the target tcp for DATAS")
144+
INT_CONFIG (GCDTargetTCP, "GCDTargetTCP", "System.GC.DTargetTCP", 0, "Specifies the target tcp for DATAS") \
145+
BOOL_CONFIG (GCLogBGCThreadId, "GCLogBGCThreadId", NULL, false, "Specifies if BGC ThreadId should be logged")
146+
147+
145148
// This class is responsible for retreiving configuration information
146149
// for how the GC should operate.
147150
class GCConfig

src/coreclr/gc/gcpriv.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ struct hc_history
618618
// invalid fields on the Thread object such as m_OSThreadId. This is to help with debugging that problem so I
619619
// only enable it for retail builds on Windows. We can extend this with a GCToEEInterface interface method to get the offset
620620
// of that particular field on the Thread object.
621-
#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS) && !defined(_DEBUG)
621+
#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS) && !defined(_DEBUG) && !defined(FEATURE_NATIVEAOT)
622622
int bgc_thread_os_id;
623623
#endif
624624
short bgc_t_join_join_lock;

0 commit comments

Comments
 (0)