Skip to content
Open
Show file tree
Hide file tree
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
36 changes: 28 additions & 8 deletions src/coreclr/debug/daccess/cdac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,38 @@ CDAC::~CDAC()
}
}

void CDAC::CreateSosInterface(IUnknown** sos)
HRESULT CDAC::CreateSosInterface(IUnknown** sos)
{
if (sos == nullptr)
{
return E_INVALIDARG;
}

*sos = nullptr;

decltype(&cdac_reader_create_sos_interface) createSosInterface = reinterpret_cast<decltype(&cdac_reader_create_sos_interface)>(::GetProcAddress(m_module, "cdac_reader_create_sos_interface"));
_ASSERTE(createSosInterface != nullptr);
int ret = createSosInterface(m_cdac_handle, m_legacyImpl, sos);
_ASSERTE(ret == 0);
if (createSosInterface == nullptr)
{
Comment thread
noahfalk marked this conversation as resolved.
return E_FAIL;
}
Comment thread
noahfalk marked this conversation as resolved.

return createSosInterface(m_cdac_handle, m_legacyImpl, sos);
Comment thread
noahfalk marked this conversation as resolved.
}

void CDAC::CreateDacDbiInterface(IUnknown** dbi)
HRESULT CDAC::CreateDacDbiInterface(IUnknown** dbi)
{
if (dbi == nullptr)
{
return E_INVALIDARG;
}

*dbi = nullptr;

decltype(&cdac_reader_create_dacdbi_interface) createDacDbiInterface = reinterpret_cast<decltype(&cdac_reader_create_dacdbi_interface)>(::GetProcAddress(m_module, "cdac_reader_create_dacdbi_interface"));
_ASSERTE(createDacDbiInterface != nullptr);
int ret = createDacDbiInterface(m_cdac_handle, m_legacyImpl, dbi);
_ASSERTE(ret == 0);
if (createDacDbiInterface == nullptr)
{
return E_FAIL;
}

return createDacDbiInterface(m_cdac_handle, m_legacyImpl, dbi);
}
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/cdac.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class CDAC final
return m_module != NULL && m_cdac_handle != 0;
}

void CreateSosInterface(IUnknown** sos);
void CreateDacDbiInterface(IUnknown** dbi);
HRESULT CreateSosInterface(IUnknown** sos);
HRESULT CreateDacDbiInterface(IUnknown** dbi);

private:
CDAC(HMODULE module, intptr_t handle, ICorDebugDataTarget* target, IUnknown* legacyImpl);
Expand Down
14 changes: 8 additions & 6 deletions src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6558,7 +6558,9 @@ CLRDataCreateInstance(REFIID iid,
if (enable.IsSet())
{
DWORD val;
if (enable.TryAsInteger(10, val) && val == 1)
// cDAC does not yet support the memory enumeration used to create debugger dumps.
if (enable.TryAsInteger(10, val) && val == 1 &&
!(IsEqualIID(iid, __uuidof(ICLRDataEnumMemoryRegions))))
{
// TODO: [cdac] TryGetSymbol is only implemented for Linux, OSX, and Windows.
uint64_t contractDescriptorAddr = 0;
Expand All @@ -6572,11 +6574,11 @@ CLRDataCreateInstance(REFIID iid,
if (cdac.IsValid())
{
// Get SOS interfaces from the cDAC if available.
cdac.CreateSosInterface(&cdacInterface);
_ASSERTE(cdacInterface != nullptr);

// Lifetime is now managed by cDAC implementation of SOS interfaces
pClrDataAccess->Release();
if (cdac.CreateSosInterface(&cdacInterface) == S_OK && cdacInterface != nullptr)
{
// Lifetime is now managed by cDAC implementation of SOS interfaces.
pClrDataAccess->Release();
}
}

// Release the AddRef from the QI.
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,7 @@ DacDbiInterfaceInstance(
if (cdac.IsValid())
{
ReleaseHolder<IUnknown> cdacInterface;
cdac.CreateDacDbiInterface(&cdacInterface);
if (cdacInterface != nullptr)
if (cdac.CreateDacDbiInterface(&cdacInterface) == S_OK && cdacInterface != nullptr)
{
IDacDbiInterface* pCDacDbi = nullptr;
HRESULT hr = cdacInterface->QueryInterface(__uuidof(IDacDbiInterface), (void**)&pCDacDbi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int IXCLRDataExceptionState.GetManagedObject(DacComNullableByRef<IXCLRDataValue>
int hr = HResults.S_OK, hrLocal = HResults.S_OK;
IXCLRDataValue? legacyValue = null;

if (_legacyImpl is not null && LegacyFallbackHelper.CanFallback())
if (_legacyImpl is not null)
{
DacComNullableByRef<IXCLRDataValue> legacyValueOut = new(value.IsNullRef);
hrLocal = _legacyImpl.GetManagedObject(legacyValueOut);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ int IXCLRDataFrame.GetCodeName(
{
using Lock.Scope scope = _apiLock.EnterScope();

return LegacyFallbackHelper.CanFallback() && _legacyImpl is not null ? _legacyImpl.GetCodeName(flags, bufLen, nameLen, nameBuf) : HResults.E_NOTIMPL;
return HResults.E_NOTIMPL;
}

int IXCLRDataFrame.GetMethodInstance(DacComNullableByRef<IXCLRDataMethodInstance> method)
Expand Down Expand Up @@ -425,7 +425,7 @@ int IXCLRDataFrame.Request(
{
using Lock.Scope scope = _apiLock.EnterScope();

return LegacyFallbackHelper.CanFallback() && _legacyImpl is not null ? _legacyImpl.Request(reqCode, inBufferSize, inBuffer, outBufferSize, outBuffer) : HResults.E_NOTIMPL;
return HResults.E_NOTIMPL;
}

int IXCLRDataFrame.GetNumTypeArguments(uint* numTypeArgs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ int IXCLRDataMethodDefinition.StartEnumInstances(IXCLRDataAppDomain? appDomain,
int hr = HResults.S_FALSE;
*handle = 0;

// Start the legacy enumeration to keep it in sync with the cDAC enumeration.
// EnumInstance passes the legacy method instance to ClrDataMethodInstance,
// which delegates some operations to it.
// Start the legacy enumeration to keep it in sync for validation.
ulong legacyHandle = default;
int hrLocal = default;
if (_legacyImpl is not null)
Expand Down Expand Up @@ -226,8 +224,7 @@ int IXCLRDataMethodDefinition.EnumInstance(ulong* handle, DacComNullableByRef<IX
if (gcHandle.Target is not SOSDacImpl.EnumMethodInstances emi)
return HResults.E_INVALIDARG;

// Advance the legacy enumeration to keep it in sync with the cDAC enumeration.
// The legacy method instance is passed to ClrDataMethodInstance for delegation.
// Advance the legacy enumeration to keep it in sync for validation.
IXCLRDataMethodInstance? legacyMethod = null;
int hrLocal = default;
if (_legacyImpl is not null)
Expand All @@ -253,16 +250,7 @@ int IXCLRDataMethodDefinition.EnumInstance(ulong* handle, DacComNullableByRef<IX
}
catch (System.Exception ex)
{
// Fall back to the legacy DAC result when available, otherwise propagate the error.
if (_legacyImpl is not null)
{
hr = hrLocal;
instance.Interface = legacyMethod;
}
else
{
hr = ex.HResult;
}
hr = ex.HResult;
}

#if DEBUG
Expand Down Expand Up @@ -295,8 +283,9 @@ int IXCLRDataMethodDefinition.EndEnumInstances(ulong handle)
if (_legacyImpl is not null && emi.LegacyHandle != 0)
{
int hrLocal = _legacyImpl.EndEnumInstances(emi.LegacyHandle);
if (hrLocal < 0)
hr = hrLocal;
#if DEBUG
Debug.ValidateHResult(hr, hrLocal);
#endif
}
}
catch (System.Exception ex)
Expand Down Expand Up @@ -397,9 +386,8 @@ int IXCLRDataMethodDefinition.GetTokenAndScope(uint* token, DacComNullableByRef<
{
DacComNullableByRef<IXCLRDataModule> legacyModOut = new(isNullRef: false);
int hrLegacy = _legacyImpl.GetTokenAndScope(null, legacyModOut);
if (hrLegacy < 0)
return hrLegacy;
legacyMod = legacyModOut.Interface;
if (hrLegacy >= 0)
legacyMod = legacyModOut.Interface;
}

mod.Interface = new ClrDataModule(_module, _target, legacyMod, _apiLock);
Expand Down Expand Up @@ -709,7 +697,7 @@ int IXCLRDataMethodDefinition.GetRepresentativeEntryAddress(ClrDataAddress* addr
}

#if DEBUG
if (LegacyFallbackHelper.CanFallback() && _legacyImpl is not null)
if (_legacyImpl is not null)
{
ClrDataAddress addrLocal = 0;
int hrLocal = _legacyImpl.GetRepresentativeEntryAddress(addr is null ? null : &addrLocal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int IXCLRDataMethodInstance.GetDefinition(DacComNullableByRef<IXCLRDataMethodDef

try
{
if (LegacyFallbackHelper.CanFallback() && _legacyImpl is not null)
if (_legacyImpl is not null)
{
DacComNullableByRef<IXCLRDataMethodDefinition> legacyMethodDefinitionOut = new(isNullRef: methodDefinition.IsNullRef);
hrLocal = _legacyImpl.GetDefinition(legacyMethodDefinitionOut);
Expand Down Expand Up @@ -110,9 +110,8 @@ int IXCLRDataMethodInstance.GetTokenAndScope(uint* token, DacComNullableByRef<IX
{
DacComNullableByRef<IXCLRDataModule> legacyModOut = new(isNullRef: false);
int hrLegacy = _legacyImpl.GetTokenAndScope(token, legacyModOut);
if (hrLegacy < 0)
return hrLegacy;
legacyMod = legacyModOut.Interface;
if (hrLegacy >= 0)
legacyMod = legacyModOut.Interface;
}

TargetPointer mtAddr = rts.GetMethodTable(_methodDesc);
Expand Down
Loading
Loading