rdar://problem/12007576
Record the snapshot of our watched value when the watchpoint is set or hit.
And report the old/new values when watchpoint is triggered. Add some test scenarios.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@161785 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectWatchpoint.cpp b/source/Commands/CommandObjectWatchpoint.cpp
index b545d3e..ff59e31 100644
--- a/source/Commands/CommandObjectWatchpoint.cpp
+++ b/source/Commands/CommandObjectWatchpoint.cpp
@@ -1047,6 +1047,8 @@
error.Clear();
Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type, error).get();
if (wp) {
+ wp->SetWatchSpec(command.GetArgumentAtIndex(0));
+ wp->SetWatchVariable(true);
if (var_sp && var_sp->GetDeclaration().GetFile()) {
StreamString ss;
// True to show fullpath for declaration file.
@@ -1054,13 +1056,15 @@
wp->SetDeclInfo(ss.GetString());
}
StreamString ss;
+ ValueObject::DumpValueObject(ss, valobj_sp.get());
+ wp->SetNewSnapshot(ss.GetString());
output_stream.Printf("Watchpoint created: ");
wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
output_stream.EOL();
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
- result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%llx, size=%lu).\n",
- addr, size);
+ result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%llx, size=%lu, variable expression='%s').\n",
+ addr, size, command.GetArgumentAtIndex(0));
if (error.AsCString(NULL))
result.AppendError(error.AsCString());
result.SetStatus(eReturnStatusFailed);
@@ -1238,8 +1242,12 @@
var_sp->GetDeclaration().DumpStopContext(&ss, true);
wp->SetDeclInfo(ss.GetString());
}
- StreamString ss;
output_stream.Printf("Watchpoint created: ");
+ uint64_t val = target->GetProcessSP()->ReadUnsignedIntegerFromMemory(addr, size, 0, error);
+ if (error.Success())
+ wp->SetNewSnapshotVal(val);
+ else
+ output_stream.Printf("watchpoint snapshot failed: %s", error.AsCString());
wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
output_stream.EOL();
result.SetStatus(eReturnStatusSuccessFinishResult);