Skip to content

Commit d92f7f7

Browse files
committed
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
1 parent ca73de4 commit d92f7f7

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

lldb/source/Interpreter/ScriptInterpreter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ ScriptInterpreter::StringToLanguage(const llvm::StringRef &language) {
109109
Status ScriptInterpreter::SetBreakpointCommandCallback(
110110
std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
111111
const char *callback_text) {
112-
Status return_error;
112+
Status error;
113113
for (BreakpointOptions &bp_options : bp_options_vec) {
114-
return_error = SetBreakpointCommandCallback(bp_options, callback_text);
115-
if (return_error.Success())
114+
error = SetBreakpointCommandCallback(bp_options, callback_text);
115+
if (!error.Success())
116116
break;
117117
}
118-
return return_error;
118+
return error;
119119
}
120120

121121
Status ScriptInterpreter::SetBreakpointCommandCallbackFunction(

lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,34 @@ def breakpoint_commands_on_creation(self):
283283
self.assertEqual(com_list.GetStringAtIndex(1), "thread list", "Next thread list")
284284
self.assertEqual(com_list.GetStringAtIndex(2), "continue", "Last continue")
285285

286+
def test_add_commands_by_breakpoint_name(self):
287+
"""Make sure that when you specify a breakpoint name to "break command add"
288+
it gets added to all the breakpoints marked with that name."""
289+
self.build()
290+
target = self.createTestTarget()
291+
292+
bp_ids = []
293+
bp_names = ["main", "not_here", "main"]
294+
for bp_name in bp_names:
295+
bp = target.BreakpointCreateByName(bp_name)
296+
bp.AddName("MyBKPTS")
297+
bp_ids.append(bp.GetID())
298+
# First do it with a script one-liner:
299+
self.runCmd("breakpoint command add -s py -o 'print(\"some command\")' MyBKPTS")
300+
for id in bp_ids:
301+
self.expect("breakpoint command list {0}".format(id),
302+
patterns=["some command"])
303+
# Now do the same thing with a python function:
304+
import side_effect
305+
self.runCmd("command script import --allow-reload ./bktptcmd.py")
306+
307+
self.runCmd("breakpoint command add --python-function bktptcmd.function MyBKPTS")
308+
for id in bp_ids:
309+
self.expect("breakpoint command list {0}".format(id),
310+
patterns=["bktptcmd.function"])
311+
312+
313+
286314
def test_breakpoint_delete_disabled(self):
287315
"""Test 'break delete --disabled' works"""
288316
self.build()

0 commit comments

Comments
 (0)