summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}