Abridge GDB Commands
Abridge GDB Commands
@start gdb
$gdb executable-file OR $ gdb
@ help of a command
gdb) help (general class help) gdb) h disas (about disassemble
command)
gdb) h b (about breakpoints) gdb) h list (about listcommand)
@run program
gdb)r (run till end , or next breakpoint) use c -continue between
breakpoints
gdb)c n (run continue skipping n-1 breakpoints)
gdb)s (run next source line)
gdb)si n (run next n machine instruction)
gdb)ni (run next machine instruction,including function)
gdb)n n (run next n source instruction,including function)
gdb)where (shows the source file line number currently to be executed next)
@set value
gdb)set variable=exp ; set address=val ((assign value at address of
val )
gdb)set $cpsr=0x80000010 ( flag set)
gdb)set $pc=0x10088 (pc changed to given address, like jump)
gdb)set $r1=&val (assign address of val to r1) or set $r1=5 (assign value to
r1)
gdb set {int}0x201bc=0x11223344 (update memory contents/instruction)
set *(int *)0x201bc=0x11223344 (update memory contents/change instruction)
set {char[3]}0x201bc ="AA";(gdb) x/x 0x201bc :0x42004141
set {char[4]}0x201bc ="AAB";(gdb)x/x 0x201bc :0x00424141
set *(char *)0x8074=0x88 ; change a byte
@print value
gdb)format p/f exp
where f is type x(hexa), d(decimal,default),u(unsigned
decimal),o(octal),t(binary),a(address),c(character),f(float)
gdb)p $r1 (value in r1 in decimal) gdb)p/x $pc (value in r15 in hex)
gdb)p/t $cpsr (value in cpsr in binary) gdb)p/x &val (address of val
in hex)
@examine memory
gdb)format x/nuf exp ; n- number of; f-format as given in print
where u is SIZE b(byte), h(half word),w(word),g(giant),o(128-bit),s(null
terminated string),i(machine inst, default)
gdb)x 0x10074 (show machine instruction at given address)
gdb)x/4i 0x10074 (4 machine instructions at given address) x/4i $pc (4
inst from current pc)
gdb)x/16x 0x10074 (show 16 words from given address)
gdb)x/6 $sp (6 words in memory pointed by sp onwards) can use +/- number
with register
gdb)x/x &var (display address and value of variable)
gdb)x/2x &_start( display memory contents 2 words in hex starting from label
_start)
gdb) x/s 0x80c2 (shows the string starting from given address)
@quit gdb
gdb)q
ref:https://sourceware.org/gdb/current/onlinedocs/gdb/