gdbgdbserver

Print buffer in gdb relative to register


In GDB when I want to print 10 bytes from r1 register :

x/10x $r1

But how can I print number of bytes that store in r5 register?

x/$r5 $r1

Is incorrect


Solution

  • GDB parses the count portion of the FMT argument to x as a string of digits (whatever the C atoi function accepts). To insert the integer value of a register - or any other expression - there, you can use eval:

    eval "x/%dxb $r1", $r5