Skip to content

Commit cd1657d

Browse files
authored
Let the debugger knows DATAS is on (#107115)
1 parent b2a6266 commit cd1657d

File tree

12 files changed

+180
-8
lines changed

12 files changed

+180
-8
lines changed

src/coreclr/debug/daccess/daccess.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3245,6 +3245,10 @@ ClrDataAccess::QueryInterface(THIS_
32453245
{
32463246
ifaceRet = static_cast<ISOSDacInterface15*>(this);
32473247
}
3248+
else if (IsEqualIID(interfaceId, __uuidof(ISOSDacInterface16)))
3249+
{
3250+
ifaceRet = static_cast<ISOSDacInterface16*>(this);
3251+
}
32483252
else
32493253
{
32503254
*iface = NULL;

src/coreclr/debug/daccess/dacimpl.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,8 @@ class ClrDataAccess
814814
public ISOSDacInterface12,
815815
public ISOSDacInterface13,
816816
public ISOSDacInterface14,
817-
public ISOSDacInterface15
817+
public ISOSDacInterface15,
818+
public ISOSDacInterface16
818819
{
819820
public:
820821
ClrDataAccess(ICorDebugDataTarget * pTarget, ICLRDataTarget * pLegacyTarget=0);
@@ -1222,6 +1223,9 @@ class ClrDataAccess
12221223
// ISOSDacInterface15
12231224
virtual HRESULT STDMETHODCALLTYPE GetMethodTableSlotEnumerator(CLRDATA_ADDRESS mt, ISOSMethodEnum **enumerator);
12241225

1226+
// ISOSDacInterface16
1227+
virtual HRESULT STDMETHODCALLTYPE GetGCDynamicAdaptationMode(int* pDynamicAdaptationMode);
1228+
12251229
//
12261230
// ClrDataAccess.
12271231
//

src/coreclr/debug/daccess/request.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,6 +2908,24 @@ ClrDataAccess::GetGCHeapStaticData(struct DacpGcHeapDetails *detailsData)
29082908
return hr;
29092909
}
29102910

2911+
HRESULT
2912+
ClrDataAccess::GetGCDynamicAdaptationMode(int* pDynamicAdaptationMode)
2913+
{
2914+
SOSDacEnter();
2915+
if (IsDatasEnabled())
2916+
{
2917+
*pDynamicAdaptationMode = *g_gcDacGlobals->dynamic_adaptation_mode;
2918+
hr = S_OK;
2919+
}
2920+
else
2921+
{
2922+
*pDynamicAdaptationMode = -1;
2923+
hr = S_FALSE;
2924+
}
2925+
SOSDacLeave();
2926+
return hr;
2927+
}
2928+
29112929
HRESULT
29122930
ClrDataAccess::GetHeapSegmentData(CLRDATA_ADDRESS seg, struct DacpHeapSegmentData *heapSegment)
29132931
{

src/coreclr/debug/daccess/request_common.h

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,47 @@ HeapTableIndex(DPTR(unused_gc_heap**) heaps, size_t index)
103103
DacEnumMemoryRegion(p_##field_name.GetAddr(), sizeof(field_type) * array_length); \
104104
}
105105

106+
inline bool UseBuildVariant()
107+
{
108+
int major = g_gcDacGlobals->major_version_number;
109+
int minor = g_gcDacGlobals->minor_version_number;
110+
return (major > 2) || (major == 2 && minor >= 4);
111+
}
112+
106113
inline bool IsRegionGCEnabled()
107114
{
108-
return (g_gcDacGlobals->minor_version_number & 1) != 0;
115+
if (UseBuildVariant())
116+
{
117+
return (*(g_gcDacGlobals->build_variant) & build_variant_use_region) != 0;
118+
}
119+
else
120+
{
121+
return (g_gcDacGlobals->minor_version_number & 1) != 0;
122+
}
109123
}
110124

111125
inline bool IsBackgroundGCEnabled()
112126
{
113-
return (g_gcDacGlobals->minor_version_number & 2) == 0;
127+
if (UseBuildVariant())
128+
{
129+
return (*(g_gcDacGlobals->build_variant) & build_variant_background_gc) != 0;
130+
}
131+
else
132+
{
133+
return (g_gcDacGlobals->minor_version_number & 2) == 0;
134+
}
135+
}
136+
137+
inline bool IsDatasEnabled()
138+
{
139+
if (UseBuildVariant())
140+
{
141+
return (*(g_gcDacGlobals->build_variant) & build_variant_dynamic_heap_count) != 0;
142+
}
143+
else
144+
{
145+
return false;
146+
}
114147
}
115148

116149
// Load an instance of dac_gc_heap for the heap pointed by heap.

src/coreclr/gc/dac_gcheap_fields.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ DEFINE_MISSING_FIELD(freeable_uoh_segment)
5353
DEFINE_ARRAY_FIELD (free_regions, dac_region_free_list, FREE_REGION_KINDS)
5454
#else
5555
DEFINE_MISSING_FIELD(free_regions)
56-
#endif // ALL_FIELDS
56+
#endif // defined(ALL_FIELDS) || defined(USE_REGIONS)

src/coreclr/gc/gc.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53194,6 +53194,7 @@ bool GCHeap::IsConcurrentGCEnabled()
5319453194
void PopulateDacVars(GcDacVars *gcDacVars)
5319553195
{
5319653196
bool v2 = gcDacVars->minor_version_number >= 2;
53197+
bool v4 = gcDacVars->minor_version_number >= 4;
5319753198

5319853199
#define DEFINE_FIELD(field_name, field_type) offsetof(CLASS_NAME, field_name),
5319953200
#define DEFINE_DPTR_FIELD(field_name, field_type) offsetof(CLASS_NAME, field_name),
@@ -53225,15 +53226,16 @@ void PopulateDacVars(GcDacVars *gcDacVars)
5322553226
// work differently than .Net SOS. When making breaking changes here you may need to
5322653227
// find NativeAOT's equivalent of SOS_BREAKING_CHANGE_VERSION and increment it.
5322753228
gcDacVars->major_version_number = 2;
53228-
gcDacVars->minor_version_number = 0;
53229+
gcDacVars->minor_version_number = 4;
5322953230
if (v2)
5323053231
{
5323153232
gcDacVars->total_bookkeeping_elements = total_bookkeeping_elements;
5323253233
gcDacVars->card_table_info_size = sizeof(card_table_info);
5323353234
}
5323453235

53236+
g_build_variant = 0;
5323553237
#ifdef USE_REGIONS
53236-
gcDacVars->minor_version_number |= 1;
53238+
g_build_variant |= build_variant_use_region;
5323753239
if (v2)
5323853240
{
5323953241
gcDacVars->count_free_region_kinds = count_free_region_kinds;
@@ -53242,8 +53244,11 @@ void PopulateDacVars(GcDacVars *gcDacVars)
5324253244
}
5324353245
#endif //USE_REGIONS
5324453246
#ifndef BACKGROUND_GC
53245-
gcDacVars->minor_version_number |= 2;
53247+
g_build_variant |= build_variant_background_gc;
5324653248
#endif //!BACKGROUND_GC
53249+
#ifdef DYNAMIC_HEAP_COUNT
53250+
g_build_variant |= build_variant_dynamic_heap_count;
53251+
#endif //DYNAMIC_HEAP_COUNT
5324753252
gcDacVars->built_with_svr = &g_built_with_svr_gc;
5324853253
gcDacVars->build_variant = &g_build_variant;
5324953254
gcDacVars->gc_structures_invalid_cnt = const_cast<int32_t*>(&GCScan::m_GcStructuresInvalidCnt);
@@ -53319,6 +53324,14 @@ void PopulateDacVars(GcDacVars *gcDacVars)
5331953324
{
5332053325
gcDacVars->bookkeeping_start = &gc_heap::bookkeeping_start;
5332153326
}
53327+
if (v4)
53328+
{
53329+
#ifdef DYNAMIC_HEAP_COUNT
53330+
gcDacVars->dynamic_adaptation_mode = &gc_heap::dynamic_adaptation_mode;
53331+
#else
53332+
gcDacVars->dynamic_adaptation_mode = nullptr;
53333+
#endif //DYNAMIC_HEAP_COUNT
53334+
}
5332253335
}
5332353336

5332453337
int GCHeap::RefreshMemoryLimit()

src/coreclr/gc/gcinterface.dac.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ struct unused_generation
206206
uint8_t unused;
207207
};
208208

209+
#define build_variant_use_region 1
210+
#define build_variant_background_gc 2
211+
#define build_variant_dynamic_heap_count 4
212+
209213
// The DAC links against six symbols that build as part of the VM DACCESS_COMPILE
210214
// build. These symbols are considered to be GC-private functions, but the DAC needs
211215
// to use them in order to perform some handle-related functions. These six functions

src/coreclr/gc/gcinterface.dacvars.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ GC_DAC_VAL (int, total_bookkeeping_elements)
8888
GC_DAC_VAL (int, count_free_region_kinds)
8989
GC_DAC_VAL (size_t, card_table_info_size)
9090

91+
// Here is where v5.4 fields starts
92+
GC_DAC_VAR (int, dynamic_adaptation_mode)
93+
9194
#undef GC_DAC_VAR
9295
#undef GC_DAC_ARRAY_VAR
9396
#undef GC_DAC_PTR_VAR

src/coreclr/gc/gcinterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// The minor version of the IGCHeap interface. Non-breaking changes are required
1212
// to bump the minor version number. GCs and EEs with minor version number
1313
// mismatches can still interoperate correctly, with some care.
14-
#define GC_INTERFACE_MINOR_VERSION 3
14+
#define GC_INTERFACE_MINOR_VERSION 4
1515

1616
// The major version of the IGCToCLR interface. Breaking changes to this interface
1717
// require bumps in the major version number.

src/coreclr/inc/sospriv.idl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,3 +562,13 @@ interface ISOSDacInterface15 : IUnknown
562562
{
563563
HRESULT GetMethodTableSlotEnumerator(CLRDATA_ADDRESS mt, ISOSMethodEnum **enumerator);
564564
}
565+
566+
[
567+
object,
568+
local,
569+
uuid(4ba12ff8-daac-4e43-ac56-98cf8d5c595d)
570+
]
571+
interface ISOSDacInterface16 : IUnknown
572+
{
573+
HRESULT GetGCDynamicAdaptationMode(int* pDynamicAdaptationMode);
574+
}

src/coreclr/pal/prebuilt/idl/sospriv_i.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ MIDL_DEFINE_GUID(IID, IID_ISOSMethodEnum,0x3c0fe725,0xc324,0x4a4f,0x81,0x00,0xd3
127127

128128
MIDL_DEFINE_GUID(IID, IID_ISOSDacInterface15,0x7ed81261,0x52a9,0x4a23,0xa3,0x58,0xc3,0x31,0x3d,0xea,0x30,0xa8);
129129

130+
131+
MIDL_DEFINE_GUID(IID, IID_ISOSDacInterface16,0x4ba12ff8,0xdaac,0x4e43,0xac,0x56,0x98,0xcf,0x8d,0x5c,0x59,0x5d);
132+
130133
#undef MIDL_DEFINE_GUID
131134

132135
#ifdef __cplusplus

src/coreclr/pal/prebuilt/inc/sospriv.h

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3685,6 +3685,86 @@ EXTERN_C const IID IID_ISOSDacInterface15;
36853685
#endif /* __ISOSDacInterface15_INTERFACE_DEFINED__ */
36863686

36873687

3688+
#ifndef __ISOSDacInterface16_INTERFACE_DEFINED__
3689+
#define __ISOSDacInterface16_INTERFACE_DEFINED__
3690+
3691+
/* interface ISOSDacInterface16 */
3692+
/* [uuid][local][object] */
3693+
3694+
3695+
EXTERN_C const IID IID_ISOSDacInterface16;
3696+
3697+
#if defined(__cplusplus) && !defined(CINTERFACE)
3698+
3699+
MIDL_INTERFACE("4ba12ff8-daac-4e43-ac56-98cf8d5c595d")
3700+
ISOSDacInterface16 : public IUnknown
3701+
{
3702+
public:
3703+
virtual HRESULT STDMETHODCALLTYPE GetGCDynamicAdaptationMode(
3704+
int *pDynamicAdaptationMode) = 0;
3705+
3706+
};
3707+
3708+
3709+
#else /* C style interface */
3710+
3711+
typedef struct ISOSDacInterface16Vtbl
3712+
{
3713+
BEGIN_INTERFACE
3714+
3715+
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
3716+
ISOSDacInterface16 * This,
3717+
/* [in] */ REFIID riid,
3718+
/* [annotation][iid_is][out] */
3719+
_COM_Outptr_ void **ppvObject);
3720+
3721+
ULONG ( STDMETHODCALLTYPE *AddRef )(
3722+
ISOSDacInterface16 * This);
3723+
3724+
ULONG ( STDMETHODCALLTYPE *Release )(
3725+
ISOSDacInterface16 * This);
3726+
3727+
HRESULT ( STDMETHODCALLTYPE *GetGCDynamicAdaptationMode )(
3728+
ISOSDacInterface16 * This,
3729+
int *pDynamicAdaptationMode);
3730+
3731+
END_INTERFACE
3732+
} ISOSDacInterface16Vtbl;
3733+
3734+
interface ISOSDacInterface16
3735+
{
3736+
CONST_VTBL struct ISOSDacInterface16Vtbl *lpVtbl;
3737+
};
3738+
3739+
3740+
3741+
#ifdef COBJMACROS
3742+
3743+
3744+
#define ISOSDacInterface16_QueryInterface(This,riid,ppvObject) \
3745+
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
3746+
3747+
#define ISOSDacInterface16_AddRef(This) \
3748+
( (This)->lpVtbl -> AddRef(This) )
3749+
3750+
#define ISOSDacInterface16_Release(This) \
3751+
( (This)->lpVtbl -> Release(This) )
3752+
3753+
3754+
#define ISOSDacInterface16_GetGCDynamicAdaptationMode(This,pDynamicAdaptationMode) \
3755+
( (This)->lpVtbl -> GetGCDynamicAdaptationMode(This,pDynamicAdaptationMode) )
3756+
3757+
#endif /* COBJMACROS */
3758+
3759+
3760+
#endif /* C style interface */
3761+
3762+
3763+
3764+
3765+
#endif /* __ISOSDacInterface16_INTERFACE_DEFINED__ */
3766+
3767+
36883768
/* Additional Prototypes for ALL interfaces */
36893769

36903770
/* end of Additional Prototypes */

0 commit comments

Comments
 (0)