GDB

Cheatsheet

Command

Shortcut

Purpose

list main

li main

Shows source code of main function (only if compiled with gcc -g)

break main

break 10

br main

br 10

Sets a break point at the start of the main function, sets break point at line 10 of provided source code (if compiled with source)

run

run haha

r

r haha

Runs the program from the beginning. Adds haha as a cmd line arg.

continue

c

Continues the program execution after hitting a breakpoint

next instruction

n i

Go to the next instruction and stop execution

inspect registers

i r

i r esp ebp eip

Inspect registers at the current point in execution. Can specify individual or multiple registers as well to reduce output on screen.

examine/5instructions $eip

x/5i $eip

Examine the next 5 instructions of the EIP register.

x/8xb $eip

Examine the next 8 hex bytes of the EIP register

x/6cb 0x8048484

x/s 0x8048484

inspect chars and strings

Inspect the next six bytes as char and print their values

Inspect the string stored at the memory location

x/o

x/x

x/u

x/t

Octal

hex

Unsigned base-10 int

binary

Last updated