[Lldb-commits] [PATCH] D126730: Fix a bug where `break com add -s py -o "some_python" BKPT_NAME` only added the command to the first breakpoint

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue May 31 17:24:24 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd92f7f790c8e: Fix a copy-paste error in "br com add -s py -o 'some_python' BKPT_NAME" (authored by jingham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126730

Files:
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py


Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
===================================================================
--- lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -283,6 +283,34 @@
         self.assertEqual(com_list.GetStringAtIndex(1), "thread list", "Next thread list")
         self.assertEqual(com_list.GetStringAtIndex(2), "continue", "Last continue")
 
+    def test_add_commands_by_breakpoint_name(self):
+        """Make sure that when you specify a breakpoint name to "break command add"
+           it gets added to all the breakpoints marked with that name."""
+        self.build()
+        target = self.createTestTarget()
+
+        bp_ids = []
+        bp_names = ["main", "not_here", "main"]
+        for bp_name in bp_names:
+            bp = target.BreakpointCreateByName(bp_name)
+            bp.AddName("MyBKPTS")
+            bp_ids.append(bp.GetID())
+        # First do it with a script one-liner:
+        self.runCmd("breakpoint command add -s py -o 'print(\"some command\")' MyBKPTS")
+        for id in bp_ids:
+            self.expect("breakpoint command list {0}".format(id),
+                        patterns=["some command"])
+        # Now do the same thing with a python function:
+        import side_effect
+        self.runCmd("command script import --allow-reload ./bktptcmd.py")
+
+        self.runCmd("breakpoint command add --python-function bktptcmd.function MyBKPTS")
+        for id in bp_ids:
+            self.expect("breakpoint command list {0}".format(id),
+                        patterns=["bktptcmd.function"])
+        
+        
+
     def test_breakpoint_delete_disabled(self):
         """Test 'break delete --disabled' works"""
         self.build()
Index: lldb/source/Interpreter/ScriptInterpreter.cpp
===================================================================
--- lldb/source/Interpreter/ScriptInterpreter.cpp
+++ lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -109,13 +109,13 @@
 Status ScriptInterpreter::SetBreakpointCommandCallback(
     std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
     const char *callback_text) {
-  Status return_error;
+  Status error;
   for (BreakpointOptions &bp_options : bp_options_vec) {
-    return_error = SetBreakpointCommandCallback(bp_options, callback_text);
-    if (return_error.Success())
+    error = SetBreakpointCommandCallback(bp_options, callback_text);
+    if (!error.Success())
       break;
   }
-  return return_error;
+  return error;
 }
 
 Status ScriptInterpreter::SetBreakpointCommandCallbackFunction(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126730.433241.patch
Type: text/x-patch
Size: 2730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220601/419989f5/attachment-0001.bin>


More information about the lldb-commits mailing list