3

Radare2 doesn't update current address, when single-step debugging using ds?

I'm debugging an ELF binary on Linux using single-step (ds). The problem is that the current address at the prompt doesn't update after each step.

The prompt:

enter image description here

How do I make Radare2 update the prompt to reflect the current value of EIP?

Furthermore, is it possible to make Radare2 automatically disassemble the next instruction after each ds, like it is possible with GDB?

2 Answers 2

2

How do I make Radare2 update the prompt to reflect the current value of EIP?

Just use e cmd.prompt = sr PC for it. See question and issue for more details.

Furthermore, is it possible to make Radare2 automatically disassemble the next instruction after each ds, like it is possible with GDB?

Not automatic solution, but you can do pd1 each time you want to see the next instruction to perform.

However, if you want it badly to be automatic, you can modify the source code to perform pd1 automatically for you. To do so, you want to modify libr/core/cmd_debug.c. Just find the place where ds is handled and put relevant code there like so: r2_pd1

Then run make and enjoy the new functionality. r2_pd1_added

0

What you can do is to use pd with the temporary seek operator @ passing rip register so that pd will work from that address.

So instead of pd just use pd@rip and you should be fine with that.

[0x00000000]> pd
    ;-- rsi:
    0x00000000      ff             invalid
    ...


[0x00000000]> pd@rip
    ;-- rip:
    ┌─> 0x10000b3bf      4c892424       mov qword [rsp], r12
    ╎   0x10000b3c3      4489ea         mov edx, r13d
    ╎   0x10000b3c6      4c89f9         mov rcx, r15

Additionally you can use the V!-mode (or any other graphical view mode for that matter) view for debugging. They get automatically updated after you step over your binary.

3
  • Thank you - do you think it is a bug in Radare2? Or what's the reason for not updating the prompt address?
    – Shuzheng
    Commented Dec 11, 2018 at 7:46
  • no. I think your seek position is just unrelated to the rip while debugging. You can imagine doing some stepping and investigating data at some other address. If you seek position changes every time you step it might be also frustrating. Commented Dec 11, 2018 at 7:48
  • But sometimes the prompt address update, e.g. after pressing ds, say, 10 times? Do you know if it is possible to make Radare2 update the prompt address after each ds? Also, do you know if it is possible to make Radare2 automatically disassembly the next instruction after each ds (GDB can do that)?
    – Shuzheng
    Commented Dec 11, 2018 at 7:51

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.