Skip to content

Commit 078f8ca

Browse files
authored
Adding GetClrNotification cDAC API (#117737)
* Adding GetClrNotification cDAC API
1 parent e69e2b3 commit 078f8ca

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

src/coreclr/debug/runtimeinfo/datadescriptor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,8 @@ CDAC_GLOBAL(MethodDescAlignment, uint64, MethodDesc::ALIGNMENT)
963963
CDAC_GLOBAL(ObjectHeaderSize, uint64, OBJHEADER_SIZE)
964964
CDAC_GLOBAL(SyncBlockValueToObjectOffset, uint16, OBJHEADER_SIZE - cdac_data<ObjHeader>::SyncBlockValue)
965965
CDAC_GLOBAL(StubCodeBlockLast, uint8, STUB_CODE_BLOCK_LAST)
966+
CDAC_GLOBAL(MaxClrNotificationArgs, uint32, MAX_CLR_NOTIFICATION_ARGS)
967+
CDAC_GLOBAL_POINTER(ClrNotificationArguments, &::g_clrNotificationArguments)
966968
CDAC_GLOBAL_POINTER(ArrayBoundsZero, cdac_data<ArrayBase>::ArrayBoundsZero)
967969
CDAC_GLOBAL_POINTER(ExceptionMethodTable, &::g_pExceptionClass)
968970
CDAC_GLOBAL_POINTER(FreeObjectMethodTable, &::g_pFreeObjectMethodTable)

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public static class Globals
5454

5555
public const string ExecutionManagerCodeRangeMapAddress = nameof(ExecutionManagerCodeRangeMapAddress);
5656
public const string StubCodeBlockLast = nameof(StubCodeBlockLast);
57+
public const string MaxClrNotificationArgs = nameof(MaxClrNotificationArgs);
58+
public const string ClrNotificationArguments = nameof(ClrNotificationArguments);
5759
public const string PlatformMetadata = nameof(PlatformMetadata);
5860
public const string ProfilerControlBlock = nameof(ProfilerControlBlock);
5961

src/native/managed/cdac/mscordaccore_universal/Legacy/SOSDacImpl.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,48 @@ int ISOSDacInterface3.GetGCGlobalMechanisms(nuint* globalMechanisms)
19621962

19631963
#region ISOSDacInterface4
19641964
int ISOSDacInterface4.GetClrNotification(ClrDataAddress[] arguments, int count, int* pNeeded)
1965-
=> _legacyImpl4 is not null ? _legacyImpl4.GetClrNotification(arguments, count, pNeeded) : HResults.E_NOTIMPL;
1965+
{
1966+
int hr = HResults.S_OK;
1967+
uint MaxClrNotificationArgs = _target.ReadGlobal<uint>(Constants.Globals.MaxClrNotificationArgs);
1968+
try
1969+
{
1970+
*pNeeded = (int)MaxClrNotificationArgs;
1971+
TargetPointer basePtr = _target.ReadGlobalPointer(Constants.Globals.ClrNotificationArguments);
1972+
if (_target.ReadNUInt(basePtr).Value == 0)
1973+
{
1974+
hr = HResults.E_FAIL;
1975+
}
1976+
else
1977+
{
1978+
for (int i = 0; i < count && i < MaxClrNotificationArgs; i++)
1979+
{
1980+
arguments[i] = _target.ReadNUInt(basePtr.Value + (ulong)(i * _target.PointerSize)).Value;
1981+
}
1982+
}
1983+
}
1984+
catch (System.Exception ex)
1985+
{
1986+
hr = ex.HResult;
1987+
}
1988+
#if DEBUG
1989+
if (_legacyImpl4 is not null)
1990+
{
1991+
ClrDataAddress[] argumentsLocal = new ClrDataAddress[count];
1992+
int neededLocal;
1993+
int hrLocal = _legacyImpl4.GetClrNotification(argumentsLocal, count, &neededLocal);
1994+
Debug.Assert(hrLocal == hr, $"cDAC: {hr:x}, DAC: {hrLocal:x}");
1995+
if (hr == HResults.S_OK)
1996+
{
1997+
Debug.Assert(*pNeeded == neededLocal);
1998+
for (int i = 0; i < count && i < MaxClrNotificationArgs; i++)
1999+
{
2000+
Debug.Assert(arguments[i] == argumentsLocal[i]);
2001+
}
2002+
}
2003+
}
2004+
#endif
2005+
return hr;
2006+
}
19662007
#endregion ISOSDacInterface4
19672008

19682009
#region ISOSDacInterface5

0 commit comments

Comments
 (0)