Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C/GDB: display contents of address

Tags:

c

debugging

gdb

I have this address, 0x8002bf20, and I need to see what's inside there. I know GDB does nice things like "print x" and I'll see something like struct ex {x: 1, y: 2}

I need to see that kind of print output for this address I need to examine.

Thanks.

like image 377
JDS Avatar asked Feb 28 '12 04:02

JDS


1 Answers

If you know the type of the structure at that address, you can coerce GDB to print it with:

(gdb) print *(struct mystruct *) 0x8002bf20

If you do not know the type of the structure, then the best you can do is the x command which you already mentioned -- although do be aware that there's no harm in casting to the 'wrong' type, so you can try various structures with print *(struct mystruct *) until the output looks plausible.

like image 110
Eric Melski Avatar answered Sep 19 '22 23:09

Eric Melski