Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading