The GNU Debugger is pretty handy when developing applications in C for the Linux platform. Using it is pretty simple...
Compiling for Debug
Compile your program with gcc, adding a "-g" option to include debugging symbols
Example: gcc -g nitin.c
Run with Debugger
Execute GDB, providing the executable as a parameter
Example: gdb a.out
Start Execution
Get into the main method by typing "start main" followed by any parameters
Example: start main hello
Step Through
Go line-by-line by typing "n" or "next"
Watch
Display variable values using the "print" command
Example: print argv[1]
Breakpoints
Set a breakpoint with the "b" or "break" command followed by the filename:line number
Example: b nitin.c:25
Continue
Run till the next breakpoint using "c" or "continue"
End
Press Ctrl+C to stop execution, and "q" or "quit" to close GDB.
Friday, January 23, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment