summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2012-08-13 23:27:50 +0000
committerJohnny Chen <johnny.chen@apple.com>2012-08-13 23:27:50 +0000
commit88fc73b8f7ff8187110cab0f3175bdf7a3a6c41b (patch)
tree4836356277f9dcbfbcb7a986c5ed050518d960d1
parent396b595b9281486be49b1d1596dba86c2e98f3aa (diff)
downloadbcm5719-llvm-88fc73b8f7ff8187110cab0f3175bdf7a3a6c41b.tar.gz
bcm5719-llvm-88fc73b8f7ff8187110cab0f3175bdf7a3a6c41b.zip
Simplify the "Watchpoint ... hit" printout, make it more terse.
Change the test case, too. llvm-svn: 161806
-rw-r--r--lldb/include/lldb/Breakpoint/Watchpoint.h3
-rw-r--r--lldb/source/Breakpoint/Watchpoint.cpp37
-rw-r--r--lldb/source/Target/StopInfo.cpp4
-rw-r--r--lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py4
-rw-r--r--lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py4
5 files changed, 39 insertions, 13 deletions
diff --git a/lldb/include/lldb/Breakpoint/Watchpoint.h b/lldb/include/lldb/Breakpoint/Watchpoint.h
index c5537d21e6c..0f11b30811c 100644
--- a/lldb/include/lldb/Breakpoint/Watchpoint.h
+++ b/lldb/include/lldb/Breakpoint/Watchpoint.h
@@ -68,10 +68,11 @@ public:
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; }
diff --git a/lldb/source/Breakpoint/Watchpoint.cpp b/lldb/source/Breakpoint/Watchpoint.cpp
index 60c47a9ad9b..6ba2f9c89f4 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -103,7 +103,10 @@ Watchpoint::GetOldSnapshot() const
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 @@ void
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 @@ Watchpoint::SetNewSnapshotVal (uint64_t val)
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 @@ Watchpoint::Dump(Stream *s) const
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 @@ Watchpoint::DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) c
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 @@ void
Watchpoint::SetEnabled(bool enabled)
{
if (!enabled)
+ {
SetHardwareIndex(LLDB_INVALID_INDEX32);
+ ClearSnapshots();
+ }
m_enabled = enabled;
}
diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp
index 6beec286584..5732ed66cc1 100644
--- a/lldb/source/Target/StopInfo.cpp
+++ b/lldb/source/Target/StopInfo.cpp
@@ -544,8 +544,8 @@ public:
// 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();
}
diff --git a/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py b/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py
index 782f04cab92..5348737a3c5 100644
--- a/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py
+++ b/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py
@@ -83,8 +83,8 @@ class WatchpointLLDBCommandTestCase(TestBase):
# 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",
diff --git a/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py b/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py
index 3a4cafe5872..023a4c697ab 100644
--- a/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py
+++ b/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py
@@ -83,8 +83,8 @@ class WatchpointPythonCommandTestCase(TestBase):
# 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",
OpenPOWER on IntegriCloud