diff --git a/src/coreclr/debug/runtimeinfo/datadescriptor.h b/src/coreclr/debug/runtimeinfo/datadescriptor.h index 647583b0e87fe5..2d7e6aabc701fa 100644 --- a/src/coreclr/debug/runtimeinfo/datadescriptor.h +++ b/src/coreclr/debug/runtimeinfo/datadescriptor.h @@ -959,6 +959,8 @@ CDAC_GLOBAL(MethodDescAlignment, uint64, MethodDesc::ALIGNMENT) CDAC_GLOBAL(ObjectHeaderSize, uint64, OBJHEADER_SIZE) CDAC_GLOBAL(SyncBlockValueToObjectOffset, uint16, OBJHEADER_SIZE - cdac_data::SyncBlockValue) CDAC_GLOBAL(StubCodeBlockLast, uint8, STUB_CODE_BLOCK_LAST) +CDAC_GLOBAL(MaxClrNotificationArgs, uint32, MAX_CLR_NOTIFICATION_ARGS) +CDAC_GLOBAL_POINTER(ClrNotificationArguments, &::g_clrNotificationArguments) CDAC_GLOBAL_POINTER(ArrayBoundsZero, cdac_data::ArrayBoundsZero) CDAC_GLOBAL_POINTER(ExceptionMethodTable, &::g_pExceptionClass) CDAC_GLOBAL_POINTER(FreeObjectMethodTable, &::g_pFreeObjectMethodTable) diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Constants.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Constants.cs index b4e0011e1da0a4..3ef762eed2187e 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Constants.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Constants.cs @@ -53,6 +53,8 @@ public static class Globals public const string ExecutionManagerCodeRangeMapAddress = nameof(ExecutionManagerCodeRangeMapAddress); public const string StubCodeBlockLast = nameof(StubCodeBlockLast); + public const string MaxClrNotificationArgs = nameof(MaxClrNotificationArgs); + public const string ClrNotificationArguments = nameof(ClrNotificationArguments); public const string PlatformMetadata = nameof(PlatformMetadata); public const string ProfilerControlBlock = nameof(ProfilerControlBlock); diff --git a/src/native/managed/cdac/mscordaccore_universal/Legacy/SOSDacImpl.cs b/src/native/managed/cdac/mscordaccore_universal/Legacy/SOSDacImpl.cs index 1e67b1a01bebd3..0d125449c71154 100644 --- a/src/native/managed/cdac/mscordaccore_universal/Legacy/SOSDacImpl.cs +++ b/src/native/managed/cdac/mscordaccore_universal/Legacy/SOSDacImpl.cs @@ -1851,7 +1851,48 @@ int ISOSDacInterface3.GetGCGlobalMechanisms(nuint* globalMechanisms) #region ISOSDacInterface4 int ISOSDacInterface4.GetClrNotification(ClrDataAddress[] arguments, int count, int* pNeeded) - => _legacyImpl4 is not null ? _legacyImpl4.GetClrNotification(arguments, count, pNeeded) : HResults.E_NOTIMPL; + { + int hr = HResults.S_OK; + uint MaxClrNotificationArgs = _target.ReadGlobal(Constants.Globals.MaxClrNotificationArgs); + try + { + *pNeeded = (int)MaxClrNotificationArgs; + TargetPointer basePtr = _target.ReadGlobalPointer(Constants.Globals.ClrNotificationArguments); + if (_target.ReadNUInt(basePtr).Value == 0) + { + hr = HResults.E_FAIL; + } + else + { + for (int i = 0; i < count && i < MaxClrNotificationArgs; i++) + { + arguments[i] = _target.ReadNUInt(basePtr.Value + (ulong)(i * _target.PointerSize)).Value; + } + } + } + catch (System.Exception ex) + { + hr = ex.HResult; + } +#if DEBUG + if (_legacyImpl4 is not null) + { + ClrDataAddress[] argumentsLocal = new ClrDataAddress[count]; + int neededLocal; + int hrLocal = _legacyImpl4.GetClrNotification(argumentsLocal, count, &neededLocal); + Debug.Assert(hrLocal == hr, $"cDAC: {hr:x}, DAC: {hrLocal:x}"); + if (hr == HResults.S_OK) + { + Debug.Assert(*pNeeded == neededLocal); + for (int i = 0; i < count && i < MaxClrNotificationArgs; i++) + { + Debug.Assert(arguments[i] == argumentsLocal[i]); + } + } + } +#endif + return hr; + } #endregion ISOSDacInterface4 #region ISOSDacInterface5