[Lldb-commits] [lldb] r162322 - in /lldb/trunk/source: Breakpoint/Watchpoint.cpp Target/StopInfo.cpp

Johnny Chen johnny.chen at apple.com
Tue Aug 21 15:06:35 PDT 2012


Author: johnny
Date: Tue Aug 21 17:06:34 2012
New Revision: 162322

URL: http://llvm.org/viewvc/llvm-project?rev=162322&view=rev
Log:
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.

Modified:
    lldb/trunk/source/Breakpoint/Watchpoint.cpp
    lldb/trunk/source/Target/StopInfo.cpp

Modified: lldb/trunk/source/Breakpoint/Watchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Watchpoint.cpp?rev=162322&r1=162321&r2=162322&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Watchpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Watchpoint.cpp Tue Aug 21 17:06:34 2012
@@ -313,7 +313,9 @@
     if (!enabled)
     {
         SetHardwareIndex(LLDB_INVALID_INDEX32);
-        ClearSnapshots();
+        // Don't clear the snapshots for now.
+        // Within StopInfo.cpp, we purposely do disable/enable watchpoint while performing watchpoint actions.
+        //ClearSnapshots();
     }
     m_enabled = enabled;
 }

Modified: lldb/trunk/source/Target/StopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=162322&r1=162321&r2=162322&view=diff
==============================================================================
--- lldb/trunk/source/Target/StopInfo.cpp (original)
+++ lldb/trunk/source/Target/StopInfo.cpp Tue Aug 21 17:06:34 2012
@@ -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





More information about the lldb-commits mailing list