Chitika

Tuesday, June 25, 2013

GDB hex dump

Create file in home folder, named '.gdbinit', and put following contents in it:

define xxd
dump binary memory dump.bin $arg0 $arg0+$arg1
shell xxd dump.bin
end


during debugging execute following command to get hex dump of any memory area, by specifying starting address (or name of variable) and length:

(gdb) xxd var 112
0000000: aabb ccdd eeff 0011 2233 4455 6677 8899 ................
0000010:
aabb ccdd eeff 0011 2233 4455 6677 8899 ................
0000020:
aabb ccdd eeff 0011 2233 4455 6677 8899 ................
0000030:
aabb ccdd eeff 0011 2233 4455 6677 8899 ................
0000040:
aabb ccdd eeff 0011 2233 4455 6677 8899 ................
0000050:
aabb ccdd eeff 0011 2233 4455 6677 8899 ................
0000060:
aabb ccdd eeff 0011 2233 4455 6677 8899 ................



Ref:

http://stackoverflow.com/questions/9233095/memory-dump-formatted-like-xxd-from-gdb
http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_chapter/gdb_18.html#SEC195

No comments:

Post a Comment