Skip to content
Closed
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
46 changes: 46 additions & 0 deletions src/coreclr/debug/di/shimdatatarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ HRESULT STDMETHODCALLTYPE ShimDataTarget::QueryInterface(
{
*pInterface = static_cast<ICorDebugDataTarget4 *>(this);
}
else if (InterfaceId == IID_ICorDebugDataTarget5)
{
*pInterface = static_cast<ICorDebugDataTarget5 *>(this);
}
else
{
*pInterface = NULL;
Expand Down Expand Up @@ -89,3 +93,45 @@ void ShimDataTarget::HookContinueStatusChanged(FPContinueStatusChanged fpContinu
m_fpContinueStatusChanged = fpContinueStatusChanged;
m_pContinueStatusChangedUserData = pUserData;
}

//---------------------------------------------------------------------------------------
// ICorDebugDataTarget5::GetTargetInfo
//
// Reports the processor architecture and operating system of the target process.
//
HRESULT STDMETHODCALLTYPE ShimDataTarget::GetTargetInfo(CorDebugTargetInfo * pTargetInfo)
{
if (pTargetInfo == NULL)
{
return E_INVALIDARG;
}

// host and target are the same for live debugging as of now
#if defined(HOST_X86)
pTargetInfo->arch = CORDB_ARCH_X86;
#elif defined(HOST_AMD64)
pTargetInfo->arch = CORDB_ARCH_AMD64;
#elif defined(HOST_ARM)
pTargetInfo->arch = CORDB_ARCH_ARM;
#elif defined(HOST_ARM64)
pTargetInfo->arch = CORDB_ARCH_ARM64;
#elif defined(HOST_LOONGARCH64)
pTargetInfo->arch = CORDB_ARCH_LOONGARCH64;
#elif defined(HOST_RISCV64)
pTargetInfo->arch = CORDB_ARCH_RISCV64;
#else
pTargetInfo->arch = CORDB_ARCH_UNKNOWN;
#endif

#if defined(HOST_APPLE)
pTargetInfo->os = CORDB_OS_MACOS;
#elif defined(HOST_UNIX)
pTargetInfo->os = CORDB_OS_LINUX;
#elif defined(HOST_WINDOWS)
pTargetInfo->os = CORDB_OS_WINDOWS;
#else
pTargetInfo->os = CORDB_OS_UNKNOWN;
#endif
Comment thread
rcj1 marked this conversation as resolved.

return S_OK;
}
10 changes: 9 additions & 1 deletion src/coreclr/debug/di/shimdatatarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef HRESULT (*FPContinueStatusChanged)(void * pUserData, DWORD dwThreadId, C
//---------------------------------------------------------------------------------------
// Data target for a live process. This is used by Shim.
//
class ShimDataTarget : public ICorDebugMutableDataTarget, ICorDebugDataTarget4
class ShimDataTarget : public ICorDebugMutableDataTarget, ICorDebugDataTarget4, ICorDebugDataTarget5
{
public:
virtual ~ShimDataTarget() {}
Expand Down Expand Up @@ -91,6 +91,14 @@ class ShimDataTarget : public ICorDebugMutableDataTarget, ICorDebugDataTarget4
virtual HRESULT STDMETHODCALLTYPE VirtualUnwind(
DWORD threadId, ULONG32 contextSize, PBYTE context) = 0;

//
// ICorDebugDataTarget5
//

// Get the processor architecture and operating system of the target.
virtual HRESULT STDMETHODCALLTYPE GetTargetInfo(
CorDebugTargetInfo * pTargetInfo);

protected:
// Pid of the target process.
DWORD m_processId;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/dlls/mscordac/mscordac_unixexports.src
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ IID_ISequentialStream
IID_IStream
IID_ICLRDataTarget
IID_ICorDebugDataTarget4
IID_ICorDebugDataTarget5
IID_ICLRDataEnumMemoryRegionsCallback
nativeStringResourceTable_mscorrc

Expand Down
54 changes: 54 additions & 0 deletions src/coreclr/inc/cordebug.idl
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,60 @@ interface ICorDebugDataTarget4 : IUnknown
[in, out, size_is(contextSize)] BYTE *context);
};

/*
* Describes the processor architecture of the target process.
*/
typedef enum CorDebugTargetArchitecture
{
CORDB_ARCH_UNKNOWN,
CORDB_ARCH_X86,
CORDB_ARCH_AMD64,
CORDB_ARCH_ARM,
CORDB_ARCH_ARM64,
CORDB_ARCH_LOONGARCH64,
CORDB_ARCH_RISCV64,
CORDB_ARCH_WASM
} CorDebugTargetArchitecture;

/*
* Describes the operating system of the target process.
*/
typedef enum CorDebugTargetOperatingSystem
{
CORDB_OS_UNKNOWN,
CORDB_OS_WINDOWS,
CORDB_OS_MACOS,
CORDB_OS_LINUX
} CorDebugTargetOperatingSystem;

/*
* Describes the processor architecture and operating system of the target process.
*/
typedef struct CorDebugTargetInfo
{
CorDebugTargetArchitecture arch;
CorDebugTargetOperatingSystem os;
} CorDebugTargetInfo;

/*
* Data target that can report the processor architecture and operating system
* of the target process.
*/
[
object,
uuid(A5634045-7D7E-4497-A608-44D6BFE4FC28),
local,
pointer_default(unique)
]
interface ICorDebugDataTarget5 : IUnknown
{
/*
* GetTargetInfo returns the processor architecture and operating system
* of the target process.
*/
HRESULT GetTargetInfo([out] CorDebugTargetInfo * pTargetInfo);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, implementations of the API do not distinguish between Mac and Linux. If we ever needed to distinguish the two, we would not be able to distinguish say a Mac with an old implementation that returns POSIX_XXX, from a Linux with either an old or a new implementation. I also like the (arch, OS) API as opposed to one which lists all the possible combinations - especially when we often care about only one element at a time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm skeptical we need to add this new public surface area right now, especially considering this is implemented for in repo use only. What APIs need this? Do we need to distinguish between MacOS and Linux today?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see us distinguishing Mac from Linux anywhere at the moment, but we really should be able to distinguish them, and we really should not rely on this surface where we have to do X different checks just to check if we are ARM64, for example. The idea is that @hoyosjs would have the rest of the data targets implement this API as well, and that if needed we can fall back to the old API.

};
Comment thread
rcj1 marked this conversation as resolved.

/*
* Mutable extension to the data target. This version of ICorDebugDataTarget
* can be implemented by targets that wish to support modification of the target
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/pal/prebuilt/idl/cordebug_i.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ MIDL_DEFINE_GUID(IID, IID_ICorDebugDataTarget3,0xD05E60C3,0x848C,0x4E7D,0x89,0x4
MIDL_DEFINE_GUID(IID, IID_ICorDebugDataTarget4,0xE799DC06,0xE099,0x4713,0xBD,0xD9,0x90,0x6D,0x3C,0xC0,0x2C,0xF2);


MIDL_DEFINE_GUID(IID, IID_ICorDebugDataTarget5,0xA5634045,0x7D7E,0x4497,0xA6,0x08,0x44,0xD6,0xBF,0xE4,0xFC,0x28);


MIDL_DEFINE_GUID(IID, IID_ICorDebugMutableDataTarget,0xA1B8A756,0x3CB6,0x4CCB,0x97,0x9F,0x3D,0xF9,0x99,0x67,0x3A,0x59);


Expand Down
117 changes: 117 additions & 0 deletions src/coreclr/pal/prebuilt/inc/cordebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -3124,6 +3124,123 @@ EXTERN_C const IID IID_ICorDebugDataTarget4;
#endif /* __ICorDebugDataTarget4_INTERFACE_DEFINED__ */


/* interface __MIDL_itf_cordebug_ICorDebugDataTarget5 */
/* [local] */

typedef
enum CorDebugTargetArchitecture
{
CORDB_ARCH_UNKNOWN = 0,
CORDB_ARCH_X86 = ( CORDB_ARCH_UNKNOWN + 1 ) ,
CORDB_ARCH_AMD64 = ( CORDB_ARCH_X86 + 1 ) ,
CORDB_ARCH_ARM = ( CORDB_ARCH_AMD64 + 1 ) ,
CORDB_ARCH_ARM64 = ( CORDB_ARCH_ARM + 1 ) ,
CORDB_ARCH_LOONGARCH64 = ( CORDB_ARCH_ARM64 + 1 ) ,
CORDB_ARCH_RISCV64 = ( CORDB_ARCH_LOONGARCH64 + 1 ) ,
CORDB_ARCH_WASM = ( CORDB_ARCH_RISCV64 + 1 )
} CorDebugTargetArchitecture;

typedef
enum CorDebugTargetOperatingSystem
{
CORDB_OS_UNKNOWN = 0,
CORDB_OS_WINDOWS = ( CORDB_OS_UNKNOWN + 1 ) ,
CORDB_OS_MACOS = ( CORDB_OS_WINDOWS + 1 ) ,
CORDB_OS_LINUX = ( CORDB_OS_MACOS + 1 )
} CorDebugTargetOperatingSystem;

typedef struct CorDebugTargetInfo
{
CorDebugTargetArchitecture arch;
CorDebugTargetOperatingSystem os;
} CorDebugTargetInfo;



#ifndef __ICorDebugDataTarget5_INTERFACE_DEFINED__
#define __ICorDebugDataTarget5_INTERFACE_DEFINED__

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


EXTERN_C const IID IID_ICorDebugDataTarget5;

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

MIDL_INTERFACE("A5634045-7D7E-4497-A608-44D6BFE4FC28")
ICorDebugDataTarget5 : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE GetTargetInfo(
/* [out] */ CorDebugTargetInfo *pTargetInfo) = 0;

};


#else /* C style interface */

typedef struct ICorDebugDataTarget5Vtbl
{
BEGIN_INTERFACE

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

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

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

DECLSPEC_XFGVIRT(ICorDebugDataTarget5, GetTargetInfo)
HRESULT ( STDMETHODCALLTYPE *GetTargetInfo )(
ICorDebugDataTarget5 * This,
/* [out] */ CorDebugTargetInfo *pTargetInfo);

END_INTERFACE
} ICorDebugDataTarget5Vtbl;

interface ICorDebugDataTarget5
{
CONST_VTBL struct ICorDebugDataTarget5Vtbl *lpVtbl;
};



#ifdef COBJMACROS


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

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

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


#define ICorDebugDataTarget5_GetTargetInfo(This,pTargetInfo) \
( (This)->lpVtbl -> GetTargetInfo(This,pTargetInfo) )

#endif /* COBJMACROS */


#endif /* C style interface */




#endif /* __ICorDebugDataTarget5_INTERFACE_DEFINED__ */


#ifndef __ICorDebugMutableDataTarget_INTERFACE_DEFINED__
#define __ICorDebugMutableDataTarget_INTERFACE_DEFINED__

Expand Down