summaryrefslogtreecommitdiff
path: root/src/debug/ee/rcthread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug/ee/rcthread.cpp')
-rw-r--r--src/debug/ee/rcthread.cpp326
1 files changed, 130 insertions, 196 deletions
diff --git a/src/debug/ee/rcthread.cpp b/src/debug/ee/rcthread.cpp
index 7e6f1ae304..896db99884 100644
--- a/src/debug/ee/rcthread.cpp
+++ b/src/debug/ee/rcthread.cpp
@@ -305,27 +305,21 @@ HRESULT DebuggerIPCControlBlock::Init(
m_bHostingInFiber = true;
}
-#if defined(FEATURE_DBGIPC_TRANSPORT_VM)
- DWORD useTransport = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_DbgUseTransport);
- if(!useTransport)
+#if !defined(FEATURE_DBGIPC_TRANSPORT_VM)
+ // Copy RSEA and RSER into the control block.
+ if (!m_rightSideEventAvailable.SetLocal(hRsea))
{
-#endif
- // Copy RSEA and RSER into the control block.
- if (!m_rightSideEventAvailable.SetLocal(hRsea))
- {
- ThrowLastError();
- }
+ ThrowLastError();
+ }
- if (!m_rightSideEventRead.SetLocal(hRser))
- {
- ThrowLastError();
- }
+ if (!m_rightSideEventRead.SetLocal(hRser))
+ {
+ ThrowLastError();
+ }
- if (!m_leftSideUnmanagedWaitEvent.SetLocal(hLsuwe))
- {
- ThrowLastError();
- }
-#ifdef FEATURE_DBGIPC_TRANSPORT_VM
+ if (!m_leftSideUnmanagedWaitEvent.SetLocal(hLsuwe))
+ {
+ ThrowLastError();
}
#endif // !FEATURE_DBGIPC_TRANSPORT_VM
@@ -420,78 +414,71 @@ HRESULT DebuggerRCThread::Init(void)
HRESULT hr;
#if defined(FEATURE_DBGIPC_TRANSPORT_VM)
- DWORD useTransport = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_DbgUseTransport);
- if(!useTransport)
+
+ if (m_pDCB)
{
-#endif
- IPCHostSecurityAttributeHolder sa(GetCurrentProcessId());
+ hr = m_pDCB->Init(NULL, NULL, NULL, NULL, NULL);
+ _ASSERTE(SUCCEEDED(hr)); // throws on error.
+ }
+#else //FEATURE_DBGIPC_TRANSPORT_VM
- // Create the events that the thread will need to receive events
- // from the out of process piece on the right side.
- // We will not fail out if CreateEvent fails for RSEA or RSER. Because
- // the worst case is that debugger cannot attach to debuggee.
- //
- HandleHolder rightSideEventAvailable(WszCreateEvent(sa.GetHostSA(), (BOOL) kAutoResetEvent, FALSE, NULL));
+ IPCHostSecurityAttributeHolder sa(GetCurrentProcessId());
- // Security fix:
- // We need to check the last error to see if the event was precreated or not
- // If so, we need to release the handle right now.
- //
- dwStatus = GetLastError();
- if (dwStatus == ERROR_ALREADY_EXISTS)
- {
- // clean up the handle now
- rightSideEventAvailable.Clear();
- }
+ // Create the events that the thread will need to receive events
+ // from the out of process piece on the right side.
+ // We will not fail out if CreateEvent fails for RSEA or RSER. Because
+ // the worst case is that debugger cannot attach to debuggee.
+ //
+ HandleHolder rightSideEventAvailable(WszCreateEvent(sa.GetHostSA(), (BOOL) kAutoResetEvent, FALSE, NULL));
- HandleHolder rightSideEventRead(WszCreateEvent(sa.GetHostSA(), (BOOL) kAutoResetEvent, FALSE, NULL));
+ // Security fix:
+ // We need to check the last error to see if the event was precreated or not
+ // If so, we need to release the handle right now.
+ //
+ dwStatus = GetLastError();
+ if (dwStatus == ERROR_ALREADY_EXISTS)
+ {
+ // clean up the handle now
+ rightSideEventAvailable.Clear();
+ }
- // Security fix:
- // We need to check the last error to see if the event was precreated or not
- // If so, we need to release the handle right now.
- //
- dwStatus = GetLastError();
- if (dwStatus == ERROR_ALREADY_EXISTS)
- {
- // clean up the handle now
- rightSideEventRead.Clear();
- }
+ HandleHolder rightSideEventRead(WszCreateEvent(sa.GetHostSA(), (BOOL) kAutoResetEvent, FALSE, NULL));
+ // Security fix:
+ // We need to check the last error to see if the event was precreated or not
+ // If so, we need to release the handle right now.
+ //
+ dwStatus = GetLastError();
+ if (dwStatus == ERROR_ALREADY_EXISTS)
+ {
+ // clean up the handle now
+ rightSideEventRead.Clear();
+ }
- HandleHolder leftSideUnmanagedWaitEvent(CreateWin32EventOrThrow(NULL, kManualResetEvent, FALSE));
- // Copy RSEA and RSER into the control block only if shared memory is created without error.
- if (m_pDCB)
- {
- // Since Init() gets ownership of handles as soon as it's called, we can
- // release our ownership now.
- rightSideEventAvailable.SuppressRelease();
- rightSideEventRead.SuppressRelease();
- leftSideUnmanagedWaitEvent.SuppressRelease();
-
- // NOTE: initialization of the debugger control block occurs partly on the left side and partly on
- // the right side. This initialization occurs in parallel, so it's unsafe to make assumptions about
- // the order in which the fields will be initialized.
- hr = m_pDCB->Init(rightSideEventAvailable,
- rightSideEventRead,
- NULL,
- NULL,
- leftSideUnmanagedWaitEvent);
-
- _ASSERTE(SUCCEEDED(hr)); // throws on error.
- }
+ HandleHolder leftSideUnmanagedWaitEvent(CreateWin32EventOrThrow(NULL, kManualResetEvent, FALSE));
-#ifdef FEATURE_DBGIPC_TRANSPORT_VM
- }
- else
+ // Copy RSEA and RSER into the control block only if shared memory is created without error.
+ if (m_pDCB)
{
- if (m_pDCB)
- {
- hr = m_pDCB->Init(NULL, NULL, NULL, NULL, NULL);
- _ASSERTE(SUCCEEDED(hr)); // throws on error.
- }
+ // Since Init() gets ownership of handles as soon as it's called, we can
+ // release our ownership now.
+ rightSideEventAvailable.SuppressRelease();
+ rightSideEventRead.SuppressRelease();
+ leftSideUnmanagedWaitEvent.SuppressRelease();
+
+ // NOTE: initialization of the debugger control block occurs partly on the left side and partly on
+ // the right side. This initialization occurs in parallel, so it's unsafe to make assumptions about
+ // the order in which the fields will be initialized.
+ hr = m_pDCB->Init(rightSideEventAvailable,
+ rightSideEventRead,
+ NULL,
+ NULL,
+ leftSideUnmanagedWaitEvent);
+
+ _ASSERTE(SUCCEEDED(hr)); // throws on error.
}
-#endif
+#endif //FEATURE_DBGIPC_TRANSPORT_VM
if(m_pDCB)
{
@@ -751,7 +738,7 @@ HRESULT DebuggerRCThread::SetupRuntimeOffsets(DebuggerIPCControlBlock * pDebugge
#if !defined(FEATURE_CORESYSTEM)
// Grab the address of RaiseException in kernel32 because we have to play some games with exceptions
// that are generated there (just another reason why mixed mode debugging is shady). See bug 476768.
- HMODULE hModule = WszGetModuleHandle(W("kernel32.dll"));
+ HMODULE hModule = WszGetModuleHandle(W("kernel32.dll"));
_ASSERTE(hModule != NULL);
PREFAST_ASSUME(hModule != NULL);
pDebuggerRuntimeOffsets->m_raiseExceptionAddr = GetProcAddress(hModule, "RaiseException");
@@ -1060,14 +1047,8 @@ void DebuggerRCThread::RightSideDetach(void)
{
_ASSERTE( m_fDetachRightSide == false );
m_fDetachRightSide = true;
-#if defined(FEATURE_DBGIPC_TRANSPORT_VM)
- DWORD useTransport = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_DbgUseTransport);
- if(!useTransport)
- {
-#endif
- CloseIPCHandles();
-#ifdef FEATURE_DBGIPC_TRANSPORT_VM
- }
+#if !defined(FEATURE_DBGIPC_TRANSPORT_VM)
+ CloseIPCHandles();
#endif // !FEATURE_DBGIPC_TRANSPORT_VM
}
@@ -1127,53 +1108,40 @@ bool DebuggerRCThread::HandleRSEA()
LOG((LF_CORDB,LL_INFO10000, "RSEA from out of process (right side)\n"));
DebuggerIPCEvent * e;
-#if defined(FEATURE_DBGIPC_TRANSPORT_VM)
- DWORD useTransport = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_DbgUseTransport);
- if(!useTransport)
- {
-#endif
- // Make room for any Right Side event on the stack.
- BYTE buffer[CorDBIPC_BUFFER_SIZE];
- e = (DebuggerIPCEvent *) buffer;
+#if !defined(FEATURE_DBGIPC_TRANSPORT_VM)
+ // Make room for any Right Side event on the stack.
+ BYTE buffer[CorDBIPC_BUFFER_SIZE];
+ e = (DebuggerIPCEvent *) buffer;
- // If the RSEA is signaled, then handle the event from the Right Side.
- memcpy(e, GetIPCEventReceiveBuffer(), CorDBIPC_BUFFER_SIZE);
-#ifdef FEATURE_DBGIPC_TRANSPORT_VM
- }
- else
- {
- // Be sure to fetch the event into the official receive buffer since some event handlers assume it's there
- // regardless of the the event buffer pointer passed to them.
- e = GetIPCEventReceiveBuffer();
- g_pDbgTransport->GetNextEvent(e, CorDBIPC_BUFFER_SIZE);
- }
+ // If the RSEA is signaled, then handle the event from the Right Side.
+ memcpy(e, GetIPCEventReceiveBuffer(), CorDBIPC_BUFFER_SIZE);
+#else
+ // Be sure to fetch the event into the official receive buffer since some event handlers assume it's there
+ // regardless of the the event buffer pointer passed to them.
+ e = GetIPCEventReceiveBuffer();
+ g_pDbgTransport->GetNextEvent(e, CorDBIPC_BUFFER_SIZE);
#endif // !FEATURE_DBGIPC_TRANSPOPRT
-#if defined(FEATURE_DBGIPC_TRANSPORT_VM)
- if(!useTransport)
- {
-#endif
- // If no reply is required, then let the Right Side go since we've got a copy of the event now.
- _ASSERTE(!e->asyncSend || !e->replyRequired);
+#if !defined(FEATURE_DBGIPC_TRANSPORT_VM)
+ // If no reply is required, then let the Right Side go since we've got a copy of the event now.
+ _ASSERTE(!e->asyncSend || !e->replyRequired);
- if (!e->replyRequired && !e->asyncSend)
- {
- LOG((LF_CORDB, LL_INFO1000, "DRCT::ML: no reply required, letting Right Side go.\n"));
+ if (!e->replyRequired && !e->asyncSend)
+ {
+ LOG((LF_CORDB, LL_INFO1000, "DRCT::ML: no reply required, letting Right Side go.\n"));
- BOOL succ = SetEvent(m_pDCB->m_rightSideEventRead);
+ BOOL succ = SetEvent(m_pDCB->m_rightSideEventRead);
- if (!succ)
- CORDBDebuggerSetUnrecoverableWin32Error(m_debugger, 0, true);
- }
+ if (!succ)
+ CORDBDebuggerSetUnrecoverableWin32Error(m_debugger, 0, true);
+ }
#ifdef LOGGING
- else if (e->asyncSend)
- LOG((LF_CORDB, LL_INFO1000, "DRCT::ML: async send.\n"));
- else
- LOG((LF_CORDB, LL_INFO1000, "DRCT::ML: reply required, holding Right Side...\n"));
+ else if (e->asyncSend)
+ LOG((LF_CORDB, LL_INFO1000, "DRCT::ML: async send.\n"));
+ else
+ LOG((LF_CORDB, LL_INFO1000, "DRCT::ML: reply required, holding Right Side...\n"));
#endif
-#ifdef FEATURE_DBGIPC_TRANSPORT_VM
- }
-#endif // FEATURE_DBGIPC_TRANSPORT_VM
+#endif // !FEATURE_DBGIPC_TRANSPORT_VM
// Pass the event to the debugger for handling. Returns true if the event was a Continue event and we can
// stop looking for stragglers. We wrap this whole thing in an exception handler to help us debug faults.
@@ -1227,18 +1195,10 @@ void DebuggerRCThread::MainLoop()
DWORD dwWaitTimeout = INFINITE;
rghWaitSet[DRCT_CONTROL_EVENT] = m_threadControlEvent;
rghWaitSet[DRCT_FAVORAVAIL] = GetFavorAvailableEvent();
-#if defined(FEATURE_DBGIPC_TRANSPORT_VM)
- DWORD useTransport = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_DbgUseTransport);
- if(!useTransport)
- {
-#endif // !FEATURE_DBGIPC_TRANSPORT_VM
- rghWaitSet[DRCT_RSEA] = m_pDCB->m_rightSideEventAvailable;
-#ifdef FEATURE_DBGIPC_TRANSPORT_VM
- }
- else
- {
- rghWaitSet[DRCT_RSEA] = g_pDbgTransport->GetIPCEventReadyEvent();
- }
+#if !defined(FEATURE_DBGIPC_TRANSPORT_VM)
+ rghWaitSet[DRCT_RSEA] = m_pDCB->m_rightSideEventAvailable;
+#else
+ rghWaitSet[DRCT_RSEA] = g_pDbgTransport->GetIPCEventReadyEvent();
#endif // !FEATURE_DBGIPC_TRANSPORT_VM
CONTRACT_VIOLATION(ThrowsViolation);// HndCreateHandle throws, and this loop is not backstopped by any EH
@@ -1251,38 +1211,28 @@ void DebuggerRCThread::MainLoop()
{
LOG((LF_CORDB, LL_INFO1000, "DRCT::ML: waiting for event.\n"));
-#if defined(FEATURE_DBGIPC_TRANSPORT_VM)
- DWORD useTransport = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_DbgUseTransport);
- if(!useTransport)
+#if !defined(FEATURE_DBGIPC_TRANSPORT_VM)
+ // If there is a debugger attached, wait on its handle, too...
+ if ((cWaitCount == DRCT_COUNT_INITIAL) &&
+ m_pDCB->m_rightSideProcessHandle.ImportToLocalProcess() != NULL)
{
-#endif // FEATURE_DBGIPC_TRANSPORT_VM
- // If there is a debugger attached, wait on its handle, too...
- if ((cWaitCount == DRCT_COUNT_INITIAL) &&
- m_pDCB->m_rightSideProcessHandle.ImportToLocalProcess() != NULL)
- {
- _ASSERTE((cWaitCount + 1) == DRCT_COUNT_FINAL);
- rghWaitSet[DRCT_DEBUGGER_EVENT] = m_pDCB->m_rightSideProcessHandle;
- cWaitCount = DRCT_COUNT_FINAL;
- }
-#ifdef FEATURE_DBGIPC_TRANSPORT_VM
+ _ASSERTE((cWaitCount + 1) == DRCT_COUNT_FINAL);
+ rghWaitSet[DRCT_DEBUGGER_EVENT] = m_pDCB->m_rightSideProcessHandle;
+ cWaitCount = DRCT_COUNT_FINAL;
}
-#endif // FEATURE_DBGIPC_TRANSPORT_VM
+#endif // !FEATURE_DBGIPC_TRANSPORT_VM
+
if (m_fDetachRightSide)
{
m_fDetachRightSide = false;
-#if defined(FEATURE_DBGIPC_TRANSPORT_VM)
- if(!useTransport)
- {
-#endif
- _ASSERTE(cWaitCount == DRCT_COUNT_FINAL);
- _ASSERTE((cWaitCount - 1) == DRCT_COUNT_INITIAL);
+#if !defined(FEATURE_DBGIPC_TRANSPORT_VM)
+ _ASSERTE(cWaitCount == DRCT_COUNT_FINAL);
+ _ASSERTE((cWaitCount - 1) == DRCT_COUNT_INITIAL);
- rghWaitSet[DRCT_DEBUGGER_EVENT] = NULL;
- cWaitCount = DRCT_COUNT_INITIAL;
-#if defined(FEATURE_DBGIPC_TRANSPORT_VM)
- }
+ rghWaitSet[DRCT_DEBUGGER_EVENT] = NULL;
+ cWaitCount = DRCT_COUNT_INITIAL;
#endif // !FEATURE_DBGIPC_TRANSPORT_VM
}
@@ -1491,18 +1441,10 @@ void DebuggerRCThread::TemporaryHelperThreadMainLoop()
DWORD dwWaitTimeout = INFINITE;
rghWaitSet[DRCT_CONTROL_EVENT] = m_threadControlEvent;
rghWaitSet[DRCT_FAVORAVAIL] = GetFavorAvailableEvent();
-#if defined(FEATURE_DBGIPC_TRANSPORT_VM)
- DWORD useTransport = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_DbgUseTransport);
- if(!useTransport)
- {
-#endif
- rghWaitSet[DRCT_RSEA] = m_pDCB->m_rightSideEventAvailable;
-#ifdef FEATURE_DBGIPC_TRANSPORT_VM
- }
- else
- {
- rghWaitSet[DRCT_RSEA] = g_pDbgTransport->GetIPCEventReadyEvent();
- }
+#if !defined(FEATURE_DBGIPC_TRANSPORT_VM)
+ rghWaitSet[DRCT_RSEA] = m_pDCB->m_rightSideEventAvailable;
+#else //FEATURE_DBGIPC_TRANSPORT_VM
+ rghWaitSet[DRCT_RSEA] = g_pDbgTransport->GetIPCEventReadyEvent();
#endif // !FEATURE_DBGIPC_TRANSPORT_VM
CONTRACT_VIOLATION(ThrowsViolation);// HndCreateHandle throws, and this loop is not backstopped by any EH
@@ -2153,31 +2095,23 @@ HRESULT DebuggerRCThread::SendIPCReply()
IPCENames::GetName(event->type)));
#endif
-#if defined(FEATURE_DBGIPC_TRANSPORT_VM)
- DWORD useTransport = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_DbgUseTransport);
- if(!useTransport)
+#if !defined(FEATURE_DBGIPC_TRANSPORT_VM)
+ BOOL succ = SetEvent(m_pDCB->m_rightSideEventRead);
+ if (!succ)
{
-#endif
- BOOL succ = SetEvent(m_pDCB->m_rightSideEventRead);
- if (!succ)
- {
- hr = CORDBDebuggerSetUnrecoverableWin32Error(m_debugger, 0, false);
- }
-#ifdef FEATURE_DBGIPC_TRANSPORT_VM
+ hr = CORDBDebuggerSetUnrecoverableWin32Error(m_debugger, 0, false);
}
- else
+#else // !FEATURE_DBGIPC_TRANSPORT_VM
+ hr = g_pDbgTransport->SendEvent(GetIPCEventReceiveBuffer());
+ if (FAILED(hr))
{
- hr = g_pDbgTransport->SendEvent(GetIPCEventReceiveBuffer());
- if (FAILED(hr))
- {
- m_debugger->UnrecoverableError(hr,
- 0,
- __FILE__,
- __LINE__,
- false);
- }
+ m_debugger->UnrecoverableError(hr,
+ 0,
+ __FILE__,
+ __LINE__,
+ false);
}
-#endif // FEATURE_DBGIPC_TRANSPORT_VM
+#endif // !FEATURE_DBGIPC_TRANSPORT_VM
return hr;
}