[Lldb-commits] [PATCH] D146262: [lldb] Set the watchpoint spec for expression watchpoints
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 16 14:40:42 PDT 2023
JDevlieghere created this revision.
JDevlieghere added reviewers: jingham, mib, delcypher.
Herald added a project: All.
JDevlieghere requested review of this revision.
When setting a variable watchpoint, the watchpoint stores the variable name in the watchpoint spec. For expression variables we should store the expression in the watchpoint spec. This patch adds that functionality.
https://reviews.llvm.org/D146262
Files:
lldb/source/Commands/CommandObjectWatchpoint.cpp
lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
Index: lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
===================================================================
--- lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
+++ lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
@@ -46,7 +46,7 @@
self.setTearDownCleanup()
exe = self.getBuildArtifact("a.out")
- self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+ target = self.dbg.CreateTarget(exe)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
lldbutil.run_break_set_by_file_and_line(
@@ -81,6 +81,12 @@
self.expect("watchpoint list -v",
substrs=['hit_count = 0'])
+ # Check the underlying SBWatchpoint.
+ watchpoint = target.GetWatchpointAtIndex(0)
+ self.assertEqual(watchpoint.GetWatchSize(), 1)
+ self.assertEqual(watchpoint.GetHitCount(), 0)
+ self.assertEqual(watchpoint.GetWatchSpec(), "g_char_ptr + 7")
+
self.runCmd("process continue")
# We should be stopped again due to the watchpoint (write type), but
Index: lldb/source/Commands/CommandObjectWatchpoint.cpp
===================================================================
--- lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -949,9 +949,8 @@
uint32_t watch_type = m_option_watchpoint.watch_type;
error.Clear();
- Watchpoint *wp =
- target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error)
- .get();
+ WatchpointSP wp =
+ target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error);
if (wp) {
wp->SetWatchSpec(command.GetArgumentAtIndex(0));
wp->SetWatchVariable(true);
@@ -1117,10 +1116,10 @@
CompilerType compiler_type(valobj_sp->GetCompilerType());
Status error;
- Watchpoint *wp =
- target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error)
- .get();
+ WatchpointSP wp =
+ target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error);
if (wp) {
+ wp->SetWatchSpec(std::string(expr));
Stream &output_stream = result.GetOutputStream();
output_stream.Printf("Watchpoint created: ");
wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146262.505931.patch
Type: text/x-patch
Size: 2454 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230316/225237a4/attachment.bin>
More information about the lldb-commits
mailing list