[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
Fri Mar 17 09:56:09 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG2a7642977876: [lldb] Set the watchpoint spec for expression watchpoints (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146262/new/

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.506122.patch
Type: text/x-patch
Size: 2454 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230317/73d6b443/attachment.bin>


More information about the lldb-commits mailing list