GDB Cheatsheet

# setting to get core dumps through gdb
ulimit -c unlimited

; disable stack protections compile-time
gcc -fno-stack-protector -z execstack blame.c -o blame

; syscalls
/usr/include/asm/unistd_64.h

gcc -g -static foo.c -o foo

; obtain asm code
gcc -S foo.c -o foo 

; Basics
gdb foo
disas main
disas my_gcc_code_compiled_to_binary
list
watch x				# check variable
rwatch x

; Start debugging
gdb -q a.out

; Moving around code
break main 			# or line number from gdb>list
step / next
run
# Setting a breakpoint
break 0x666666
brek *0xoff

; Getting information
info files
info registers
info register rip
info proc

bt
list
dis main
disas 0x666666,+50
# register information

; Getting detailed information
print foobar
x/s 0x40060
x/h 0x40060
x/b foobar
x/20i $pc
x/s $rsp
x/256xb $esp