GDB useful commands for C-program debugging

To debug a C-program in gdb, compile the program and use the following command to enter into gdb mode in linux terminal –

gdb ./your_program

  1. n – execute the next instruction
  2. b – to put a break-point on current line
  3. c – continue execution till next break-point
  4. info breakpoints – to look all breakpoints
  5. info args – to check argument values in current function
  6. info locals – to check local value in a function
  7. set print elements 20000 – to avoid truncation of values printing
  8. set print array-indexes on
  9. set print array on
  10. set print pretty on
  11. set variable i = 10 – change a variable value in gdb

Leave a Reply

Your email address will not be published. Required fields are marked *