Skip to content

Conversation

@jimingham
Copy link
Collaborator

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.

file line & column breakpoint through `run_break_set`.
@llvmbot
Copy link
Member

llvmbot commented Dec 8, 2025

@llvm/pr-subscribers-lldb

Author: None (jimingham)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/171206.diff

2 Files Affected:

  • (modified) lldb/source/Commands/CommandObjectBreakpoint.cpp (+1-1)
  • (modified) lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py (+19)
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):

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

⚠️ Python code formatter, darker found issues in your code. ⚠️

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

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

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

@jimingham jimingham requested review from JDevlieghere and medismailben and removed request for JDevlieghere December 8, 2025 21:56
@jimingham jimingham merged commit 0ce6d56 into llvm:main Dec 8, 2025
11 of 12 checks passed
@jimingham jimingham deleted the column-is-u branch December 8, 2025 22:34
honeygoyal pushed a commit to honeygoyal/llvm-project that referenced this pull request Dec 9, 2025
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants