diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp --- a/lldb/source/Interpreter/ScriptInterpreter.cpp +++ b/lldb/source/Interpreter/ScriptInterpreter.cpp @@ -109,13 +109,13 @@ Status ScriptInterpreter::SetBreakpointCommandCallback( std::vector> &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 --- a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ b/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()