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.
Set a breakpoint at entry to function fn.
Set a break point at a line of assembly.
Delete breakpoint n.
Delete all breakpoints.
Step forward n assembly instruction, entering into function calls.
Step forward n assembly instruction, skipping over function calls.
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
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.
Print the values in the registers.
Print information about the current stack frame.
Disassemble the current function.
Disassemble function fn.
print /x $eip
Print the program counter in hex
Other useful commands