GDB Commands

Here are some useful GDB commands. For more information on these commands try typing help command into GDB. To find out about other potential useful commands, try typing help into GDB.

Breakpoints

break fn

Set a breakpoint at entry to function fn.

break *ADDRESS

Set a break point at a line of assembly.

delete n

Delete breakpoint n.

delete

Delete all breakpoints.

Execution

si n

Step forward n assembly instruction, entering into function calls.

ni n

Step forward n assembly instruction, skipping over function calls.

continue

Resume execution

Examining data

print $eax

Print contents of register %eax in decimal.

print /x $eax

Print contents of register %eax in hex.

print /t $eax

Print contents of register %eax in binary.

print /x ($eax + 8)

Print contents of memory address %eax + 8 in hex.

print *(int *) (($eax + 8))

Print contents of memory address %eax + 8 as an integer

x ADDRESS

Print the value at a memory address. x/d ADDRESS will print the value as an integer; x/i ADDRESS as an instruction; x/s ADDRESS as a string. x/8xw ADDRESS will print 8 four-byte words in hexadecimal format. Note that ADDRESS can be written as a formula, e.g. $esp + 4. Try help x for more information.

info registers

Print the values in the registers.

info frame

Print information about the current stack frame.

Examining code

disas

Disassemble the current function.

disas fn

Disassemble function fn.

print /x $eip

Print the program counter in hex

Other useful commands

quit

run

kill

help