gcc -S foo.c
gcc -Wa,--gstabs, foo.s gcc -g foo.s
gdb ./a.out
b main (easy way to find start of program)
r (run till breakpoint)
info registers (shows all registers)
p/x $eax (shows register eax in hex)
p/t $-16 (shows the number 16 in binary)
display/i $pc print instruction as you go
gdb to save its history set history save on
.gdbinit in the directory you are working in
--args command... gdb --args ./mpg123 -C -a /dev/dsp1 /share/music/Trance/*
break <line # or function name> clear <line #, filename:line#, function> delete
delete 2
disable
esp: x/40 ($esp - 10)
set {int}0x7fbffff71c = 4 sticks 4 at the shown memory location
n
s
run
c
finish
bt
p <variable> p/x <variable> x &<variable>
display <value>
undisplay
sse registers in hex: p/x $xmm0
x/2d $rsp - print two 4-byte words starting at address in $rsp in decimal
x/g $rsp - print one 8-byte word starting at address in $rsp.
x/gd $rsp - print one 8-byte word starting at address in $rsp in decimal
x/20b sum - print first 20 opcode bytes of function sum
x/10i sum - print first 10 instructions of function sum
info registers
l with... gdb to catch a signal, but also let the debugged program catch it handle SIGINT pass