From a8c8caf4a80f127f5a37720e18f8e4a4fbd0d665 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 2 Jul 2024 12:36:50 -0700 Subject: [PATCH 1/7] Make cDAC implement ISOSDacInterface2 --- .../cdacreader/src/Legacy/ISOSDacInterface.cs | 24 +++++++++++++++++++ .../cdacreader/src/Legacy/SOSDacImpl.cs | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/native/managed/cdacreader/src/Legacy/ISOSDacInterface.cs b/src/native/managed/cdacreader/src/Legacy/ISOSDacInterface.cs index bd0d20e65b77c..4476370761907 100644 --- a/src/native/managed/cdacreader/src/Legacy/ISOSDacInterface.cs +++ b/src/native/managed/cdacreader/src/Legacy/ISOSDacInterface.cs @@ -285,6 +285,30 @@ internal unsafe partial interface ISOSDacInterface int GetFailedAssemblyDisplayName(ulong assembly, uint count, char* name, uint* pNeeded); }; +#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value +internal struct DacpExceptionObjectData +{ + public ulong Message; + public ulong InnerException; + public ulong StackTrace; + public ulong WatsonBuckets; + public ulong StackTraceString; + public ulong RemoteStackTraceString; + public int HResult; + public int XCode; +} +#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value + +[GeneratedComInterface] +[Guid("A16026EC-96F4-40BA-87FB-5575986FB7AF")] +internal unsafe partial interface ISOSDacInterface2 +{ + [PreserveSig] + int GetObjectExceptionData(ulong objectAddress, DacpExceptionObjectData* data); + [PreserveSig] + int IsRCWDCOMProxy(ulong rcwAddress, int* inDCOMProxy); +} + [GeneratedComInterface] [Guid("4eca42d8-7e7b-4c8a-a116-7bfbf6929267")] internal partial interface ISOSDacInterface9 diff --git a/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs b/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs index 8dc36985a9add..085259afb9226 100644 --- a/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs +++ b/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs @@ -17,7 +17,7 @@ namespace Microsoft.Diagnostics.DataContractReader.Legacy; /// corresponding error code. /// [GeneratedComClass] -internal sealed partial class SOSDacImpl : ISOSDacInterface, ISOSDacInterface9 +internal sealed partial class SOSDacImpl : ISOSDacInterface, ISOSDacInterface2, ISOSDacInterface9 { private readonly Target _target; @@ -109,6 +109,7 @@ public unsafe int GetNestedExceptionData(ulong exception, ulong* exceptionObject public unsafe int GetObjectClassName(ulong obj, uint count, char* className, uint* pNeeded) => HResults.E_NOTIMPL; public unsafe int GetObjectData(ulong objAddr, void* data) => HResults.E_NOTIMPL; + public unsafe int GetObjectExceptionData(ulong objectAddress, DacpExceptionObjectData* data) => HResults.E_NOTIMPL; public unsafe int GetObjectStringData(ulong obj, uint count, char* stringData, uint* pNeeded) => HResults.E_NOTIMPL; public unsafe int GetOOMData(ulong oomAddr, void* data) => HResults.E_NOTIMPL; public unsafe int GetOOMStaticData(void* data) => HResults.E_NOTIMPL; @@ -192,6 +193,7 @@ public unsafe int GetThreadStoreData(DacpThreadStoreData* data) public unsafe int GetTLSIndex(uint* pIndex) => HResults.E_NOTIMPL; public unsafe int GetUsefulGlobals(void* data) => HResults.E_NOTIMPL; public unsafe int GetWorkRequestData(ulong addrWorkRequest, void* data) => HResults.E_NOTIMPL; + public unsafe int IsRCWDCOMProxy(ulong rcwAddress, int* inDCOMProxy) => HResults.E_NOTIMPL; public unsafe int TraverseEHInfo(ulong ip, void* pCallback, void* token) => HResults.E_NOTIMPL; public unsafe int TraverseLoaderHeap(ulong loaderHeapAddr, void* pCallback) => HResults.E_NOTIMPL; public unsafe int TraverseModuleMap(int mmt, ulong moduleAddr, void* pCallback, void* token) => HResults.E_NOTIMPL; From ca65ff1cdca5597652df574634fd55a87ef1c9c6 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 2 Jul 2024 12:48:01 -0700 Subject: [PATCH 2/7] Make DAC call cDAC for GetObjectExceptionData --- src/coreclr/debug/daccess/daccess.cpp | 1 + src/coreclr/debug/daccess/dacimpl.h | 2 ++ src/coreclr/debug/daccess/request.cpp | 41 +++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/coreclr/debug/daccess/daccess.cpp b/src/coreclr/debug/daccess/daccess.cpp index 6dd0f52fa2e55..5b6b4f03ef3a1 100644 --- a/src/coreclr/debug/daccess/daccess.cpp +++ b/src/coreclr/debug/daccess/daccess.cpp @@ -5512,6 +5512,7 @@ ClrDataAccess::Initialize(void) // Get SOS interfaces from the cDAC if available. IUnknown* unk = m_cdac.SosInterface(); (void)unk->QueryInterface(__uuidof(ISOSDacInterface), (void**)&m_cdacSos); + (void)unk->QueryInterface(__uuidof(ISOSDacInterface2), (void**)&m_cdacSos2); (void)unk->QueryInterface(__uuidof(ISOSDacInterface9), (void**)&m_cdacSos9); } } diff --git a/src/coreclr/debug/daccess/dacimpl.h b/src/coreclr/debug/daccess/dacimpl.h index f480eea6baaa5..07f02508b3a31 100644 --- a/src/coreclr/debug/daccess/dacimpl.h +++ b/src/coreclr/debug/daccess/dacimpl.h @@ -1232,6 +1232,7 @@ class ClrDataAccess HRESULT GetThreadDataImpl(CLRDATA_ADDRESS threadAddr, struct DacpThreadData *threadData); HRESULT GetThreadStoreDataImpl(struct DacpThreadStoreData *data); HRESULT GetNestedExceptionDataImpl(CLRDATA_ADDRESS exception, CLRDATA_ADDRESS *exceptionObject, CLRDATA_ADDRESS *nextNestedException); + HRESULT GetObjectExceptionDataImpl(CLRDATA_ADDRESS objAddr, struct DacpExceptionObjectData *data); BOOL IsExceptionFromManagedCode(EXCEPTION_RECORD * pExceptionRecord); #ifndef TARGET_UNIX @@ -1421,6 +1422,7 @@ class ClrDataAccess CDAC m_cdac; NonVMComHolder m_cdacSos; + NonVMComHolder m_cdacSos2; NonVMComHolder m_cdacSos9; #ifdef FEATURE_MINIMETADATA_IN_TRIAGEDUMPS diff --git a/src/coreclr/debug/daccess/request.cpp b/src/coreclr/debug/daccess/request.cpp index 9e15f96c03b8d..1c36c7c3c1bef 100644 --- a/src/coreclr/debug/daccess/request.cpp +++ b/src/coreclr/debug/daccess/request.cpp @@ -4571,8 +4571,42 @@ HRESULT ClrDataAccess::GetObjectExceptionData(CLRDATA_ADDRESS objAddr, struct Da SOSDacEnter(); - PTR_ExceptionObject pObj = dac_cast(TO_TADDR(objAddr)); + if (m_cdacSos2 != NULL) + { + hr = m_cdacSos2->GetObjectExceptionData(objAddr, data); + if (FAILED(hr)) + { + hr = GetObjectExceptionDataImpl(objAddr, data); + } +#ifdef _DEBUG + else + { + DacpExceptionObjectData dataLocal; + HRESULT hrLocal = GetObjectExceptionDataImpl(objAddr, &dataLocal); + _ASSERTE(hr == hrLocal); + _ASSERTE(data->Message == dataLocal.Message); + _ASSERTE(data->InnerException == dataLocal.InnerException); + _ASSERTE(data->StackTrace == dataLocal.StackTrace); + _ASSERTE(data->WatsonBuckets == dataLocal.WatsonBuckets); + _ASSERTE(data->StackTraceString == dataLocal.StackTraceString); + _ASSERTE(data->RemoteStackTraceString == dataLocal.RemoteStackTraceString); + _ASSERTE(data->HResult == dataLocal.HResult); + _ASSERTE(data->XCode == dataLocal.XCode); + } +#endif + } + else + { + hr = GetObjectExceptionDataImpl(objAddr, data); + } + SOSDacLeave(); + return hr; +} + +HRESULT ClrDataAccess::GetObjectExceptionDataImpl(CLRDATA_ADDRESS objAddr, struct DacpExceptionObjectData *data) +{ + PTR_ExceptionObject pObj = dac_cast(TO_TADDR(objAddr)); data->Message = TO_CDADDR(dac_cast(pObj->GetMessage())); data->InnerException = TO_CDADDR(dac_cast(pObj->GetInnerException())); data->StackTrace = TO_CDADDR(dac_cast(pObj->GetStackTraceArrayObject())); @@ -4581,10 +4615,7 @@ HRESULT ClrDataAccess::GetObjectExceptionData(CLRDATA_ADDRESS objAddr, struct Da data->RemoteStackTraceString = TO_CDADDR(dac_cast(pObj->GetRemoteStackTraceString())); data->HResult = pObj->GetHResult(); data->XCode = pObj->GetXCode(); - - SOSDacLeave(); - - return hr; + return S_OK; } HRESULT ClrDataAccess::IsRCWDCOMProxy(CLRDATA_ADDRESS rcwAddr, BOOL* isDCOMProxy) From 26c7632724a76424e5ae39253ef5189ad30399eb Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 2 Jul 2024 14:16:23 -0700 Subject: [PATCH 3/7] Add GetExceptionObjectData to Exception contract, implement ISOSDacInterface2::GetObjectExceptionData --- .../debug/runtimeinfo/datadescriptor.h | 12 +++++++ src/coreclr/vm/object.h | 15 +++++++++ .../cdacreader/src/Contracts/Exception.cs | 11 +++++++ .../cdacreader/src/Contracts/Exception_1.cs | 14 ++++++++ .../cdacreader/src/Data/ExceptionObject.cs | 33 +++++++++++++++++++ src/native/managed/cdacreader/src/DataType.cs | 3 +- .../cdacreader/src/Legacy/SOSDacImpl.cs | 25 +++++++++++++- 7 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 src/native/managed/cdacreader/src/Data/ExceptionObject.cs diff --git a/src/coreclr/debug/runtimeinfo/datadescriptor.h b/src/coreclr/debug/runtimeinfo/datadescriptor.h index 0c7e3f70b4d33..f4aba0fd5806e 100644 --- a/src/coreclr/debug/runtimeinfo/datadescriptor.h +++ b/src/coreclr/debug/runtimeinfo/datadescriptor.h @@ -152,6 +152,18 @@ CDAC_TYPE_FIELD(PreviousNestedInfo, /*pointer*/, PreviousNestedInfo, offsetof(Ex #endif CDAC_TYPE_END(ExceptionInfo) +CDAC_TYPE_BEGIN(ExceptionObject) +CDAC_TYPE_INDETERMINATE(ExceptionObject) +CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, Message, cdac_offsets::Message) +CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, InnerException, cdac_offsets::InnerException) +CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, StackTrace, cdac_offsets::StackTrace) +CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, WatsonBuckets, cdac_offsets::WatsonBuckets) +CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, StackTraceString, cdac_offsets::StackTraceString) +CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, RemoteStackTraceString, cdac_offsets::RemoteStackTraceString) +CDAC_TYPE_FIELD(ExceptionObject, /*int32*/, HResult, cdac_offsets::HResult) +CDAC_TYPE_FIELD(ExceptionObject, /*int32*/, XCode, cdac_offsets::XCode) +CDAC_TYPE_END(ExceptionObject) + CDAC_TYPE_BEGIN(GCHandle) CDAC_TYPE_SIZE(sizeof(OBJECTHANDLE)) CDAC_TYPE_END(GCHandle) diff --git a/src/coreclr/vm/object.h b/src/coreclr/vm/object.h index 6d65b65502314..53ff257815e38 100644 --- a/src/coreclr/vm/object.h +++ b/src/coreclr/vm/object.h @@ -2340,6 +2340,21 @@ class ExceptionObject : public Object void* _xptrs; INT32 _xcode; INT32 _HResult; + + template friend struct ::cdac_offsets; +}; + +template<> +struct cdac_offsets +{ + static constexpr size_t Message = offsetof(ExceptionObject, _message); + static constexpr size_t InnerException = offsetof(ExceptionObject, _innerException); + static constexpr size_t StackTrace = offsetof(ExceptionObject, _stackTrace); + static constexpr size_t WatsonBuckets = offsetof(ExceptionObject, _watsonBuckets); + static constexpr size_t StackTraceString = offsetof(ExceptionObject, _stackTraceString); + static constexpr size_t RemoteStackTraceString = offsetof(ExceptionObject, _remoteStackTraceString); + static constexpr size_t HResult = offsetof(ExceptionObject, _HResult); + static constexpr size_t XCode = offsetof(ExceptionObject, _xcode); }; // Defined in Contracts.cs diff --git a/src/native/managed/cdacreader/src/Contracts/Exception.cs b/src/native/managed/cdacreader/src/Contracts/Exception.cs index c06a6984db898..66b397840542a 100644 --- a/src/native/managed/cdacreader/src/Contracts/Exception.cs +++ b/src/native/managed/cdacreader/src/Contracts/Exception.cs @@ -5,6 +5,16 @@ namespace Microsoft.Diagnostics.DataContractReader.Contracts; +internal record struct ExceptionObjectData( + TargetPointer Message, + TargetPointer InnerException, + TargetPointer StackTrace, + TargetPointer WatsonBuckets, + TargetPointer StackTraceString, + TargetPointer RemoteStackTraceString, + int HResult, + int XCode); + internal interface IException : IContract { static string IContract.Name { get; } = nameof(Exception); @@ -18,6 +28,7 @@ static IContract IContract.Create(Target target, int version) } public virtual TargetPointer GetExceptionInfo(TargetPointer exception, out TargetPointer nextNestedException) => throw new NotImplementedException(); + public virtual ExceptionObjectData GetExceptionObjectData(TargetPointer exceptionObject) => throw new NotImplementedException(); } internal readonly struct Exception : IException diff --git a/src/native/managed/cdacreader/src/Contracts/Exception_1.cs b/src/native/managed/cdacreader/src/Contracts/Exception_1.cs index 57249576719ee..92d134cbda5df 100644 --- a/src/native/managed/cdacreader/src/Contracts/Exception_1.cs +++ b/src/native/managed/cdacreader/src/Contracts/Exception_1.cs @@ -20,4 +20,18 @@ TargetPointer IException.GetExceptionInfo(TargetPointer exception, out TargetPoi nextNestedException = exceptionInfo.PreviousNestedInfo; return exceptionInfo.ThrownObject.Object; } + + ExceptionObjectData IException.GetExceptionObjectData(TargetPointer objectAddress) + { + Data.ExceptionObject exceptionObject = _target.ProcessedData.GetOrAdd(objectAddress); + return new ExceptionObjectData( + exceptionObject.Message, + exceptionObject.InnerException, + exceptionObject.StackTrace, + exceptionObject.WatsonBuckets, + exceptionObject.StackTraceString, + exceptionObject.RemoteStackTraceString, + exceptionObject.HResult, + exceptionObject.XCode); + } } diff --git a/src/native/managed/cdacreader/src/Data/ExceptionObject.cs b/src/native/managed/cdacreader/src/Data/ExceptionObject.cs new file mode 100644 index 0000000000000..585b341acb776 --- /dev/null +++ b/src/native/managed/cdacreader/src/Data/ExceptionObject.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.Diagnostics.DataContractReader.Data; + +internal sealed class ExceptionObject : IData +{ + static ExceptionObject IData.Create(Target target, TargetPointer address) + => new ExceptionObject(target, address); + + public ExceptionObject(Target target, TargetPointer address) + { + Target.TypeInfo type = target.GetTypeInfo(DataType.ExceptionObject); + + Message = target.ReadPointer(address + (ulong)type.Fields[nameof(Message)].Offset); + InnerException = target.ReadPointer(address + (ulong)type.Fields[nameof(InnerException)].Offset); + StackTrace = target.ReadPointer(address + (ulong)type.Fields[nameof(StackTrace)].Offset); + WatsonBuckets = target.ReadPointer(address + (ulong)type.Fields[nameof(WatsonBuckets)].Offset); + StackTraceString = target.ReadPointer(address + (ulong)type.Fields[nameof(StackTraceString)].Offset); + RemoteStackTraceString = target.ReadPointer(address + (ulong)type.Fields[nameof(RemoteStackTraceString)].Offset); + HResult = target.Read(address + (ulong)type.Fields[nameof(HResult)].Offset); + XCode = target.Read(address + (ulong)type.Fields[nameof(XCode)].Offset); + } + + public TargetPointer Message { get; init; } + public TargetPointer InnerException { get; init; } + public TargetPointer StackTrace { get; init; } + public TargetPointer WatsonBuckets { get; init; } + public TargetPointer StackTraceString { get; init; } + public TargetPointer RemoteStackTraceString { get; init; } + public int HResult { get; init; } + public int XCode { get; init; } +} diff --git a/src/native/managed/cdacreader/src/DataType.cs b/src/native/managed/cdacreader/src/DataType.cs index 94274d5f47a8b..99319cf73ef15 100644 --- a/src/native/managed/cdacreader/src/DataType.cs +++ b/src/native/managed/cdacreader/src/DataType.cs @@ -24,5 +24,6 @@ public enum DataType ThreadStore, GCAllocContext, ExceptionInfo, - RuntimeThreadLocals + ExceptionObject, + RuntimeThreadLocals, } diff --git a/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs b/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs index 085259afb9226..b0727a6ded78a 100644 --- a/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs +++ b/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs @@ -109,7 +109,30 @@ public unsafe int GetNestedExceptionData(ulong exception, ulong* exceptionObject public unsafe int GetObjectClassName(ulong obj, uint count, char* className, uint* pNeeded) => HResults.E_NOTIMPL; public unsafe int GetObjectData(ulong objAddr, void* data) => HResults.E_NOTIMPL; - public unsafe int GetObjectExceptionData(ulong objectAddress, DacpExceptionObjectData* data) => HResults.E_NOTIMPL; + + public unsafe int GetObjectExceptionData(ulong objectAddress, DacpExceptionObjectData* data) + { + try + { + Contracts.IException contract = _target.Contracts.Exception; + Contracts.ExceptionObjectData exceptionData = contract.GetExceptionObjectData(objectAddress); + data->Message = exceptionData.Message; + data->InnerException = exceptionData.InnerException; + data->StackTrace = exceptionData.StackTrace; + data->WatsonBuckets = exceptionData.WatsonBuckets; + data->StackTraceString = exceptionData.StackTraceString; + data->RemoteStackTraceString = exceptionData.RemoteStackTraceString; + data->HResult = exceptionData.HResult; + data->XCode = exceptionData.XCode; + } + catch (Exception ex) + { + return ex.HResult; + } + + return HResults.S_OK; + } + public unsafe int GetObjectStringData(ulong obj, uint count, char* stringData, uint* pNeeded) => HResults.E_NOTIMPL; public unsafe int GetOOMData(ulong oomAddr, void* data) => HResults.E_NOTIMPL; public unsafe int GetOOMStaticData(void* data) => HResults.E_NOTIMPL; From 1e553280be728a0a03a85edb1d49daf64ebf6377 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 2 Jul 2024 14:18:19 -0700 Subject: [PATCH 4/7] Update Exception contract doc --- docs/design/datacontracts/Exception.md | 34 +++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/docs/design/datacontracts/Exception.md b/docs/design/datacontracts/Exception.md index e507c23f00c4f..51a04a99afdaf 100644 --- a/docs/design/datacontracts/Exception.md +++ b/docs/design/datacontracts/Exception.md @@ -1,17 +1,31 @@ -# Contract Thread +# Contract Exception This contract is for getting information about exceptions in the process. ## APIs of contract +```csharp +record struct ExceptionObjectData( + TargetPointer Message, + TargetPointer InnerException, + TargetPointer StackTrace, + TargetPointer WatsonBuckets, + TargetPointer StackTraceString, + TargetPointer RemoteStackTraceString, + int HResult, + int XCode); +``` + ``` csharp TargetPointer GetExceptionInfo(TargetPointer exception, out TargetPointer nextNestedException); +ExceptionObjectData GetExceptionObjectData(TargetPointer objectAddress); ``` ## Version 1 Data descriptors used: - `ExceptionInfo` +- `ExceptionObject` ``` csharp TargetPointer GetExceptionInfo(TargetPointer exception, out TargetPointer nextNestedException) @@ -19,10 +33,24 @@ TargetPointer GetExceptionInfo(TargetPointer exception, out TargetPointer nextNe if (exception == TargetPointer.Null) throw new InvalidArgumentException(); - nextNestedException = target.ReadPointer(address + /* ExceptionInfo::PreviousNestedInfo offset*/); - TargetPointer thrownObjHandle = target.ReadPointer(address + /* ExceptionInfo::ThrownObject offset */); + nextNestedException = target.ReadPointer(exception + /* ExceptionInfo::PreviousNestedInfo offset*/); + TargetPointer thrownObjHandle = target.ReadPointer(exception + /* ExceptionInfo::ThrownObject offset */); return = thrownObjHandle != TargetPointer.Null ? target.ReadPointer(thrownObjHandle) : TargetPointer.Null; } + +ExceptionObjectData GetExceptionObjectData(TargetPointer objectAddress) +{ + return new ExceptionObjectData( + target.ReadPointer(objectAddress + /* ExceptionObject::Message offset */), + target.ReadPointer(objectAddress + /* ExceptionObject::InnerException offset */), + target.ReadPointer(objectAddress + /* ExceptionObject::StackTrace offset */), + target.ReadPointer(objectAddress + /* ExceptionObject::WatsonBuckets offset */), + target.ReadPointer(objectAddress + /* ExceptionObject::StackTraceString offset */), + target.ReadPointer(objectAddress + /* ExceptionObject::RemoteStackTraceString offset */), + target.Read(objectAddress + /* ExceptionObject::HResult offset */), + target.Read(objectAddress + /* ExceptionObject::XCode offset */), + ); +} ``` From 451405680e41d5f1002ad6b2d3c2d44ccbd362a3 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 8 Jul 2024 10:27:42 -0700 Subject: [PATCH 5/7] Use exast field names --- .../debug/runtimeinfo/datadescriptor.h | 26 +++++++++++-------- src/coreclr/vm/object.h | 18 ++++++------- .../cdacreader/src/Data/ExceptionObject.cs | 16 ++++++------ 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/coreclr/debug/runtimeinfo/datadescriptor.h b/src/coreclr/debug/runtimeinfo/datadescriptor.h index f4aba0fd5806e..8732b2f1a9e05 100644 --- a/src/coreclr/debug/runtimeinfo/datadescriptor.h +++ b/src/coreclr/debug/runtimeinfo/datadescriptor.h @@ -141,6 +141,21 @@ CDAC_TYPE_FIELD(GCAllocContext, /*pointer*/, Pointer, offsetof(gc_alloc_context, CDAC_TYPE_FIELD(GCAllocContext, /*pointer*/, Limit, offsetof(gc_alloc_context, alloc_limit)) CDAC_TYPE_END(GCAllocContext) +// Exception + +// Use exact managed type field names for the descriptor as field names often can't change due to binary serialization or implicit diagnostic contracts +CDAC_TYPE_BEGIN(ExceptionObject) +CDAC_TYPE_INDETERMINATE(ExceptionObject) +CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, _message, cdac_offsets::_message) +CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, _innerException, cdac_offsets::_innerException) +CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, _stackTrace, cdac_offsets::_stackTrace) +CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, _watsonBuckets, cdac_offsets::_watsonBuckets) +CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, _stackTraceString, cdac_offsets::_stackTraceString) +CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, _remoteStackTraceString, cdac_offsets::_remoteStackTraceString) +CDAC_TYPE_FIELD(ExceptionObject, /*int32*/, _HResult, cdac_offsets::_HResult) +CDAC_TYPE_FIELD(ExceptionObject, /*int32*/, _xcode, cdac_offsets::_xcode) +CDAC_TYPE_END(ExceptionObject) + CDAC_TYPE_BEGIN(ExceptionInfo) CDAC_TYPE_INDETERMINATE(ExceptionInfo) #if FEATURE_EH_FUNCLETS @@ -152,17 +167,6 @@ CDAC_TYPE_FIELD(PreviousNestedInfo, /*pointer*/, PreviousNestedInfo, offsetof(Ex #endif CDAC_TYPE_END(ExceptionInfo) -CDAC_TYPE_BEGIN(ExceptionObject) -CDAC_TYPE_INDETERMINATE(ExceptionObject) -CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, Message, cdac_offsets::Message) -CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, InnerException, cdac_offsets::InnerException) -CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, StackTrace, cdac_offsets::StackTrace) -CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, WatsonBuckets, cdac_offsets::WatsonBuckets) -CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, StackTraceString, cdac_offsets::StackTraceString) -CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, RemoteStackTraceString, cdac_offsets::RemoteStackTraceString) -CDAC_TYPE_FIELD(ExceptionObject, /*int32*/, HResult, cdac_offsets::HResult) -CDAC_TYPE_FIELD(ExceptionObject, /*int32*/, XCode, cdac_offsets::XCode) -CDAC_TYPE_END(ExceptionObject) CDAC_TYPE_BEGIN(GCHandle) CDAC_TYPE_SIZE(sizeof(OBJECTHANDLE)) diff --git a/src/coreclr/vm/object.h b/src/coreclr/vm/object.h index 53ff257815e38..59416d4af7c53 100644 --- a/src/coreclr/vm/object.h +++ b/src/coreclr/vm/object.h @@ -2096,7 +2096,7 @@ class LoaderAllocatorObject : public Object INT32 GetSlotsUsed(); void SetSlotsUsed(INT32 newSlotsUsed); #endif // DACCESS_COMPILE - + void SetNativeLoaderAllocator(LoaderAllocator * pLoaderAllocator) { LIMITED_METHOD_CONTRACT; @@ -2347,14 +2347,14 @@ class ExceptionObject : public Object template<> struct cdac_offsets { - static constexpr size_t Message = offsetof(ExceptionObject, _message); - static constexpr size_t InnerException = offsetof(ExceptionObject, _innerException); - static constexpr size_t StackTrace = offsetof(ExceptionObject, _stackTrace); - static constexpr size_t WatsonBuckets = offsetof(ExceptionObject, _watsonBuckets); - static constexpr size_t StackTraceString = offsetof(ExceptionObject, _stackTraceString); - static constexpr size_t RemoteStackTraceString = offsetof(ExceptionObject, _remoteStackTraceString); - static constexpr size_t HResult = offsetof(ExceptionObject, _HResult); - static constexpr size_t XCode = offsetof(ExceptionObject, _xcode); + static constexpr size_t _message = offsetof(ExceptionObject, _message); + static constexpr size_t _innerException = offsetof(ExceptionObject, _innerException); + static constexpr size_t _stackTrace = offsetof(ExceptionObject, _stackTrace); + static constexpr size_t _watsonBuckets = offsetof(ExceptionObject, _watsonBuckets); + static constexpr size_t _stackTraceString = offsetof(ExceptionObject, _stackTraceString); + static constexpr size_t _remoteStackTraceString = offsetof(ExceptionObject, _remoteStackTraceString); + static constexpr size_t _HResult = offsetof(ExceptionObject, _HResult); + static constexpr size_t _xcode = offsetof(ExceptionObject, _xcode); }; // Defined in Contracts.cs diff --git a/src/native/managed/cdacreader/src/Data/ExceptionObject.cs b/src/native/managed/cdacreader/src/Data/ExceptionObject.cs index 585b341acb776..70f5629409e0c 100644 --- a/src/native/managed/cdacreader/src/Data/ExceptionObject.cs +++ b/src/native/managed/cdacreader/src/Data/ExceptionObject.cs @@ -12,14 +12,14 @@ public ExceptionObject(Target target, TargetPointer address) { Target.TypeInfo type = target.GetTypeInfo(DataType.ExceptionObject); - Message = target.ReadPointer(address + (ulong)type.Fields[nameof(Message)].Offset); - InnerException = target.ReadPointer(address + (ulong)type.Fields[nameof(InnerException)].Offset); - StackTrace = target.ReadPointer(address + (ulong)type.Fields[nameof(StackTrace)].Offset); - WatsonBuckets = target.ReadPointer(address + (ulong)type.Fields[nameof(WatsonBuckets)].Offset); - StackTraceString = target.ReadPointer(address + (ulong)type.Fields[nameof(StackTraceString)].Offset); - RemoteStackTraceString = target.ReadPointer(address + (ulong)type.Fields[nameof(RemoteStackTraceString)].Offset); - HResult = target.Read(address + (ulong)type.Fields[nameof(HResult)].Offset); - XCode = target.Read(address + (ulong)type.Fields[nameof(XCode)].Offset); + Message = target.ReadPointer(address + (ulong)type.Fields["_message"].Offset); + InnerException = target.ReadPointer(address + (ulong)type.Fields["_innerException"].Offset); + StackTrace = target.ReadPointer(address + (ulong)type.Fields["_stackTrace"].Offset); + WatsonBuckets = target.ReadPointer(address + (ulong)type.Fields["_watsonBuckets"].Offset); + StackTraceString = target.ReadPointer(address + (ulong)type.Fields["_stackTraceString"].Offset); + RemoteStackTraceString = target.ReadPointer(address + (ulong)type.Fields["_remoteStackTraceString"].Offset); + HResult = target.Read(address + (ulong)type.Fields["_HResult"].Offset); + XCode = target.Read(address + (ulong)type.Fields["_xcode"].Offset); } public TargetPointer Message { get; init; } From 86875bab15bf1c5107681ca128b8eeb8404df1aa Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 8 Jul 2024 10:34:47 -0700 Subject: [PATCH 6/7] ExceptionObject -> Exception --- docs/design/datacontracts/Exception.md | 24 +++++++++---------- .../debug/runtimeinfo/datadescriptor.h | 22 ++++++++--------- .../cdacreader/src/Contracts/Exception.cs | 4 ++-- .../cdacreader/src/Contracts/Exception_1.cs | 6 ++--- .../Data/{ExceptionObject.cs => Exception.cs} | 10 ++++---- src/native/managed/cdacreader/src/DataType.cs | 2 +- .../cdacreader/src/Legacy/SOSDacImpl.cs | 2 +- 7 files changed, 35 insertions(+), 35 deletions(-) rename src/native/managed/cdacreader/src/Data/{ExceptionObject.cs => Exception.cs} (83%) diff --git a/docs/design/datacontracts/Exception.md b/docs/design/datacontracts/Exception.md index 51a04a99afdaf..ad096983305b2 100644 --- a/docs/design/datacontracts/Exception.md +++ b/docs/design/datacontracts/Exception.md @@ -5,7 +5,7 @@ This contract is for getting information about exceptions in the process. ## APIs of contract ```csharp -record struct ExceptionObjectData( +record struct ManagedExceptionData( TargetPointer Message, TargetPointer InnerException, TargetPointer StackTrace, @@ -18,7 +18,7 @@ record struct ExceptionObjectData( ``` csharp TargetPointer GetExceptionInfo(TargetPointer exception, out TargetPointer nextNestedException); -ExceptionObjectData GetExceptionObjectData(TargetPointer objectAddress); +ManagedExceptionData GetManagedExceptionData(TargetPointer managedException) ``` ## Version 1 @@ -40,17 +40,17 @@ TargetPointer GetExceptionInfo(TargetPointer exception, out TargetPointer nextNe : TargetPointer.Null; } -ExceptionObjectData GetExceptionObjectData(TargetPointer objectAddress) +ManagedExceptionData GetManagedExceptionData(TargetPointer managedException) { - return new ExceptionObjectData( - target.ReadPointer(objectAddress + /* ExceptionObject::Message offset */), - target.ReadPointer(objectAddress + /* ExceptionObject::InnerException offset */), - target.ReadPointer(objectAddress + /* ExceptionObject::StackTrace offset */), - target.ReadPointer(objectAddress + /* ExceptionObject::WatsonBuckets offset */), - target.ReadPointer(objectAddress + /* ExceptionObject::StackTraceString offset */), - target.ReadPointer(objectAddress + /* ExceptionObject::RemoteStackTraceString offset */), - target.Read(objectAddress + /* ExceptionObject::HResult offset */), - target.Read(objectAddress + /* ExceptionObject::XCode offset */), + return new ManagedExceptionData( + target.ReadPointer(objectAddress + /* Exception::Message offset */), + target.ReadPointer(objectAddress + /* Exception::InnerException offset */), + target.ReadPointer(objectAddress + /* Exception::StackTrace offset */), + target.ReadPointer(objectAddress + /* Exception::WatsonBuckets offset */), + target.ReadPointer(objectAddress + /* Exception::StackTraceString offset */), + target.ReadPointer(objectAddress + /* Exception::RemoteStackTraceString offset */), + target.Read(objectAddress + /* Exception::HResult offset */), + target.Read(objectAddress + /* Exception::XCode offset */), ); } ``` diff --git a/src/coreclr/debug/runtimeinfo/datadescriptor.h b/src/coreclr/debug/runtimeinfo/datadescriptor.h index 8732b2f1a9e05..c15286032215c 100644 --- a/src/coreclr/debug/runtimeinfo/datadescriptor.h +++ b/src/coreclr/debug/runtimeinfo/datadescriptor.h @@ -144,17 +144,17 @@ CDAC_TYPE_END(GCAllocContext) // Exception // Use exact managed type field names for the descriptor as field names often can't change due to binary serialization or implicit diagnostic contracts -CDAC_TYPE_BEGIN(ExceptionObject) -CDAC_TYPE_INDETERMINATE(ExceptionObject) -CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, _message, cdac_offsets::_message) -CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, _innerException, cdac_offsets::_innerException) -CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, _stackTrace, cdac_offsets::_stackTrace) -CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, _watsonBuckets, cdac_offsets::_watsonBuckets) -CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, _stackTraceString, cdac_offsets::_stackTraceString) -CDAC_TYPE_FIELD(ExceptionObject, /*pointer*/, _remoteStackTraceString, cdac_offsets::_remoteStackTraceString) -CDAC_TYPE_FIELD(ExceptionObject, /*int32*/, _HResult, cdac_offsets::_HResult) -CDAC_TYPE_FIELD(ExceptionObject, /*int32*/, _xcode, cdac_offsets::_xcode) -CDAC_TYPE_END(ExceptionObject) +CDAC_TYPE_BEGIN(Exception) +CDAC_TYPE_INDETERMINATE(Exception) +CDAC_TYPE_FIELD(Exception, /*pointer*/, _message, cdac_offsets::_message) +CDAC_TYPE_FIELD(Exception, /*pointer*/, _innerException, cdac_offsets::_innerException) +CDAC_TYPE_FIELD(Exception, /*pointer*/, _stackTrace, cdac_offsets::_stackTrace) +CDAC_TYPE_FIELD(Exception, /*pointer*/, _watsonBuckets, cdac_offsets::_watsonBuckets) +CDAC_TYPE_FIELD(Exception, /*pointer*/, _stackTraceString, cdac_offsets::_stackTraceString) +CDAC_TYPE_FIELD(Exception, /*pointer*/, _remoteStackTraceString, cdac_offsets::_remoteStackTraceString) +CDAC_TYPE_FIELD(Exception, /*int32*/, _HResult, cdac_offsets::_HResult) +CDAC_TYPE_FIELD(Exception, /*int32*/, _xcode, cdac_offsets::_xcode) +CDAC_TYPE_END(Exception) CDAC_TYPE_BEGIN(ExceptionInfo) CDAC_TYPE_INDETERMINATE(ExceptionInfo) diff --git a/src/native/managed/cdacreader/src/Contracts/Exception.cs b/src/native/managed/cdacreader/src/Contracts/Exception.cs index 66b397840542a..9ae92b433cb9e 100644 --- a/src/native/managed/cdacreader/src/Contracts/Exception.cs +++ b/src/native/managed/cdacreader/src/Contracts/Exception.cs @@ -5,7 +5,7 @@ namespace Microsoft.Diagnostics.DataContractReader.Contracts; -internal record struct ExceptionObjectData( +internal record struct ManagedExceptionData( TargetPointer Message, TargetPointer InnerException, TargetPointer StackTrace, @@ -28,7 +28,7 @@ static IContract IContract.Create(Target target, int version) } public virtual TargetPointer GetExceptionInfo(TargetPointer exception, out TargetPointer nextNestedException) => throw new NotImplementedException(); - public virtual ExceptionObjectData GetExceptionObjectData(TargetPointer exceptionObject) => throw new NotImplementedException(); + public virtual ManagedExceptionData GetManagedExceptionData(TargetPointer managedException) => throw new NotImplementedException(); } internal readonly struct Exception : IException diff --git a/src/native/managed/cdacreader/src/Contracts/Exception_1.cs b/src/native/managed/cdacreader/src/Contracts/Exception_1.cs index 92d134cbda5df..543e2c5dabc36 100644 --- a/src/native/managed/cdacreader/src/Contracts/Exception_1.cs +++ b/src/native/managed/cdacreader/src/Contracts/Exception_1.cs @@ -21,10 +21,10 @@ TargetPointer IException.GetExceptionInfo(TargetPointer exception, out TargetPoi return exceptionInfo.ThrownObject.Object; } - ExceptionObjectData IException.GetExceptionObjectData(TargetPointer objectAddress) + ManagedExceptionData IException.GetManagedExceptionData(TargetPointer managedException) { - Data.ExceptionObject exceptionObject = _target.ProcessedData.GetOrAdd(objectAddress); - return new ExceptionObjectData( + Data.Exception exceptionObject = _target.ProcessedData.GetOrAdd(managedException); + return new ManagedExceptionData( exceptionObject.Message, exceptionObject.InnerException, exceptionObject.StackTrace, diff --git a/src/native/managed/cdacreader/src/Data/ExceptionObject.cs b/src/native/managed/cdacreader/src/Data/Exception.cs similarity index 83% rename from src/native/managed/cdacreader/src/Data/ExceptionObject.cs rename to src/native/managed/cdacreader/src/Data/Exception.cs index 70f5629409e0c..8f08dc08810e6 100644 --- a/src/native/managed/cdacreader/src/Data/ExceptionObject.cs +++ b/src/native/managed/cdacreader/src/Data/Exception.cs @@ -3,14 +3,14 @@ namespace Microsoft.Diagnostics.DataContractReader.Data; -internal sealed class ExceptionObject : IData +internal sealed class Exception : IData { - static ExceptionObject IData.Create(Target target, TargetPointer address) - => new ExceptionObject(target, address); + static Exception IData.Create(Target target, TargetPointer address) + => new Exception(target, address); - public ExceptionObject(Target target, TargetPointer address) + public Exception(Target target, TargetPointer address) { - Target.TypeInfo type = target.GetTypeInfo(DataType.ExceptionObject); + Target.TypeInfo type = target.GetTypeInfo(DataType.Exception); Message = target.ReadPointer(address + (ulong)type.Fields["_message"].Offset); InnerException = target.ReadPointer(address + (ulong)type.Fields["_innerException"].Offset); diff --git a/src/native/managed/cdacreader/src/DataType.cs b/src/native/managed/cdacreader/src/DataType.cs index 99319cf73ef15..fd440aff2ffe6 100644 --- a/src/native/managed/cdacreader/src/DataType.cs +++ b/src/native/managed/cdacreader/src/DataType.cs @@ -24,6 +24,6 @@ public enum DataType ThreadStore, GCAllocContext, ExceptionInfo, - ExceptionObject, + Exception, RuntimeThreadLocals, } diff --git a/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs b/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs index b0727a6ded78a..2fd24322cb35a 100644 --- a/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs +++ b/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs @@ -115,7 +115,7 @@ public unsafe int GetObjectExceptionData(ulong objectAddress, DacpExceptionObjec try { Contracts.IException contract = _target.Contracts.Exception; - Contracts.ExceptionObjectData exceptionData = contract.GetExceptionObjectData(objectAddress); + Contracts.ManagedExceptionData exceptionData = contract.GetManagedExceptionData(objectAddress); data->Message = exceptionData.Message; data->InnerException = exceptionData.InnerException; data->StackTrace = exceptionData.StackTrace; From 1952438301d0e1400566a3b142180f364f072191 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 9 Jul 2024 11:49:59 -0700 Subject: [PATCH 7/7] Remove Managed prefix --- docs/design/datacontracts/Exception.md | 36 +++++++++---------- .../cdacreader/src/Contracts/Exception.cs | 6 ++-- .../cdacreader/src/Contracts/Exception_1.cs | 28 +++++++-------- .../cdacreader/src/Legacy/SOSDacImpl.cs | 4 +-- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/docs/design/datacontracts/Exception.md b/docs/design/datacontracts/Exception.md index ad096983305b2..61455b180d76c 100644 --- a/docs/design/datacontracts/Exception.md +++ b/docs/design/datacontracts/Exception.md @@ -5,7 +5,7 @@ This contract is for getting information about exceptions in the process. ## APIs of contract ```csharp -record struct ManagedExceptionData( +record struct ExceptionData( TargetPointer Message, TargetPointer InnerException, TargetPointer StackTrace, @@ -17,40 +17,40 @@ record struct ManagedExceptionData( ``` ``` csharp -TargetPointer GetExceptionInfo(TargetPointer exception, out TargetPointer nextNestedException); -ManagedExceptionData GetManagedExceptionData(TargetPointer managedException) +TargetPointer GetNestedExceptionInfo(TargetPointer exceptionInfoAddr, out TargetPointer nextNestedExceptionInfo); +ExceptionData GetExceptionData(TargetPointer exceptionAddr) ``` ## Version 1 Data descriptors used: - `ExceptionInfo` -- `ExceptionObject` +- `Exception` ``` csharp -TargetPointer GetExceptionInfo(TargetPointer exception, out TargetPointer nextNestedException) +TargetPointer GetNestedExceptionInfo(TargetPointer exceptionInfoAddr, out TargetPointer nextNestedExceptionInfo) { - if (exception == TargetPointer.Null) + if (exceptionInfo == TargetPointer.Null) throw new InvalidArgumentException(); - nextNestedException = target.ReadPointer(exception + /* ExceptionInfo::PreviousNestedInfo offset*/); - TargetPointer thrownObjHandle = target.ReadPointer(exception + /* ExceptionInfo::ThrownObject offset */); + nextNestedException = target.ReadPointer(exceptionInfo + /* ExceptionInfo::PreviousNestedInfo offset*/); + TargetPointer thrownObjHandle = target.ReadPointer(exceptionInfo + /* ExceptionInfo::ThrownObject offset */); return = thrownObjHandle != TargetPointer.Null ? target.ReadPointer(thrownObjHandle) : TargetPointer.Null; } -ManagedExceptionData GetManagedExceptionData(TargetPointer managedException) +ExceptionData GetExceptionData(TargetPointer exceptionAddr) { - return new ManagedExceptionData( - target.ReadPointer(objectAddress + /* Exception::Message offset */), - target.ReadPointer(objectAddress + /* Exception::InnerException offset */), - target.ReadPointer(objectAddress + /* Exception::StackTrace offset */), - target.ReadPointer(objectAddress + /* Exception::WatsonBuckets offset */), - target.ReadPointer(objectAddress + /* Exception::StackTraceString offset */), - target.ReadPointer(objectAddress + /* Exception::RemoteStackTraceString offset */), - target.Read(objectAddress + /* Exception::HResult offset */), - target.Read(objectAddress + /* Exception::XCode offset */), + return new ExceptionData( + target.ReadPointer(exceptionAddr + /* Exception::Message offset */), + target.ReadPointer(exceptionAddr + /* Exception::InnerException offset */), + target.ReadPointer(exceptionAddr + /* Exception::StackTrace offset */), + target.ReadPointer(exceptionAddr + /* Exception::WatsonBuckets offset */), + target.ReadPointer(exceptionAddr + /* Exception::StackTraceString offset */), + target.ReadPointer(exceptionAddr + /* Exception::RemoteStackTraceString offset */), + target.Read(exceptionAddr + /* Exception::HResult offset */), + target.Read(exceptionAddr + /* Exception::XCode offset */), ); } ``` diff --git a/src/native/managed/cdacreader/src/Contracts/Exception.cs b/src/native/managed/cdacreader/src/Contracts/Exception.cs index 9ae92b433cb9e..2ad3d10faeb65 100644 --- a/src/native/managed/cdacreader/src/Contracts/Exception.cs +++ b/src/native/managed/cdacreader/src/Contracts/Exception.cs @@ -5,7 +5,7 @@ namespace Microsoft.Diagnostics.DataContractReader.Contracts; -internal record struct ManagedExceptionData( +internal record struct ExceptionData( TargetPointer Message, TargetPointer InnerException, TargetPointer StackTrace, @@ -27,8 +27,8 @@ static IContract IContract.Create(Target target, int version) }; } - public virtual TargetPointer GetExceptionInfo(TargetPointer exception, out TargetPointer nextNestedException) => throw new NotImplementedException(); - public virtual ManagedExceptionData GetManagedExceptionData(TargetPointer managedException) => throw new NotImplementedException(); + public virtual TargetPointer GetNestedExceptionInfo(TargetPointer exception, out TargetPointer nextNestedException) => throw new NotImplementedException(); + public virtual ExceptionData GetExceptionData(TargetPointer managedException) => throw new NotImplementedException(); } internal readonly struct Exception : IException diff --git a/src/native/managed/cdacreader/src/Contracts/Exception_1.cs b/src/native/managed/cdacreader/src/Contracts/Exception_1.cs index 543e2c5dabc36..faadb768cc8d8 100644 --- a/src/native/managed/cdacreader/src/Contracts/Exception_1.cs +++ b/src/native/managed/cdacreader/src/Contracts/Exception_1.cs @@ -14,24 +14,24 @@ internal Exception_1(Target target) _target = target; } - TargetPointer IException.GetExceptionInfo(TargetPointer exception, out TargetPointer nextNestedException) + TargetPointer IException.GetNestedExceptionInfo(TargetPointer exceptionInfoAddr, out TargetPointer nextNestedExceptionInfo) { - Data.ExceptionInfo exceptionInfo = _target.ProcessedData.GetOrAdd(exception); - nextNestedException = exceptionInfo.PreviousNestedInfo; + Data.ExceptionInfo exceptionInfo = _target.ProcessedData.GetOrAdd(exceptionInfoAddr); + nextNestedExceptionInfo = exceptionInfo.PreviousNestedInfo; return exceptionInfo.ThrownObject.Object; } - ManagedExceptionData IException.GetManagedExceptionData(TargetPointer managedException) + ExceptionData IException.GetExceptionData(TargetPointer exceptionAddr) { - Data.Exception exceptionObject = _target.ProcessedData.GetOrAdd(managedException); - return new ManagedExceptionData( - exceptionObject.Message, - exceptionObject.InnerException, - exceptionObject.StackTrace, - exceptionObject.WatsonBuckets, - exceptionObject.StackTraceString, - exceptionObject.RemoteStackTraceString, - exceptionObject.HResult, - exceptionObject.XCode); + Data.Exception exception = _target.ProcessedData.GetOrAdd(exceptionAddr); + return new ExceptionData( + exception.Message, + exception.InnerException, + exception.StackTrace, + exception.WatsonBuckets, + exception.StackTraceString, + exception.RemoteStackTraceString, + exception.HResult, + exception.XCode); } } diff --git a/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs b/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs index 6f62c95788b01..54057153933c6 100644 --- a/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs +++ b/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs @@ -158,7 +158,7 @@ public unsafe int GetNestedExceptionData(ulong exception, ulong* exceptionObject try { Contracts.IException contract = _target.Contracts.Exception; - TargetPointer exceptionObjectLocal = contract.GetExceptionInfo(exception, out TargetPointer nextNestedExceptionLocal); + TargetPointer exceptionObjectLocal = contract.GetNestedExceptionInfo(exception, out TargetPointer nextNestedExceptionLocal); *exceptionObject = exceptionObjectLocal; *nextNestedException = nextNestedExceptionLocal; } @@ -178,7 +178,7 @@ public unsafe int GetObjectExceptionData(ulong objectAddress, DacpExceptionObjec try { Contracts.IException contract = _target.Contracts.Exception; - Contracts.ManagedExceptionData exceptionData = contract.GetManagedExceptionData(objectAddress); + Contracts.ExceptionData exceptionData = contract.GetExceptionData(objectAddress); data->Message = exceptionData.Message; data->InnerException = exceptionData.InnerException; data->StackTrace = exceptionData.StackTrace;