rdar://problem/12144930
Watchpoint conditions were hitting watchpoint, smashing LLDB's stack.
Make sure watchpoint is properly disabled and subsequently enabled while performing watchpoint actions.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@162322 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index 434b006..c090b18 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -446,6 +446,26 @@
return m_should_stop;
}
+ // Make sure watchpoint is properly disabled and subsequently enabled while performing watchpoint actions.
+ class WatchpointSentry {
+ public:
+ WatchpointSentry(Process *p, Watchpoint *w):
+ process(p),
+ watchpoint(w)
+ {
+ if (process && watchpoint)
+ process->DisableWatchpoint(watchpoint);
+ }
+ ~WatchpointSentry()
+ {
+ if (process && watchpoint)
+ process->EnableWatchpoint(watchpoint);
+ }
+ private:
+ Process *process;
+ Watchpoint *watchpoint;
+ };
+
// Perform any action that is associated with this stop. This is done as the
// Event is removed from the event queue.
virtual void
@@ -462,6 +482,9 @@
{
ExecutionContext exe_ctx (m_thread.GetStackFrameAtIndex(0));
Process* process = exe_ctx.GetProcessPtr();
+
+ WatchpointSentry sentry(process, wp_sp.get());
+
{
// check if this process is running on an architecture where watchpoints trigger
// before the associated instruction runs. if so, disable the WP, single-step and then