GDB old - Opty-Forks/SSof GitHub Wiki

GDB Basics

Below is a simple list of basic GDB commands. They should get you going for most of our exercises

  • gdb ./file --- open GDB to debug file
  • disas function --- disassemble function function
  • disas address --- disassemble function at this address
  • b address --- inserts a breakpoint at address address
  • r < file --- run the program with input file
  • s --- execute next step of program
  • c --- execute until the next breakpoint of the program
  • p expr --- prints the value expr. expr can be a var, the pointer to a var (its address), a register, etc. It can even be address1 - address2 and in this case returns the difference between the addresses.
  • info f --- returns the info of a frame. Particularly usefull whenever you need to know where the return address of the function is stored and/or the value contained there.
  • stack n --- show the n registers after the stack pointer
  • x/nx $rsp --- show the n registers after the register $rsp
  • x/nx address --- show the n registers after the address address