Debugging - C - C++

Debug Process

  1. cc -g factorial.c # compile the program with the debugging flag enabled
  2. gdb a.out # enter the debugger for the compiled binary
  3. break 10 # set up breakpoint at line number 10
  4. run # run the program with debugger
  5. p i # Prints the i variable
  6. n # step through individual lines (treating function calls as single line)
  7. s # step through individual lines without treating functions as single instruction
  8. c # continue executing binary til next breakpoint