Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cDAC] Implement ISOSDacInterface::GetMethodDescPtrFromIp #110755

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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