Search code examples
c++clldb

Saving breakpoints after re-sourcing binary


I have a small work environment related doubt. I am analyzing a binary in LLDB and sometimes, I need to make some changes in the code and re-compile it. And then re-source the new binary into LLDB for further analysis.

Currently, I am doing this

  1. Inside LLDB, use shell <shell-command> to compile the code.
  2. Use file <binary> to reload the binary.

But in this way, I am losing the breakpoints. So, is there any way I can save breakpoints?


Solution

  • Couple of things.

    First off, if you are recompiling the binary at the same path you used for your current lldb target, then you don't need to make a new target. lldb will notice the file has changed when you do run read in the new binary & debug information, reset the breakpoints, etc.

    But if there are other reasons why you need to make a new target, lldb has breakpoint write and breakpoint read commands that allow you to serialize the breakpoints to a file and then read them back into a new target.