vimwiki

Basic Guide to Debugging with GDB

Debugging with GDB (GNU Debugger) is an essential tool for finding and fixing errors in your code. Here’s a basic guide to help you get started:

Compiling and Running the Program

  1. Compile with debugging information: gcc -g -o program program.c
  2. Start gdb with the program: gdb program
  3. Set a breakpoint: break [function/line number]
  4. Run the program: run [arguments]

Controlling Program Flow

Information Commands

Data Manipulation

Miscellaneous Commands

To quit gdb, simply type quit.