Watchpoints remember the type of the expression or variable they were set with, and use
it to print the old and new values.
Temporarily disable the "out of scope" checking since it didn't work correctly, and was
not what people generally expected watchpoints to be doing.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@166472 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectWatchpoint.cpp b/source/Commands/CommandObjectWatchpoint.cpp
index 63275f9..d3b2243 100644
--- a/source/Commands/CommandObjectWatchpoint.cpp
+++ b/source/Commands/CommandObjectWatchpoint.cpp
@@ -1056,6 +1056,8 @@
valobj_sp = valobj_list.GetValueObjectAtIndex(0);
}
+ ClangASTType type;
+
if (valobj_sp) {
AddressType addr_type;
addr = valobj_sp->GetAddressOf(false, &addr_type);
@@ -1065,6 +1067,7 @@
size = m_option_watchpoint.watch_size == 0 ? valobj_sp->GetByteSize()
: m_option_watchpoint.watch_size;
}
+ type.SetClangType(valobj_sp->GetClangAST(), valobj_sp->GetClangType());
} else {
const char *error_cstr = error.AsCString(NULL);
if (error_cstr)
@@ -1078,7 +1081,7 @@
// Now it's time to create the watchpoint.
uint32_t watch_type = m_option_watchpoint.watch_type;
error.Clear();
- Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type, error).get();
+ Watchpoint *wp = target->CreateWatchpoint(addr, size, &type, watch_type, error).get();
if (wp) {
wp->SetWatchSpec(command.GetArgumentAtIndex(0));
wp->SetWatchVariable(true);
@@ -1088,9 +1091,6 @@
var_sp->GetDeclaration().DumpStopContext(&ss, true);
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();
@@ -1265,8 +1265,15 @@
// Now it's time to create the watchpoint.
uint32_t watch_type = m_option_watchpoint.watch_type;
+
+ // Fetch the type from the value object, the type of the watched object is the pointee type
+ /// of the expression, so convert to that if we found a valid type.
+ ClangASTType type(valobj_sp->GetClangAST(), valobj_sp->GetClangType());
+ if (type.IsValid())
+ type.SetClangType(type.GetASTContext(), type.GetPointeeType());
+
Error error;
- Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type, error).get();
+ Watchpoint *wp = target->CreateWatchpoint(addr, size, &type, watch_type, error).get();
if (wp) {
if (var_sp && var_sp->GetDeclaration().GetFile()) {
StreamString ss;
@@ -1275,11 +1282,6 @@
wp->SetDeclInfo(ss.GetString());
}
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);