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
- n – execute the next instruction
- b – to put a break-point on current line
- c – continue execution till next break-point
- info breakpoints – to look all breakpoints
- info args – to check argument values in current function
- info locals – to check local value in a function
- set print elements 20000 – to avoid truncation of values printing
- set print array-indexes on
- set print array on
- set print pretty on
- set variable i = 10 – change a variable value in gdb