Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,62 @@ int ISOSDacInterface.GetMethodDescName(ulong methodDesc, uint count, char* name,
int ISOSDacInterface.GetMethodDescPtrFromFrame(ulong frameAddr, ulong* ppMD)
=> _legacyImpl is not null ? _legacyImpl.GetMethodDescPtrFromFrame(frameAddr, ppMD) : HResults.E_NOTIMPL;
int ISOSDacInterface.GetMethodDescPtrFromIP(ulong ip, ulong* ppMD)
=> _legacyImpl is not null ? _legacyImpl.GetMethodDescPtrFromIP(ip, ppMD) : HResults.E_NOTIMPL;
{
if (ip == 0 || ppMD == null)
return HResults.E_INVALIDARG;

int hr = HResults.E_NOTIMPL;

try
{
IExecutionManager executionManager = _target.Contracts.ExecutionManager;
IRuntimeTypeSystem rts = _target.Contracts.RuntimeTypeSystem;

CodeBlockHandle? handle = executionManager.GetCodeBlockHandle(new TargetCodePointer(ip));
if (handle is CodeBlockHandle codeHandle)
{
TargetPointer methodDescAddr = executionManager.GetMethodDesc(codeHandle);

try
{
// Runs validation of MethodDesc
// if validation fails, should return E_INVALIDARG
rts.GetMethodDescHandle(methodDescAddr);

*ppMD = methodDescAddr.Value;
hr = HResults.S_OK;
}
catch (System.Exception)
{
hr = HResults.E_INVALIDARG;
}
}
else
{
hr = HResults.E_FAIL;
}
}
catch (System.Exception ex)
{
hr = ex.HResult;
}

#if DEBUG
if (_legacyImpl is not null)
{
ulong ppMDLocal;
int hrLocal = _legacyImpl.GetMethodDescPtrFromIP(ip, &ppMDLocal);

Debug.Assert(hrLocal == hr);
if (hr == HResults.S_OK)
{
Debug.Assert(*ppMD == ppMDLocal);
}
}
#endif
return hr;
}

int ISOSDacInterface.GetMethodDescTransparencyData(ulong methodDesc, void* data)
=> _legacyImpl is not null ? _legacyImpl.GetMethodDescTransparencyData(methodDesc, data) : HResults.E_NOTIMPL;
int ISOSDacInterface.GetMethodTableData(ulong mt, DacpMethodTableData* data)
Expand Down
Loading