FEATURE_DATABREAKPOINT
authorAndrew Au <andrewau@microsoft.com>
Tue, 23 Oct 2018 23:49:52 +0000 (16:49 -0700)
committerAndrew Au <cshung@gmail.com>
Wed, 7 Nov 2018 02:34:47 +0000 (18:34 -0800)
clrdefinitions.cmake
src/debug/ee/controller.cpp
src/debug/ee/controller.h
src/debug/ee/debugger.cpp
src/debug/ee/debugger.h

index 4f12e4b..5ee91fc 100644 (file)
@@ -235,3 +235,9 @@ add_definitions(-DFEATURE_WINMD_RESILIENT)
 add_definitions(-D_SECURE_SCL=0)
 add_definitions(-DUNICODE)
 add_definitions(-D_UNICODE)
+
+if(WIN32)
+  if (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
+    add_definitions(-DFEATURE_DATABREAKPOINT)
+  endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
+endif(WIN32)
\ No newline at end of file
index 7997929..abc9593 100644 (file)
@@ -2725,7 +2725,7 @@ DPOSS_ACTION DebuggerController::ScanForTriggers(CORDB_ADDRESS_TYPE *address,
         }
     }
 
-#if !defined(FEATURE_PAL)
+#ifdef FEATURE_DATABREAKPOINT
     if (stWhat & ST_SINGLE_STEP &&
         tpr != TPR_TRIGGER_ONLY_THIS && 
         DebuggerDataBreakpoint::TriggerDataBreakpoint(thread, context))
@@ -3027,7 +3027,6 @@ DPOSS_ACTION DebuggerController::DispatchPatchOrSingleStep(Thread *thread, CONTE
         // If we need to to a re-abort (see below), then save the current IP in the thread's context before we block and
         // possibly let another func eval get setup.
         reabort = thread->m_StateNC & Thread::TSNC_DebuggerReAbort;
-
         SENDIPCEVENT_END;
 
         if (!atSafePlace)
@@ -8587,22 +8586,21 @@ TP_RESULT DebuggerFuncEvalComplete::TriggerPatch(DebuggerControllerPatch *patch,
 
     // Restore the thread's context to what it was before we hijacked it for this func eval.
     CONTEXT *pCtx = GetManagedLiveCtx(thread);
-    // TODO: Support other architectures
+#ifdef FEATURE_DATABREAKPOINT
+#ifdef FEATURE_PAL    
+        #error Not supported
+#endif // FEATURE_PAL
+#if defined(_TARGET_X86_) || defined(_TARGET_AMD64_)
     // If a data breakpoint is set while we hit a breakpoint inside a FuncEval, this will make sure the data breakpoint stays
-#ifdef _TARGET_X86_
-    m_pDE->m_context.Dr0 = pCtx->Dr0;
-    m_pDE->m_context.Dr1 = pCtx->Dr1;
-    m_pDE->m_context.Dr2 = pCtx->Dr2;
-    m_pDE->m_context.Dr3 = pCtx->Dr3;
-    m_pDE->m_context.Dr6 = pCtx->Dr6;
-    m_pDE->m_context.Dr7 = pCtx->Dr7;
-#elif defined(_TARGET_AMD64_)
     m_pDE->m_context.Dr0 = pCtx->Dr0;
     m_pDE->m_context.Dr1 = pCtx->Dr1;
     m_pDE->m_context.Dr2 = pCtx->Dr2;
     m_pDE->m_context.Dr3 = pCtx->Dr3;
     m_pDE->m_context.Dr6 = pCtx->Dr6;
     m_pDE->m_context.Dr7 = pCtx->Dr7;
+#else
+    #error Not supported
+#endif
 #endif
     CORDbgCopyThreadContext(reinterpret_cast<DT_CONTEXT *>(pCtx), 
                             reinterpret_cast<DT_CONTEXT *>(&(m_pDE->m_context)));
index 051817b..fa86bb7 100644 (file)
@@ -1771,6 +1771,8 @@ private:
     bool SendEvent(Thread *thread, bool fInteruptedBySetIp);
 };
 
+#ifdef FEATURE_DATABREAKPOINT
+
 class DebuggerDataBreakpoint : public DebuggerController
 {
 private:
@@ -1791,26 +1793,20 @@ public:
                               Thread *thread, 
                               TRIGGER_WHY tyWhy)
     {
-#ifndef FEATURE_PAL    
+#ifdef FEATURE_PAL    
+        #error Not supported
+#endif // FEATURE_PAL
 #if defined(_TARGET_X86_) || defined(_TARGET_AMD64_)
         CONTEXT *context = g_pEEInterface->GetThreadFilterContext(thread);
-#ifdef _TARGET_X86_
-        context->Dr0 = this->m_context.Dr0;
-        context->Dr1 = this->m_context.Dr1;
-        context->Dr2 = this->m_context.Dr2;
-        context->Dr3 = this->m_context.Dr3;
-        context->Dr6 = this->m_context.Dr6;
-        context->Dr7 = this->m_context.Dr7;
-#elif defined(_TARGET_AMD64_)
         context->Dr0 = this->m_context.Dr0;
         context->Dr1 = this->m_context.Dr1;
         context->Dr2 = this->m_context.Dr2;
         context->Dr3 = this->m_context.Dr3;
         context->Dr6 = this->m_context.Dr6;
         context->Dr7 = this->m_context.Dr7;
-#endif
-#endif
-#endif
+#else // defined(_TARGET_X86_) || defined(_TARGET_AMD64_)
+        #error Not supported
+#endif // defined(_TARGET_X86_) || defined(_TARGET_AMD64_)
         return TPR_TRIGGER;
     }
 
@@ -1840,7 +1836,9 @@ public:
         LOG((LF_CORDB, LL_INFO10000, "D::DDBP: Doing TriggerDataBreakpoint...\n"));
 
         bool hitDataBp = false;
-#ifndef FEATURE_PAL    
+#ifdef FEATURE_PAL    
+        #error Not supported
+#endif // FEATURE_PAL    
 #if defined(_TARGET_X86_) || defined(_TARGET_AMD64_)
         PDR6 pdr6 = (PDR6)&(pContext->Dr6);
 
@@ -1857,13 +1855,15 @@ public:
         {
             LOG((LF_CORDB, LL_INFO10000, "D::DDBP: DIDN'T TRIGGER DATA BREAKPOINT...\n"));
         }
-#endif
-#endif
+#else // defined(_TARGET_X86_) || defined(_TARGET_AMD64_)
+        #error Not supported
+#endif // defined(_TARGET_X86_) || defined(_TARGET_AMD64_)
         return hitDataBp;
     }
-
 };
 
+#endif // FEATURE_DATABREAKPOINT
+
 
 /* ------------------------------------------------------------------------- *
  * DebuggerUserBreakpoint routines.  UserBreakpoints are used 
index a1eed00..9876086 100644 (file)
@@ -6078,6 +6078,7 @@ void Debugger::AfterGarbageCollection()
     this->m_isBlockedOnGarbageCollectionEvent = false;
 }
 
+#ifdef FEATURE_DATABREAKPOINT
 void Debugger::SendDataBreakpoint(Thread *thread, CONTEXT *context,
     DebuggerDataBreakpoint *breakpoint)
 {
@@ -6119,6 +6120,7 @@ void Debugger::SendDataBreakpoint(Thread *thread, CONTEXT *context,
 
     m_pRCThread->SendIPCEvent();
 }
+#endif
 
 //
 // SendBreakpoint is called by Runtime threads to send that they've
index aefc904..746f914 100644 (file)
@@ -2157,9 +2157,9 @@ public:
 
     void SendBreakpoint(Thread *thread, T_CONTEXT *context,
                         DebuggerBreakpoint *breakpoint);
-
+#ifdef FEATURE_DATABREAKPOINT
     void SendDataBreakpoint(Thread* thread, T_CONTEXT *context, DebuggerDataBreakpoint *breakpoint);
-
+#endif // FEATURE_DATABREAKPOINT
     void SendStep(Thread *thread, T_CONTEXT *context,
                   DebuggerStepper *stepper,
                   CorDebugStepReason reason);