1

I want to set a breakpoint at an offset within a file.

I can do this fine if I launch the app, check where it is loaded with image list testapp and then add the offset of where in the binary I want the breakpoint e.g.:

breakpoint set -a 0x10100cff4

Is there a way whereby I can set the breakpoint in one go without first checking the offset it is loaded at so that I can automate a task more easily. e.g. something similar to:

breakpoint set -a ((image list -o testapp)+0x100168ff4)

I suspect I could do it with Python however that is not working for me at the moment on Ubuntu so would prefer a way it can be done with lldb commands.

Alternatively, I can add a breakpoint with:

breakpoint set --name function_name

but it is only one instruction I want to break on so still need to add an offset to that address as I then have a command that is performed when it is reached and then resumes.

Thanks

1 Answer 1

1

This is possible with a command like:

breakpoint set -a 0x100168ff4 -s testapp

as from lldb's help breakpoint add, when you specify a module with -s then the address or expression passed with -a:

will be treated as a file address in that module, and resolved accordingly. Again, this will allow lldb to track that offset on subsequent reloads. The module need not have been loaded at the time you specify this breakpoint, and will get resolved when the module is loaded.

With many thanks to Scott Knight for the pointer on this.

2
  • 1
    Shorter syntax b -a 0x100168ff4 -s testapp
    – Kamil.S
    Dec 29, 2021 at 12:36
  • Thanks, I still have a lot to learn :)
    – Jon
    Jan 5 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.