Search code examples
c++cdebugginggdblldb

How to get LLDB to print current line


When running GDB, the debugger would print the current line it's at to give you an indication of where it's currently at.

Seeing as I'm on Mavericks, GDB doesn't seem to be an option, and as such I'm forced to use LLDB. My question is: How do I get similar behaviour from LLDB?

Currently all it does is print 7 or-so lines of code with an arrow pointing at the current line, rather than just printing the line it's on, which is rather cluttered to look at. LLDB also seems to ignore all output produced by printf

Is there a way to achieve the same, or similar results using LLDB?


Solution

  • I don't think the question you asked is exactly what you intended. I assume you mean "How to get LLDB to print ONLY the current line" since, as you noted, it always prints the current line along with some lines of context.

    Anyway, how many lines of source get printed when you stop is controlled by the two settings:

      stop-line-count-after    -- The number of sources lines to display that come after the current source line when displaying a stopped context.
      stop-line-count-before   -- The number of sources lines to display that come before the current source line when displaying a stopped context.
    

    Actually these aren't quite right, since setting both to 0 shows no source lines, but setting "after" to 1 shows TWO stop lines. Somebody apparently wanted to make it possible to show NO source lines, but didn't want to add an extra setting.

    Anyway, you can't get just one line, but you can get it down to two.