6

How can i save/reuse/preserve Radare2 metadata (BPs, comments, flags..) of a debug session for a new debug session? I restart the debugger alot and preserving environment would be very helpful.

I start with r2 -d binary -r myenv.rr2 -i myscript.r2s, create some flags, comments and such and then exit with q. ood usually is not enough (weird errors about fds and such. I quit completely most of the time). But if i try to load my project (Po) its asks me to restart the session and then i'm in a wrong context/process or something.

[0x7f7d020fb2c0]> Po myproject
Close current session? (Y/n) 
WARNING: module's base addr + delta is not a valid address
[0x7f8baef752c0]> dc
native-singlestep: No such process
Stepping failed!
1
  • 1
    Were you able to find a solution for this? I am currently trying to figure out how to persist comments between debug sessions.
    – peachykeen
    Commented Feb 28, 2020 at 17:06

1 Answer 1

0

Commands starting with P is what you seek.

Usage: P[?.+-*cdilnsS] [file]  Project management
| P [file]          open project (formerly Po)
| P.                show current loaded project (see prj.name)
| P+ [name]         save project (same as Ps, but doesnt checks for changes)
| P- [name]         delete project
| P*                printn project script as r2 commands
| P!([cmd])         open a shell or run command in the project directory
| Pc                close current project
| Pd [N]            diff Nth commit
| Pi [file]         show project information
| Pl                list all projects
| Pn -              edit current loaded project notes using cfg.editor
| Pn[j]             manage notes associated with the project
| Ps [file]         save project (see dir.projects)
| PS [file]         save script file
| PS* [name]        print the project script file (Like P*, but requires a project)
| Pz[ie] [zipfile]  import/export r2 project in zip form (.zrp extension)
| NOTE:             the 'e prj.name' evar can save/open/rename/list projects.
| NOTE:             see the other 'e??prj.' evars for more options.
| NOTE:             project are stored in dir.projects

Example of save/restore session:

$ r2 -
[0x00000000]> f myflag = 0xdeadbeef
[0x00000000]> Ps myproject
[master (root-commit) cbcd6c2] default message
 Author: dacav <dacav@localhost>
 1 file changed, 687 insertions(+)
 create mode 100644 rc.r2
[0x00000000]> q

Starting a new session:

$ r2 -
[0x00000000]> Pl
myproject
[0x00000000]> P myproject
[0x00000000]> f | grep myflag
0xdeadbeef 0 myflag

The project saving is done using git, as suggested by the Ps output. I think using git is a great idea, and I like how Pd can tell what happened in a project over time.

Projects are saved under the directory pointed by the dir.projects configuration variable.

Also, the original question is quite old, and even trying Po will result in a deprecation warning these days.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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