[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 15:51:49 PDT 2022
jingham created this revision.
jingham added reviewers: kastiglione, JDevlieghere.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
This was a "probably should have copy-pasted" error. A "!" was omitted in copying over the code that added the command for a python function to the code that did the same for a python one-liner. I also added a test for both adding python functions and one-liners.
Repository:
rG LLVM Github Monorepo
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.433215.patch
Type: text/x-patch
Size: 2730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220531/829fb4fb/attachment.bin>
More information about the lldb-commits
mailing list