When radare2 analyzes a function, it gives local variables names such as local_4h
for ebp - 0x4
. It also offers the ability to give these variables more meaningful names when their purpose becomes clear. However, after the variables are renamed it becomes more difficult to print them. When I see an instruction such as mov eax, dword [ebp - i]
I have to
- Look at the top of the disassembly to find the line
var int i @ ebp-0xc
- Type
pxw @ebp-0xc
- Read off the value of
i
from the first of 16(!) lines of output - Find my place again in the disassembly after it was shifted from the last command
It's not a lot of work, but when when I'm looking through lots of assembly with many variables it becomes tedious quite quickly.
As a follow-up question, is it possible to print a variable/location each time execution stops at a breakpoint, like with GDB's display
command?
Instead of
pxw @ local_4h
, there isafvd
(analyze function variables display), which lists every or a particular variable:afvd name
returns the r2 command to display the variable 'name'. The dot at the beginning executes the command.Remember that you can always use the
?
command to get help:Actually there is also the possibility to use (almost) the same syntax like in your question. However the variable names have to be added as flags beforehand and this has to be done every time you enter a function.