From 97ded15bdb39658a1f60eb16d5e92e072ed4dc59 Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Sun, 4 Jul 2021 00:00:38 +0300 Subject: [PATCH] Add xxd commmand to gdb --- .gdbinit | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.gdbinit b/.gdbinit index 1074e29..b277c32 100644 --- a/.gdbinit +++ b/.gdbinit @@ -39,3 +39,22 @@ set mem inaccessible-by-default off # define target remote # bmconnect /dev/ttyBmpGdb # end + + +define xxd + if $argc < 2 + set $size = sizeof(*$arg0) + else + set $size = $arg1 + end + dump binary memory dump.bin $arg0 ((void *)$arg0)+$size + eval "shell xxd -o %d dump.bin; rm dump.bin", ((void *)$arg0) +end +document xxd + Dump memory with xxd command (keep the address as offset) + + xxd addr [size] + addr -- expression resolvable as an address + size -- size (in byte) of memory to dump + sizeof(*addr) is used by default +end