Author: Jim Ingham Date: 2022-05-31T17:24:14-07:00 New Revision: d92f7f790c8e74bf796a0313cb296d726628142e
URL: https://github.com/llvm/llvm-project/commit/d92f7f790c8e74bf796a0313cb296d726628142e DIFF: https://github.com/llvm/llvm-project/commit/d92f7f790c8e74bf796a0313cb296d726628142e.diff LOG: Fix a copy-paste error in "br com add -s py -o 'some_python' BKPT_NAME" The function that was supposed to iterate over all the breakpoints sharing BKPT_NAME stopped after the first one because of a reversed "if success" condition. Differential Revision: https://reviews.llvm.org/D126730 Added: Modified: lldb/source/Interpreter/ScriptInterpreter.cpp lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py Removed: ################################################################################ diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp index fbdcbb8da868..bc8a542afc87 100644 --- a/lldb/source/Interpreter/ScriptInterpreter.cpp +++ b/lldb/source/Interpreter/ScriptInterpreter.cpp @@ -109,13 +109,13 @@ ScriptInterpreter::StringToLanguage(const llvm::StringRef &language) { 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( diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py index 508a8d9eec32..7a47062de985 100644 --- a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -283,6 +283,34 @@ def breakpoint_commands_on_creation(self): 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() _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits