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

Johnny Chen johnny.chen at apple.com
Tue Aug 21 16:17:04 PDT 2012


Author: johnny
Date: Tue Aug 21 18:17:04 2012
New Revision: 162328

URL: http://llvm.org/viewvc/llvm-project?rev=162328&view=rev
Log:
Fix test failures in TestWatchpointIter.py due to http://llvm.org/viewvc/llvm-project?rev=162322&view=rev.

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

Modified: lldb/trunk/include/lldb/Breakpoint/Watchpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Watchpoint.h?rev=162328&r1=162327&r2=162328&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/Watchpoint.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/Watchpoint.h Tue Aug 21 18:17:04 2012
@@ -150,6 +150,12 @@
     //------------------------------------------------------------------
     const char *GetConditionText () const;
 
+    void
+    TurnOnEphemeralMode();
+
+    void
+    TurnOffEphemeralMode();
+
 private:
     friend class Target;
     friend class WatchpointList;
@@ -161,6 +167,9 @@
     bool        m_enabled;             // Is this watchpoint enabled
     bool        m_is_hardware;         // Is this a hardware watchpoint
     bool        m_is_watch_variable;   // True if set via 'watchpoint set variable'.
+    bool        m_is_ephemeral;        // True if the watchpoint is in the ephemeral mode, meaning that it is
+                                       // undergoing a pair of temporary disable/enable actions to avoid recursively
+                                       // triggering further watchpoint events.
     uint32_t    m_watch_read:1,        // 1 if we stop when the watched data is read from
                 m_watch_write:1,       // 1 if we stop when the watched data is written to
                 m_watch_was_read:1,    // Set to 1 when watchpoint is hit for a read access

Modified: lldb/trunk/source/Breakpoint/Watchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Watchpoint.cpp?rev=162328&r1=162327&r2=162328&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Watchpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Watchpoint.cpp Tue Aug 21 18:17:04 2012
@@ -29,6 +29,7 @@
     m_enabled(false),
     m_is_hardware(hardware),
     m_is_watch_variable(false),
+    m_is_ephemeral(false),
     m_watch_read(0),
     m_watch_write(0),
     m_watch_was_read(0),
@@ -307,12 +308,29 @@
     return m_enabled;
 }
 
+// Within StopInfo.cpp, we purposely turn on the ephemeral mode right before temporarily disable the watchpoint
+// in order to perform possible watchpoint actions without triggering further watchpoint events.
+// After the temporary disabled watchpoint is enabled, we then turn off the ephemeral mode.
+
+void
+Watchpoint::TurnOnEphemeralMode()
+{
+    m_is_ephemeral = true;
+}
+
+void
+Watchpoint::TurnOffEphemeralMode()
+{
+    m_is_ephemeral = false;
+}
+
 void
 Watchpoint::SetEnabled(bool enabled)
 {
     if (!enabled)
     {
-        SetHardwareIndex(LLDB_INVALID_INDEX32);
+        if (!m_is_ephemeral)
+            SetHardwareIndex(LLDB_INVALID_INDEX32);
         // Don't clear the snapshots for now.
         // Within StopInfo.cpp, we purposely do disable/enable watchpoint while performing watchpoint actions.
         //ClearSnapshots();

Modified: lldb/trunk/source/Target/StopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=162328&r1=162327&r2=162328&view=diff
==============================================================================
--- lldb/trunk/source/Target/StopInfo.cpp (original)
+++ lldb/trunk/source/Target/StopInfo.cpp Tue Aug 21 18:17:04 2012
@@ -454,12 +454,18 @@
             watchpoint(w)
         {
             if (process && watchpoint)
+            {
+                watchpoint->TurnOnEphemeralMode();
                 process->DisableWatchpoint(watchpoint);
+            }
         }
         ~WatchpointSentry()
         {
             if (process && watchpoint)
+            {
                 process->EnableWatchpoint(watchpoint);
+                watchpoint->TurnOffEphemeralMode();
+            }
         }
     private:
         Process *process;





More information about the lldb-commits mailing list