summaryrefslogtreecommitdiff
path: root/src/debug/di/process.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug/di/process.cpp')
-rw-r--r--src/debug/di/process.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/src/debug/di/process.cpp b/src/debug/di/process.cpp
index 01b474bde6..2343122317 100644
--- a/src/debug/di/process.cpp
+++ b/src/debug/di/process.cpp
@@ -100,12 +100,13 @@ STDAPI OpenVirtualProcessImpl(
// - there is no w32et thread (all threads are effectively an event thread)
// - the stop state is 'live', which corresponds to CordbProcess not knowing what
// its stop state really is (because that is now controlled by the shim).
+ ProcessDescriptor pd = ProcessDescriptor::CreateUninitialized();
IfFailThrow(CordbProcess::OpenVirtualProcess(
clrInstanceId,
pDataTarget, // takes a reference
hDacModule,
NULL, // Cordb
- (DWORD) 0, // 0 for V3 cases (pShim == NULL).
+ &pd, // 0 for V3 cases (pShim == NULL).
NULL, // no Shim in V3 cases
&pProcess));
@@ -820,7 +821,7 @@ HRESULT CordbProcess::OpenVirtualProcess(
IUnknown * pDataTarget,
HMODULE hDacModule,
Cordb* pCordb,
- DWORD dwProcessID,
+ const ProcessDescriptor * pProcessDescriptor,
ShimProcess * pShim,
CordbProcess ** ppProcess)
{
@@ -849,7 +850,7 @@ HRESULT CordbProcess::OpenVirtualProcess(
HRESULT hr = S_OK;
RSUnsafeExternalSmartPtr<CordbProcess> pProcess;
- pProcess.Assign(new (nothrow) CordbProcess(clrInstanceId, pDataTarget, hDacModule, pCordb, dwProcessID, pShim));
+ pProcess.Assign(new (nothrow) CordbProcess(clrInstanceId, pDataTarget, hDacModule, pCordb, pProcessDescriptor, pShim));
if (pProcess == NULL)
{
@@ -916,12 +917,13 @@ CordbProcess::CordbProcess(ULONG64 clrInstanceId,
IUnknown * pDataTarget,
HMODULE hDacModule,
Cordb * pCordb,
- DWORD dwProcessID,
+ const ProcessDescriptor * pProcessDescriptor,
ShimProcess * pShim)
- : CordbBase(NULL, dwProcessID, enumCordbProcess),
+ : CordbBase(NULL, pProcessDescriptor->m_Pid, enumCordbProcess),
m_fDoDelayedManagedAttached(false),
m_cordb(pCordb),
m_handle(NULL),
+ m_processDescriptor(*pProcessDescriptor),
m_detached(false),
m_uninitializedStop(false),
m_exiting(false),
@@ -1194,7 +1196,7 @@ HRESULT ShimProcess::CreateProcess(
HRESULT ShimProcess::DebugActiveProcess(
Cordb * pCordb,
ICorDebugRemoteTarget * pRemoteTarget,
- DWORD dwProcessID,
+ const ProcessDescriptor * pProcessDescriptor,
BOOL fWin32Attach
)
{
@@ -1216,7 +1218,7 @@ HRESULT ShimProcess::DebugActiveProcess(
// If this succeeds, new CordbProcess will add a ref to the ShimProcess
hr = pShim->GetWin32EventThread()->SendDebugActiveProcessEvent(pShim->GetMachineInfo(),
- dwProcessID,
+ pProcessDescriptor,
fWin32Attach == TRUE,
NULL);
IfFailThrow(hr);
@@ -3318,22 +3320,22 @@ HRESULT CordbProcess::GetID(DWORD *pdwProcessId)
*pdwProcessId = 0;
ThrowHR(E_NOTIMPL);
}
- *pdwProcessId = GetPid();
+ *pdwProcessId = GetProcessDescriptor()->m_Pid;
}
EX_CATCH_HRESULT(hr);
return hr;
}
-// Helper to get PID internally. We know we'll always succeed.
+// Helper to get process descriptor internally. We know we'll always succeed.
// This is more convient for internal callers since they can just use it as an expression
// without having to check HRESULTS.
-DWORD CordbProcess::GetPid()
+const ProcessDescriptor* CordbProcess::GetProcessDescriptor()
{
// This shouldn't be used in V3 paths, in which case it's set to 0. Only the shim should be
// calling this. Assert to catch anybody else.
- _ASSERTE(m_id != 0);
+ _ASSERTE(m_processDescriptor.IsInitialized());
- return (DWORD) m_id;
+ return &m_processDescriptor;
}
@@ -7517,7 +7519,7 @@ void CordbProcess::GetEventBlock(BOOL * pfBlockExists)
IfFailThrow(NewEventChannelForThisPlatform(pLeftSideDCB,
m_pMutableDataTarget,
- GetPid(),
+ GetProcessDescriptor(),
m_pShim->GetMachineInfo(),
&m_pEventChannel));
_ASSERTE(m_pEventChannel != NULL);
@@ -13809,9 +13811,10 @@ void CordbWin32EventThread::CreateProcess()
{
// Process ID is filled in after process is succesfully created.
DWORD dwProcessId = m_actionData.createData.lpProcessInformation->dwProcessId;
+ ProcessDescriptor pd = ProcessDescriptor::FromPid(dwProcessId);
RSUnsafeExternalSmartPtr<CordbProcess> pProcess;
- hr = m_pShim->InitializeDataTarget(dwProcessId);
+ hr = m_pShim->InitializeDataTarget(&pd);
if (SUCCEEDED(hr))
{
@@ -13819,7 +13822,7 @@ void CordbWin32EventThread::CreateProcess()
// OpenVirtualProcess. This will then connect to the first CLR
// loaded.
const ULONG64 cFirstClrLoaded = 0;
- hr = CordbProcess::OpenVirtualProcess(cFirstClrLoaded, m_pShim->GetDataTarget(), NULL, m_cordb, dwProcessId, m_pShim, &pProcess);
+ hr = CordbProcess::OpenVirtualProcess(cFirstClrLoaded, m_pShim->GetDataTarget(), NULL, m_cordb, &pd, m_pShim, &pProcess);
}
// Shouldn't happen on a create, only an attach
@@ -13866,7 +13869,7 @@ void CordbWin32EventThread::CreateProcess()
//
HRESULT CordbWin32EventThread::SendDebugActiveProcessEvent(
MachineInfo machineInfo,
- DWORD pid,
+ const ProcessDescriptor *pProcessDescriptor,
bool fWin32Attach,
CordbProcess *pProcess)
{
@@ -13875,7 +13878,7 @@ HRESULT CordbWin32EventThread::SendDebugActiveProcessEvent(
LockSendToWin32EventThreadMutex();
m_actionData.attachData.machineInfo = machineInfo;
- m_actionData.attachData.processId = pid;
+ m_actionData.attachData.processDescriptor = *pProcessDescriptor;
#if !defined(FEATURE_DBGIPC_TRANSPORT_DI)
m_actionData.attachData.fWin32Attach = fWin32Attach;
#endif
@@ -14004,17 +14007,16 @@ void CordbWin32EventThread::AttachProcess()
HRESULT hr = S_OK;
- DWORD dwProcessId = m_actionData.attachData.processId;
+ ProcessDescriptor processDescriptor = m_actionData.attachData.processDescriptor;
bool fNativeAttachSucceeded = false;
-
// Always do OS attach to the target.
// By this point, the pid should be valid (because OpenProcess above), pending some race where the process just exited.
// The OS will enforce that only 1 debugger is attached.
// Common failure paths here would be: access denied, double-attach
{
hr = m_pNativePipeline->DebugActiveProcess(m_actionData.attachData.machineInfo,
- dwProcessId);
+ processDescriptor);
if (FAILED(hr))
{
goto LExit;
@@ -14023,7 +14025,7 @@ void CordbWin32EventThread::AttachProcess()
}
- hr = m_pShim->InitializeDataTarget(m_actionData.attachData.processId);
+ hr = m_pShim->InitializeDataTarget(&processDescriptor);
if (FAILED(hr))
{
goto LExit;
@@ -14034,7 +14036,7 @@ void CordbWin32EventThread::AttachProcess()
// loaded.
{
const ULONG64 cFirstClrLoaded = 0;
- hr = CordbProcess::OpenVirtualProcess(cFirstClrLoaded, m_pShim->GetDataTarget(), NULL, m_cordb, dwProcessId, m_pShim, &pProcess);
+ hr = CordbProcess::OpenVirtualProcess(cFirstClrLoaded, m_pShim->GetDataTarget(), NULL, m_cordb, &processDescriptor, m_pShim, &pProcess);
if (FAILED(hr))
{
goto LExit;
@@ -14081,7 +14083,7 @@ LExit:
// If we succeed to do a native-attach, but then failed elsewhere, try to native-detach.
if (fNativeAttachSucceeded)
{
- m_pNativePipeline->DebugActiveProcessStop(dwProcessId);
+ m_pNativePipeline->DebugActiveProcessStop(processDescriptor.m_Pid);
}
if (pProcess != NULL)
@@ -14509,7 +14511,7 @@ void CordbWin32EventThread::ExitProcess(bool fDetach)
// Eventually, the Debugger owns the detach pipeline, so this won't be necessary.
if (fDetach && (m_pProcess != NULL))
{
- HRESULT hr = m_pNativePipeline->DebugActiveProcessStop(m_pProcess->GetPid());
+ HRESULT hr = m_pNativePipeline->DebugActiveProcessStop(m_pProcess->GetProcessDescriptor()->m_Pid);
// We don't expect detach to fail (we check earlier for common conditions that
// may cause it to fail)