0

In gdb I have this define in order to skip one line

define skip
    tbreak +1
    jump +1
end

Can one do the same with lldb?

brian0
  • 95
  • 8

1 Answers1

0

lldb doesn't have a define. One option is creating an lldb script with the commands you want. From there, you can define an alias named skip that runs the commands.

For example, here's the contents of a file named ~/scripts/lldb/skip:

tbreak +1
jump +1

To run this script, do:

command source ~/scripts/lldb/skip

To make this more convenient, you can create an alias in your ~/.lldbinit:

command alias skip command source ~/scripts/lldb/skip
Dave Lee
  • 6,299
  • 1
  • 36
  • 36
  • ok, thanx, but my problem is that apparently lldb does not accept the line specification "+1" relative to the "current line number". Sometimes I keep single-stepping (next) and I know that there is a function call or something that causes problems, so I just wanto to skip the next line of code. Of course one could provide the absolute line number (tbreak 1234 followed by jump 1234), but it's just a little less convenient. – brian0 May 17 '20 at 20:37
  • `jump +1` does work. But if you're jumping a line like that, why do you need the `tbreak`? – Dave Lee May 17 '20 at 21:17
  • 1) my version of lldb (lldb-900.0.45) gives an error on "jump +1". – brian0 May 18 '20 at 13:26
  • 2) the reason for doing that is: -- I've stopped at line 100 (line 100 will be executed if I do "next"). -- I want to skip statement at line 100 and resume single-stepping at line 101. -- So I place a tmp breakpoint at line 101 and jump to it. PS. The error I get is (lldb) jump +1 error: invalid line offset: '+1'. – brian0 May 18 '20 at 13:37
  • 1
    The "real" command for moving the PC is `thread jump`. `jump` is a fancy alias. For offset by line, try `thread jump -b 1`. Apparently someone changed the "integer parsing" routine that `thread jump -b` uses recently so that it accepts "-N" and "N" but it no longer accepts "+N". However, they didn't update the alias. The underlying command works still works (and N always meant forwards...) so `thread jump -b 1` should work correctly on any lldb version. I filed a bug about this. – Jim Ingham May 18 '20 at 19:19
  • 1
    @Jim that works, thanks. And I don't need the tbreak, since lldb's "jump" (unlike gdb's) does not include an implicit "continue" command. Now I also understand Dave's question (why do you need the tbreak?). Fact is, in gdb jump = "jump and continue", so I assumed the same behavior in lldb. – brian0 May 18 '20 at 20:12
  • 1
    Yeah, I thought it would be more convenient - particularly when jumping source lines - to give users the chance to make sure that the jump went where they expected before continuing. And this isn't such a common activity (since it is actually pretty dangerous) that the extra continue was likely to be a burden. – Jim Ingham May 18 '20 at 21:04