debugginggdbremote-debugginggdbserver

save pointer to variable with gdb script


I using gdb script to print some char** like:

print *(char**) $r0

I want to save the address to variable that I can use that address in the next breakpoint

How can I do that using gdb-script or gdb-python ?

For example

b *BREAK_POINT_1
commands
set ADDR = *(char**) $r0
c
end

b *BREAK_POINT_2
commands
x/100x ADDR
c
end

Solution

  • I want to save the address to variable that I can use that address in the next breakpoint

    (gdb) set var $addr = (char*)0x1234
    (gdb) p $addr
    $1 = 0x1234 <error: Cannot access memory at address 0x1234>
    

    So your case, you want:

    (gdb) set var $ADDR = *(char**) $r0
    

    Documentation.