aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectWatchpoint.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2012-10-23 07:20:06 +0000
committerJim Ingham <jingham@apple.com>2012-10-23 07:20:06 +0000
commita7dfb665e31dfcaba37c0680c5057ae478fbdca2 (patch)
tree92dddd6d1e2ee021262a14463d18fdc8d730b891 /lldb/source/Commands/CommandObjectWatchpoint.cpp
parent0a08aa91d50a70185e0912e39ebfbde7da632f43 (diff)
downloadllvm-a7dfb665e31dfcaba37c0680c5057ae478fbdca2.zip
llvm-a7dfb665e31dfcaba37c0680c5057ae478fbdca2.tar.gz
llvm-a7dfb665e31dfcaba37c0680c5057ae478fbdca2.tar.bz2
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. llvm-svn: 166472
Diffstat (limited to 'lldb/source/Commands/CommandObjectWatchpoint.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectWatchpoint.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index 63275f9..d3b2243 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -1056,6 +1056,8 @@ protected:
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 @@ protected:
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 @@ protected:
// 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 @@ protected:
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 @@ protected:
// 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 @@ protected:
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);