-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Fix a typo in "breakpoint add file" and add a test #171206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
file line & column breakpoint through `run_break_set`.
|
@llvm/pr-subscribers-lldb Author: None (jimingham) Changeslldbutil.run_to_line_breakpoint had usages that set column breakpoints, so I thought there was coverage of that on the command-line, but actually all the This patch fixes that typo and adds a CLI test for file + line + column. Full diff: https://github.com/llvm/llvm-project/pull/171206.diff 2 Files Affected:
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index fbd6ca44db950..75dc890cc40ed 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -767,7 +767,7 @@ class CommandObjectBreakpointAddFile : public CommandObjectParsed {
m_cur_value.SetLine(line_num);
}
break;
- case 'c':
+ case 'u':
uint32_t column_num;
if (option_arg.getAsInteger(0, column_num))
error = Status::FromError(
diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py b/lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
index 5798c8ffa8220..1f5718149b3e3 100644
--- a/lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
+++ b/lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
@@ -27,6 +27,25 @@ def testBreakpointByLineAndColumn(self):
in_then |= b_loc.GetColumn() == 50
self.assertTrue(in_then)
+ def testBreakpointByLineAndColumnUsingCLI(self):
+ self.build()
+ src_file = lldb.SBFileSpec("main.cpp")
+ line = (
+ line_number("main.cpp", "At the beginning of a function name (col:50)") + 1
+ ) # Next line after comment
+ target, process, _, _ = lldbutil.run_to_source_breakpoint(self, "This is a random comment", src_file)
+ bkpt_no = lldbutil.run_break_set_by_file_and_line(self, "main.cpp", line, "--column 50")
+ breakpoint = target.FindBreakpointByID(bkpt_no)
+ threads = lldbutil.continue_to_breakpoint(process, breakpoint)
+ self.assertEqual(len(threads), 1, "Stopped at our breakpoint")
+ self.expect("fr v did_call", substrs=["1"])
+ in_then = False
+ for i in range(breakpoint.GetNumLocations()):
+ b_loc = breakpoint.GetLocationAtIndex(i).GetAddress().GetLineEntry()
+ self.assertEqual(b_loc.GetLine(), line)
+ in_then |= b_loc.GetColumn() == 50
+ self.assertTrue(in_then)
+
## Skip gcc version less 7.1 since it doesn't support -gcolumn-info
@skipIf(compiler="gcc", compiler_version=["<", "7.1"])
def testBreakpointByLine(self):
|
You can test this locally with the following command:darker --check --diff -r origin/main...HEAD lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
View the diff from darker here.--- TestBreakpointByLineAndColumn.py 2025-12-08 21:24:29.000000 +0000
+++ TestBreakpointByLineAndColumn.py 2025-12-08 21:29:25.727562 +0000
@@ -31,12 +31,16 @@
self.build()
src_file = lldb.SBFileSpec("main.cpp")
line = (
line_number("main.cpp", "At the beginning of a function name (col:50)") + 1
) # Next line after comment
- target, process, _, _ = lldbutil.run_to_source_breakpoint(self, "This is a random comment", src_file)
- bkpt_no = lldbutil.run_break_set_by_file_and_line(self, "main.cpp", line, "--column 50")
+ target, process, _, _ = lldbutil.run_to_source_breakpoint(
+ self, "This is a random comment", src_file
+ )
+ bkpt_no = lldbutil.run_break_set_by_file_and_line(
+ self, "main.cpp", line, "--column 50"
+ )
breakpoint = target.FindBreakpointByID(bkpt_no)
threads = lldbutil.continue_to_breakpoint(process, breakpoint)
self.assertEqual(len(threads), 1, "Stopped at our breakpoint")
self.expect("fr v did_call", substrs=["1"])
in_then = False
|
lldbutil.run_to_line_breakpoint had usages that set column breakpoints, so I thought there was coverage of that on the command-line, but actually all the `run_to` utilities use the SB API's, and there weren't any tests of setting file line & column breakpoint through `run_break_set`. So I missed that I had typed the column option `c` - that's taken by `--command`. This patch fixes that typo and adds a CLI test for file + line + column.
lldbutil.run_to_line_breakpoint had usages that set column breakpoints, so I thought there was coverage of that on the command-line, but actually all the
run_toutilities use the SB API's, and there weren't any tests of setting file line & column breakpoint throughrun_break_set. So I missed that I had typed the column optionc- that's taken by--command.This patch fixes that typo and adds a CLI test for file + line + column.