summaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorAndrew Au <andrewau@microsoft.com>2018-10-12 18:34:12 -0700
committerAndrew Au <cshung@gmail.com>2018-11-06 18:34:47 -0800
commita08e10aa1472c4e75edab7f4fd51a0a423ec4a8c (patch)
treef51fe0c9ac9e626e343abe0a1fc3ead923784478 /src/debug
parent7fce1abec7f6b58f301840e0a9690e06cb70a039 (diff)
downloadcoreclr-a08e10aa1472c4e75edab7f4fd51a0a423ec4a8c.tar.gz
coreclr-a08e10aa1472c4e75edab7f4fd51a0a423ec4a8c.tar.bz2
coreclr-a08e10aa1472c4e75edab7f4fd51a0a423ec4a8c.zip
Stepping out of the write barrier
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/ee/controller.cpp16
-rw-r--r--src/debug/ee/controller.h33
2 files changed, 47 insertions, 2 deletions
diff --git a/src/debug/ee/controller.cpp b/src/debug/ee/controller.cpp
index b375e9e87c..a017c70b68 100644
--- a/src/debug/ee/controller.cpp
+++ b/src/debug/ee/controller.cpp
@@ -2733,8 +2733,6 @@ DPOSS_ACTION DebuggerController::ScanForTriggers(CORDB_ADDRESS_TYPE *address,
DebuggerDataBreakpoint::TriggerDataBreakpoint(thread, context))
{
*pHitDataBp = true;
- DebuggerDataBreakpoint *pDataBreakpoint = new (interopsafe) DebuggerDataBreakpoint(thread);
- pDcq->dcqEnqueue(pDataBreakpoint, FALSE);
}
#endif
@@ -2955,6 +2953,7 @@ DPOSS_ACTION DebuggerController::DispatchPatchOrSingleStep(Thread *thread, CONTE
if (hitDataBp)
{
PCODE ip = GetIP(context);
+ LOG((LF_CORDB|LF_ENC, LL_EVERYTHING, "DataBreakpoint: My current IP is %p.\n", ip));
#if defined(_TARGET_X86_)
bool withinWriteBarrierGroup = ((ip >= (PCODE) JIT_WriteBarrierGroup) && (ip <= (PCODE) JIT_WriteBarrierGroup_End));
bool withinPatchedWriteBarrierGroup = ((ip >= (PCODE) JIT_PatchedWriteBarrierGroup) && (ip <= (PCODE) JIT_PatchedWriteBarrierGroup_End));
@@ -2983,6 +2982,19 @@ DPOSS_ACTION DebuggerController::DispatchPatchOrSingleStep(Thread *thread, CONTE
#else
// TODO - ARM/ARM64
#endif
+ LOG((LF_CORDB|LF_ENC, LL_EVERYTHING, "DataBreakpoint: Unwound IP is %p.\n", GetIP(context)));
+ DebuggerDataBreakpoint *pDataBreakpoint = new (interopsafe) DebuggerDataBreakpoint(thread);
+ if (!stashedContext)
+ {
+ dcq.dcqEnqueue(pDataBreakpoint, FALSE);
+ }
+ else
+ {
+ pDataBreakpoint->AddAndActivateNativePatchForAddress((CORDB_ADDRESS_TYPE*)GetIP(context), FramePointer::MakeFramePointer(GetFP(context)), true, DPT_DEFAULT_TRACE_TYPE);
+ memcpy(context, &stash, sizeof(CONTEXT));
+ stashedContext = false;
+ }
+ LOG((LF_CORDB|LF_ENC, LL_EVERYTHING, "DataBreakpoint: Rewound IP is %p.\n", GetIP(context)));
}
LOG((LF_CORDB|LF_ENC, LL_EVERYTHING, "DC::DPOSS ScanForTriggers called and returned.\n"));
diff --git a/src/debug/ee/controller.h b/src/debug/ee/controller.h
index 4e81b847e4..1710001d10 100644
--- a/src/debug/ee/controller.h
+++ b/src/debug/ee/controller.h
@@ -1774,10 +1774,13 @@ private:
class DebuggerDataBreakpoint : public DebuggerController
{
+private:
+ CONTEXT context;
public:
DebuggerDataBreakpoint(Thread* pThread) : DebuggerController(pThread, NULL)
{
LOG((LF_CORDB, LL_INFO10000, "D:DDBP: Data Breakpoint event created\n"));
+ memcpy(&context, g_pEEInterface->GetThreadFilterContext(pThread), sizeof(CONTEXT));
}
virtual DEBUGGER_CONTROLLER_TYPE GetDCType(void)
@@ -1785,6 +1788,33 @@ public:
return DEBUGGER_CONTROLLER_DATA_BREAKPOINT;
}
+ virtual TP_RESULT TriggerPatch(DebuggerControllerPatch *patch,
+ Thread *thread,
+ TRIGGER_WHY tyWhy)
+ {
+#ifndef FEATURE_PAL
+#if defined(_TARGET_X86_) || defined(_TARGET_AMD64_)
+ CONTEXT *context = g_pEEInterface->GetThreadFilterContext(thread);
+#ifdef _TARGET_X86_
+ context->Dr0 = this->context.Dr0;
+ context->Dr1 = this->context.Dr1;
+ context->Dr2 = this->context.Dr2;
+ context->Dr3 = this->context.Dr3;
+ context->Dr6 = this->context.Dr6;
+ context->Dr7 = this->context.Dr7;
+#elif defined(_TARGET_AMD64_)
+ context->Dr0 = this->context.Dr0;
+ context->Dr1 = this->context.Dr1;
+ context->Dr2 = this->context.Dr2;
+ context->Dr3 = this->context.Dr3;
+ context->Dr6 = this->context.Dr6;
+ context->Dr7 = this->context.Dr7;
+#endif
+#endif
+#endif
+ return TPR_TRIGGER;
+ }
+
bool SendEvent(Thread *thread, bool fInteruptedBySetIp)
{
CONTRACTL
@@ -1800,6 +1830,9 @@ public:
CONTEXT *context = g_pEEInterface->GetThreadFilterContext(thread);
g_pDebugger->SendDataBreakpoint(thread, context, this);
+
+ Delete();
+
return true;
}