Skip to content
Draft
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
5 changes: 5 additions & 0 deletions src/coreclr/debug/di/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,11 @@ CordbProcess::CreateDacDbiInterface()
m_hDacModule = ShimProcess::GetDacModule(m_cordb->GetDacModulePath());
}

if (m_pShim != NULL)
{
m_pShim->SetRuntimeBase(m_clrInstanceId);
}

//
// Get the access interface, passing our callback interfaces (data target, allocator and metadata lookup)
//
Expand Down
50 changes: 50 additions & 0 deletions src/coreclr/debug/di/shimdatatarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

#include "shimpriv.h"

extern "C" bool TryGetSymbol(
ICorDebugDataTarget* dataTarget,
uint64_t baseAddress,
const char* symbolName,
uint64_t* symbolAddress);

// Standard impl of IUnknown::QueryInterface
HRESULT STDMETHODCALLTYPE ShimDataTarget::QueryInterface(
Expand All @@ -38,6 +43,14 @@ HRESULT STDMETHODCALLTYPE ShimDataTarget::QueryInterface(
{
*pInterface = static_cast<ICorDebugDataTarget4 *>(this);
}
else if (InterfaceId == IID_ICLRContractLocator)
{
*pInterface = static_cast<ICLRContractLocator *>(this);
}
else if (InterfaceId == IID_ICLRRuntimeLocator)
{
*pInterface = static_cast<ICLRRuntimeLocator *>(this);
}
else
{
*pInterface = NULL;
Expand Down Expand Up @@ -89,3 +102,40 @@ void ShimDataTarget::HookContinueStatusChanged(FPContinueStatusChanged fpContinu
m_fpContinueStatusChanged = fpContinueStatusChanged;
m_pContinueStatusChangedUserData = pUserData;
}

void ShimDataTarget::SetRuntimeBase(CORDB_ADDRESS runtimeBase)
{
m_runtimeBase = runtimeBase;
}

HRESULT STDMETHODCALLTYPE ShimDataTarget::GetContractDescriptor(CLRDATA_ADDRESS * contractAddress)
{
if (contractAddress == NULL || m_runtimeBase == 0)
{
return E_INVALIDARG;
}
Comment on lines +111 to +116

uint64_t address = 0;
if (!TryGetSymbol(
static_cast<ICorDebugDataTarget *>(this),
m_runtimeBase,
"DotNetRuntimeContractDescriptor",
&address))
{
return E_FAIL;
}

*contractAddress = address;
return S_OK;
}

HRESULT STDMETHODCALLTYPE ShimDataTarget::GetRuntimeBase(CLRDATA_ADDRESS * baseAddress)
{
if (baseAddress == NULL || m_runtimeBase == 0)
{
return E_INVALIDARG;
}
Comment on lines +132 to +137

*baseAddress = m_runtimeBase;
return S_OK;
}
24 changes: 21 additions & 3 deletions src/coreclr/debug/di/shimdatatarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@
#ifndef SHIMDATATARGET_H_
#define SHIMDATATARGET_H_

#include <clrdata.h>

// Function to invoke for
typedef HRESULT (*FPContinueStatusChanged)(void * pUserData, DWORD dwThreadId, CORDB_CONTINUE_STATUS dwContinueStatus);


//---------------------------------------------------------------------------------------
// Data target for a live process. This is used by Shim.
//
class ShimDataTarget : public ICorDebugMutableDataTarget, ICorDebugDataTarget4
class ShimDataTarget : public ICorDebugMutableDataTarget, ICorDebugDataTarget4, ICLRContractLocator, ICLRRuntimeLocator
{
public:
ShimDataTarget() : m_runtimeBase(0) {}
virtual ~ShimDataTarget() {}

// Allow hooking an implementation for ContinueStatusChanged.
void HookContinueStatusChanged(FPContinueStatusChanged fpContinueStatusChanged, void * pUserData);

void SetRuntimeBase(CORDB_ADDRESS runtimeBase);

// Release any resources. Also called by destructor.
virtual void Dispose() = 0;

Expand Down Expand Up @@ -91,6 +94,20 @@ class ShimDataTarget : public ICorDebugMutableDataTarget, ICorDebugDataTarget4
virtual HRESULT STDMETHODCALLTYPE VirtualUnwind(
DWORD threadId, ULONG32 contextSize, PBYTE context) = 0;

//
// ICLRContractLocator.
//

virtual HRESULT STDMETHODCALLTYPE GetContractDescriptor(
CLRDATA_ADDRESS * contractAddress);

//
// ICLRRuntimeLocator.
//

virtual HRESULT STDMETHODCALLTYPE GetRuntimeBase(
CLRDATA_ADDRESS * baseAddress);

protected:
// Pid of the target process.
DWORD m_processId;
Expand All @@ -102,6 +119,8 @@ class ShimDataTarget : public ICorDebugMutableDataTarget, ICorDebugDataTarget4
FPContinueStatusChanged m_fpContinueStatusChanged;
void * m_pContinueStatusChangedUserData;

CORDB_ADDRESS m_runtimeBase;

// Reference count.
LONG m_ref;
};
Expand Down Expand Up @@ -129,4 +148,3 @@ HRESULT BuildPlatformSpecificDataTarget(MachineInfo machineInfo,
ShimDataTarget ** ppDataTarget);

#endif // SHIMDATATARGET_H_

3 changes: 2 additions & 1 deletion src/coreclr/debug/di/shimpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ class ShimProcess
// Get the data target to access the debuggee.
ICorDebugMutableDataTarget * GetDataTarget();

void SetRuntimeBase(CORDB_ADDRESS runtimeBase);

// Get the native event pipeline
INativeEventPipeline * GetNativePipeline();

Expand Down Expand Up @@ -1046,4 +1048,3 @@ class ShimFrameEnum : public ICorDebugFrameEnum


#endif // SHIMPRIV_H

6 changes: 6 additions & 0 deletions src/coreclr/debug/di/shimprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,12 @@ ICorDebugMutableDataTarget * ShimProcess::GetDataTarget()
return m_pLiveDataTarget;
};

void ShimProcess::SetRuntimeBase(CORDB_ADDRESS runtimeBase)
{
_ASSERTE(m_pLiveDataTarget != NULL);
m_pLiveDataTarget->SetRuntimeBase(runtimeBase);
}


// Trivial accessor to get the raw native event pipeline.
// In V3, ICorDebug no longer owns the event thread and it does not own the event pipeline either.
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ endif(CLR_CMAKE_HOST_UNIX)
set(COREDBI_LIBRARIES
debug-pal
cordbdi
dbgutil
utilcodestaticnohost
mdcompiler-dbi
mdruntime-dbi
Expand Down
15 changes: 14 additions & 1 deletion src/coreclr/inc/clrdata.idl
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,20 @@ interface ICLRRuntimeLocator : IUnknown
HRESULT GetRuntimeBase([out] CLRDATA_ADDRESS* baseAddress);
};

[
object,
local,
uuid(17d5b8c6-34a9-407f-af4f-a930201d4e02),
pointer_default(unique)
]
interface ICLRContractLocator : IUnknown
{
/*
Returns the address of the runtime's contract descriptor.
*/
HRESULT GetContractDescriptor([out] CLRDATA_ADDRESS* contractAddress);
}

/*
* Interface used by the data access services layer to locate metadata
* of assemblies in a target.
Expand Down Expand Up @@ -340,4 +354,3 @@ interface ICLRDataEnumMemoryRegions : IUnknown
[in] ULONG32 miniDumpFlags,
[in] CLRDataEnumMemoryFlags clrFlags);
}

4 changes: 3 additions & 1 deletion src/coreclr/pal/prebuilt/idl/clrdata_i.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ MIDL_DEFINE_GUID(IID, IID_ICLRDataTarget3,0xa5664f95,0x0af4,0x4a1b,0x96,0x0e,0x2
MIDL_DEFINE_GUID(IID, IID_ICLRRuntimeLocator,0xb760bf44,0x9377,0x4597,0x8b,0xe7,0x58,0x08,0x3b,0xdc,0x51,0x46);


MIDL_DEFINE_GUID(IID, IID_ICLRContractLocator,0x17d5b8c6,0x34a9,0x407f,0xaf,0x4f,0xa9,0x30,0x20,0x1d,0x4e,0x02);


MIDL_DEFINE_GUID(IID, IID_ICLRMetadataLocator,0xaa8fa804,0xbc05,0x4642,0xb2,0xc5,0xc3,0x53,0xed,0x22,0xfc,0x63);


Expand All @@ -99,4 +102,3 @@ MIDL_DEFINE_GUID(IID, IID_ICLRDataEnumMemoryRegions,0x471c35b4,0x7c2f,0x4ef0,0xa
#endif



94 changes: 91 additions & 3 deletions src/coreclr/pal/prebuilt/inc/clrdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ typedef interface ICLRRuntimeLocator ICLRRuntimeLocator;
#endif /* __ICLRRuntimeLocator_FWD_DEFINED__ */


#ifndef __ICLRContractLocator_FWD_DEFINED__
#define __ICLRContractLocator_FWD_DEFINED__
typedef interface ICLRContractLocator ICLRContractLocator;

#endif /* __ICLRContractLocator_FWD_DEFINED__ */


#ifndef __ICLRMetadataLocator_FWD_DEFINED__
#define __ICLRMetadataLocator_FWD_DEFINED__
typedef interface ICLRMetadataLocator ICLRMetadataLocator;
Expand Down Expand Up @@ -146,7 +153,7 @@ extern RPC_IF_HANDLE __MIDL_itf_clrdata_0000_0000_v0_0_s_ifspec;
#define __ICLRDataTarget_INTERFACE_DEFINED__

/* interface ICLRDataTarget */
/* [unique][uuid][local][object] */
/* [unique][uuid][local][object] */


EXTERN_C const IID IID_ICLRDataTarget;
Expand Down Expand Up @@ -922,6 +929,89 @@ EXTERN_C const IID IID_ICLRRuntimeLocator;
#endif /* __ICLRRuntimeLocator_INTERFACE_DEFINED__ */


#ifndef __ICLRContractLocator_INTERFACE_DEFINED__
#define __ICLRContractLocator_INTERFACE_DEFINED__

/* interface ICLRContractLocator */
/* [unique][uuid][local][object] */


EXTERN_C const IID IID_ICLRContractLocator;

#if defined(__cplusplus) && !defined(CINTERFACE)

MIDL_INTERFACE("17d5b8c6-34a9-407f-af4f-a930201d4e02")
ICLRContractLocator : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE GetContractDescriptor(
/* [out] */ CLRDATA_ADDRESS *contractAddress) = 0;

};


#else /* C style interface */

typedef struct ICLRContractLocatorVtbl
{
BEGIN_INTERFACE

DECLSPEC_XFGVIRT(IUnknown, QueryInterface)
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
ICLRContractLocator * This,
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);

DECLSPEC_XFGVIRT(IUnknown, AddRef)
ULONG ( STDMETHODCALLTYPE *AddRef )(
ICLRContractLocator * This);

DECLSPEC_XFGVIRT(IUnknown, Release)
ULONG ( STDMETHODCALLTYPE *Release )(
ICLRContractLocator * This);

DECLSPEC_XFGVIRT(ICLRContractLocator, GetContractDescriptor)
HRESULT ( STDMETHODCALLTYPE *GetContractDescriptor )(
ICLRContractLocator * This,
/* [out] */ CLRDATA_ADDRESS *contractAddress);

END_INTERFACE
} ICLRContractLocatorVtbl;

interface ICLRContractLocator
{
CONST_VTBL struct ICLRContractLocatorVtbl *lpVtbl;
};


#ifdef COBJMACROS


#define ICLRContractLocator_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )

#define ICLRContractLocator_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )

#define ICLRContractLocator_Release(This) \
( (This)->lpVtbl -> Release(This) )


#define ICLRContractLocator_GetContractDescriptor(This,contractAddress) \
( (This)->lpVtbl -> GetContractDescriptor(This,contractAddress) )

#endif /* COBJMACROS */


#endif /* C style interface */




#endif /* __ICLRContractLocator_INTERFACE_DEFINED__ */


#ifndef __ICLRMetadataLocator_INTERFACE_DEFINED__
#define __ICLRMetadataLocator_INTERFACE_DEFINED__

Expand Down Expand Up @@ -1405,5 +1495,3 @@ EXTERN_C const IID IID_ICLRDataEnumMemoryRegions;
#endif

#endif


Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ public unsafe partial interface ICorDebugDataTarget
int GetThreadContext(uint threadId, uint contextFlags, uint contextSize, byte* pContext);
}

[GeneratedComInterface]
[Guid("A1B8A756-3CB6-4CCB-979F-3DF999673A59")]
public unsafe partial interface ICorDebugMutableDataTarget : ICorDebugDataTarget
{
[PreserveSig]
int WriteVirtual(ulong address, byte* pBuffer, uint bytesRequested);

[PreserveSig]
int SetThreadContext(uint threadId, uint contextSize, byte* pContext);

[PreserveSig]
int ContinueStatusChanged(uint threadId, uint continueStatus);
}

[StructLayout(LayoutKind.Sequential)]
public struct COR_TYPEID
{
Expand Down
Loading
Loading