Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d9da91

Browse files
[release/9.0] dont try to capture threadId for NativeAOT (#108088)
* dont try to capture threadId for NativeAOT * add config to capture bgc threadid --------- Co-authored-by: Manish Godse <[email protected]>
1 parent 9c9e77e commit 3d9da91

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/coreclr/gc/gc.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26593,16 +26593,19 @@ void gc_heap::add_to_hc_history_worker (hc_history* hist, int* current_index, hc
2659326593
current_hist->concurrent_p = (bool)settings.concurrent;
2659426594
current_hist->bgc_thread_running = (bool)bgc_thread_running;
2659526595

26596-
#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS) && !defined(_DEBUG)
26597-
int bgc_thread_os_id = 0;
26598-
26599-
if (bgc_thread)
26596+
#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS) && !defined(_DEBUG) && !defined(FEATURE_NATIVEAOT)
26597+
if (GCConfig::GetGCLogBGCThreadId())
2660026598
{
26601-
bgc_thread_os_id = (int)(*(size_t*)((uint8_t*)bgc_thread + 0x130));
26602-
}
26599+
int bgc_thread_os_id = 0;
26600+
26601+
if (bgc_thread)
26602+
{
26603+
bgc_thread_os_id = (int)(*(size_t*)((uint8_t*)bgc_thread + 0x130));
26604+
}
2660326605

26604-
current_hist->bgc_thread_os_id = bgc_thread_os_id;
26605-
#endif //TARGET_AMD64 && TARGET_WINDOWS && !_DEBUG
26606+
current_hist->bgc_thread_os_id = bgc_thread_os_id;
26607+
}
26608+
#endif //TARGET_AMD64 && TARGET_WINDOWS && !_DEBUG && !FEATURE_NATIVEAOT
2660626609
#endif //BACKGROUND_GC
2660726610

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

src/coreclr/gc/gcconfig.h

Lines changed: 4 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)