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

Support debug connecting to a remote port #3813

Merged
merged 7 commits into from
Apr 12, 2023
Merged
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
43 changes: 43 additions & 0 deletions src/dbgshim/dbgshim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ typedef HRESULT (STDAPICALLTYPE *FPCoreCLRCreateCordbObject3)(
HMODULE hmodTargetCLR,
IUnknown **ppCordb);

typedef HRESULT (STDAPICALLTYPE *FPCreateRemoteCordbObject)(
DWORD port,
LPCSTR assemblyBasePath,
IUnknown **ppCordb);

HRESULT CreateCoreDbg(
HMODULE hCLRModule,
DWORD processId,
Expand Down Expand Up @@ -2151,3 +2156,41 @@ CLRCreateInstance(

return pDebuggingImpl->QueryInterface(riid, ppInterface);
}

HRESULT CreateCoreDbgRemotePort(HMODULE hDBIModule, DWORD portId, LPCSTR assemblyBasePath, IUnknown **ppCordb)
{
HRESULT hr = S_OK;

FPCreateRemoteCordbObject fpCreate =
(FPCreateRemoteCordbObject)GetProcAddress(hDBIModule, "CreateRemoteCordbObject");
if (fpCreate == NULL)
{
return CORDBG_E_INCOMPATIBLE_PROTOCOL;
}

return fpCreate(portId, assemblyBasePath, ppCordb);

return hr;
}

DLLEXPORT
HRESULT
RegisterForRuntimeStartupRemotePort(
_In_ DWORD dwRemotePortId,
_In_ LPCSTR mscordbiPath,
_In_ LPCSTR assemblyBasePath,
_Out_ IUnknown ** ppCordb)
{
HRESULT hr = S_OK;
HMODULE hMod = NULL;

hMod = LoadLibraryA(mscordbiPath);
if (hMod == NULL)
{
hr = CORDBG_E_DEBUG_COMPONENT_MISSING;
return hr;
}

hr = CreateCoreDbgRemotePort(hMod, dwRemotePortId, assemblyBasePath, ppCordb);
return S_OK;
}
7 changes: 7 additions & 0 deletions src/dbgshim/dbgshim.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,10 @@ CreateDebuggingInterfaceFromVersion3(
_In_ LPCWSTR szApplicationGroupId,
_In_ ICLRDebuggingLibraryProvider3* pLibraryProvider,
_Out_ IUnknown ** ppCordb);

EXTERN_C HRESULT
RegisterForRuntimeStartupRemotePort(
_In_ DWORD dwRemotePortId,
_In_ LPCSTR mscordbiPath,
_In_ LPCSTR assemblyBasePath,
_Out_ IUnknown ** ppCordb);
1 change: 1 addition & 0 deletions src/dbgshim/dbgshim.ntdef
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ EXPORTS
CreateDebuggingInterfaceFromVersion2
CreateDebuggingInterfaceFromVersion3
CLRCreateInstance
RegisterForRuntimeStartupRemotePort
1 change: 1 addition & 0 deletions src/dbgshim/dbgshim_unixexports.src
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ CreateDebuggingInterfaceFromVersionEx
CreateDebuggingInterfaceFromVersion2
CreateDebuggingInterfaceFromVersion3
CLRCreateInstance
RegisterForRuntimeStartupRemotePort