[Lldb-commits] [lldb] r161806 - in /lldb/trunk: include/lldb/Breakpoint/Watchpoint.h source/Breakpoint/Watchpoint.cpp source/Target/StopInfo.cpp test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py

Johnny Chen johnny.chen at apple.com
Mon Aug 13 16:27:50 PDT 2012


Author: johnny
Date: Mon Aug 13 18:27:50 2012
New Revision: 161806

URL: http://llvm.org/viewvc/llvm-project?rev=161806&view=rev
Log:
Simplify the "Watchpoint ... hit" printout, make it more terse.
Change the test case, too. 

Modified:
    lldb/trunk/include/lldb/Breakpoint/Watchpoint.h
    lldb/trunk/source/Breakpoint/Watchpoint.cpp
    lldb/trunk/source/Target/StopInfo.cpp
    lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py
    lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py

Modified: lldb/trunk/include/lldb/Breakpoint/Watchpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Watchpoint.h?rev=161806&r1=161805&r2=161806&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/Watchpoint.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/Watchpoint.h Mon Aug 13 18:27:50 2012
@@ -68,10 +68,11 @@
     void        SetOldSnapshotVal (uint64_t val);
     uint64_t    GetNewSnapshotVal() const;
     void        SetNewSnapshotVal (uint64_t val);
+    void        ClearSnapshots();
 
     void        GetDescription (Stream *s, lldb::DescriptionLevel level);
     void        Dump (Stream *s) const;
-    void        DumpSnapshots (const char * prefix, Stream *s) const;
+    void        DumpSnapshots (Stream *s, const char * prefix = NULL) const;
     void        DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const;
     Target      &GetTarget() { return *m_target; }
     const Error &GetError() { return m_error; }

Modified: lldb/trunk/source/Breakpoint/Watchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Watchpoint.cpp?rev=161806&r1=161805&r2=161806&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Watchpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Watchpoint.cpp Mon Aug 13 18:27:50 2012
@@ -103,7 +103,10 @@
 void
 Watchpoint::SetOldSnapshot (const std::string &str)
 {
+    size_t len = str.length();
     m_snapshot_old_str = str;
+    if (len && str.at(len - 1) == '\n')
+        m_snapshot_old_str.resize(len - 1);
     return;
 }
 
@@ -117,7 +120,10 @@
 Watchpoint::SetNewSnapshot (const std::string &str)
 {
     m_snapshot_old_str = m_snapshot_new_str;
+    size_t len = str.length();
     m_snapshot_new_str = str;
+    if (len && str.at(len - 1) == '\n')
+        m_snapshot_new_str.resize(len - 1);
     return;
 }
 
@@ -148,6 +154,15 @@
     return;
 }
 
+void
+Watchpoint::ClearSnapshots()
+{
+    m_snapshot_old_str.clear();
+    m_snapshot_new_str.clear();
+    m_snapshot_old_val = 0;
+    m_snapshot_new_val = 0;
+}
+
 // Override default impl of StoppointLocation::IsHardware() since m_is_hardware
 // member field is more accurate.
 bool
@@ -198,21 +213,28 @@
     DumpWithLevel(s, lldb::eDescriptionLevelBrief);
 }
 
+// If prefix is NULL, we display the watch id and ignore the prefix altogether.
 void
-Watchpoint::DumpSnapshots(const char *prefix, Stream *s) const
+Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const
 {
+    if (!prefix)
+    {
+        s->Printf("\nWatchpoint %u hit:", GetID());
+        prefix = "";
+    }
+
     if (IsWatchVariable())
     {
         if (!m_snapshot_old_str.empty())
-            s->Printf("\n%swatchpoint old value:\n\t%s", prefix, m_snapshot_old_str.c_str());
+            s->Printf("\n%sold value: %s", prefix, m_snapshot_old_str.c_str());
         if (!m_snapshot_new_str.empty())
-            s->Printf("\n%swatchpoint new value:\n\t%s", prefix, m_snapshot_new_str.c_str());
+            s->Printf("\n%snew value: %s", prefix, m_snapshot_new_str.c_str());
     }
     else
     {
         uint32_t num_hex_digits = GetByteSize() * 2;
-        s->Printf("\n%swatchpoint old value:0x%0*.*llx", prefix, num_hex_digits, num_hex_digits, m_snapshot_old_val);
-        s->Printf("\n%swatchpoint new value:0x%0*.*llx", prefix, num_hex_digits, num_hex_digits, m_snapshot_new_val);
+        s->Printf("\n%sold value: 0x%0*.*llx", prefix, num_hex_digits, num_hex_digits, m_snapshot_old_val);
+        s->Printf("\n%snew value: 0x%0*.*llx", prefix, num_hex_digits, num_hex_digits, m_snapshot_new_val);
     }
 }
 
@@ -240,7 +262,7 @@
             s->Printf("\n    watchpoint spec = '%s'", m_watch_spec_str.c_str());
 
         // Dump the snapshots we have taken.
-        DumpSnapshots("   ", s);
+        DumpSnapshots(s, "    ");
 
         if (GetConditionText())
             s->Printf("\n    condition = '%s'", GetConditionText());
@@ -266,7 +288,10 @@
 Watchpoint::SetEnabled(bool enabled)
 {
     if (!enabled)
+    {
         SetHardwareIndex(LLDB_INVALID_INDEX32);
+        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=161806&r1=161805&r2=161806&view=diff
==============================================================================
--- lldb/trunk/source/Target/StopInfo.cpp (original)
+++ lldb/trunk/source/Target/StopInfo.cpp Mon Aug 13 18:27:50 2012
@@ -544,8 +544,8 @@
                 // Now dump the snapshots we have taken.
                 Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
                 StreamSP output_sp = debugger.GetAsyncOutputStream ();
-                wp_sp->DumpSnapshots("!!! ", output_sp.get());
-                //output_sp->EOL();
+                wp_sp->DumpSnapshots(output_sp.get());
+                output_sp->EOL();
                 output_sp->Flush();
             }
 

Modified: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py?rev=161806&r1=161805&r2=161806&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py (original)
+++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py Mon Aug 13 18:27:50 2012
@@ -83,8 +83,8 @@
 
         # Check that the watchpoint snapshoting mechanism is working.
         self.expect("watchpoint list -v",
-            substrs = ['watchpoint old value:', 'global = 0',
-                       'watchpoint new value:', 'global = 1'])
+            substrs = ['old value:', 'global = 0',
+                       'new value:', 'global = 1'])
 
         # The watchpoint command "forced" our global variable 'cookie' to become 777.
         self.expect("frame variable -g cookie",

Modified: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py?rev=161806&r1=161805&r2=161806&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py (original)
+++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py Mon Aug 13 18:27:50 2012
@@ -83,8 +83,8 @@
 
         # Check that the watchpoint snapshoting mechanism is working.
         self.expect("watchpoint list -v",
-            substrs = ['watchpoint old value:', 'global = 0',
-                       'watchpoint new value:', 'global = 1'])
+            substrs = ['old value:', 'global = 0',
+                       'new value:', 'global = 1'])
 
         # The watchpoint command "forced" our global variable 'cookie' to become 777.
         self.expect("frame variable -g cookie",





More information about the lldb-commits mailing list