From d742a2f03ab849a2d6a101320d3f1107a8f82c13 Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Tue, 23 Oct 2018 16:49:52 -0700 Subject: [PATCH] FEATURE_DATABREAKPOINT --- clrdefinitions.cmake | 6 ++++++ src/debug/ee/controller.cpp | 20 +++++++++----------- src/debug/ee/controller.h | 32 ++++++++++++++++---------------- src/debug/ee/debugger.cpp | 2 ++ src/debug/ee/debugger.h | 4 ++-- 5 files changed, 35 insertions(+), 29 deletions(-) diff --git a/clrdefinitions.cmake b/clrdefinitions.cmake index 4f12e4b..5ee91fc 100644 --- a/clrdefinitions.cmake +++ b/clrdefinitions.cmake @@ -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 diff --git a/src/debug/ee/controller.cpp b/src/debug/ee/controller.cpp index 7997929..abc9593 100644 --- a/src/debug/ee/controller.cpp +++ b/src/debug/ee/controller.cpp @@ -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(pCtx), reinterpret_cast(&(m_pDE->m_context))); diff --git a/src/debug/ee/controller.h b/src/debug/ee/controller.h index 051817b..fa86bb7 100644 --- a/src/debug/ee/controller.h +++ b/src/debug/ee/controller.h @@ -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 diff --git a/src/debug/ee/debugger.cpp b/src/debug/ee/debugger.cpp index a1eed00..9876086 100644 --- a/src/debug/ee/debugger.cpp +++ b/src/debug/ee/debugger.cpp @@ -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 diff --git a/src/debug/ee/debugger.h b/src/debug/ee/debugger.h index aefc904..746f914 100644 --- a/src/debug/ee/debugger.h +++ b/src/debug/ee/debugger.h @@ -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); -- 2.7.4