Home > Mobile >  LLDB aborts breakpoint command execution after `step`, `next` etc
LLDB aborts breakpoint command execution after `step`, `next` etc

Time:12-28

When I hit a breakpoint in LLDB I want to execute multiple commands that automatically step my program.

Example (this should alter the program to skip the first call made by foo::bar):

breakpoint set --method foo::bar --command s --command 'thread return'

When I try the above example:

  1. I do hit the breakpoint
  2. s is executed
  3. But then the following is printed: error: Aborting reading of commands after command #1: 's' continued the target. and thread return is not executed

CodePudding user response:

lldb does "programmed steps" differently from gdb. In lldb, if you want to cons up a "step, check something, step again" type operation, you do that by implementing your own version of a step command, using the same functionality as the built-in lldb step/next/etc operations. Then you add that as a new command alongside the lldb step commands, and invoke it as you would the built-in step commands. You can even pass arguments to it on each invocation, and use them in your step. Multiple such operations can be in flight at a time, and they also nest naturally.

Here are the details for scripted steps:

https://lldb.llvm.org/use/python-reference.html#using-the-python-api-to-create-custom-stepping-logic

In your case, you would use the fancy step as the final operation in your breakpoint command.

lldb's breakpoint callbacks stop on the first command that causes the target to run by design. It doesn't need to support that complexity since users can do the same thing with scripted steps, so it took the opportunity not to.

  • Related