The debugger is in the bin\win32 or bin\dos directories (the GDB.EXE file), for the Windows and DOS versions respectively. It usually comes already installed in most Linux distros.
(Note: all commands should be typed without quotes and then [return] must be pressed.)
- Compile the sources using the -g cmd-line option to add debugging support.
- Load it in GDB using: "gdb myapplicationname.exe"
- Set the arguments to the application been debugged using: "set args arg1 arg2 argn". You can also run GDB and pass the arguments directly to the application been debugged: "gdb --args myapp.exe arg1 arg2 arg3".
- If the executable isn't in the same directory of the source files where it was compiled, type: "dir path/to/my/application/sources".
- Place a breakpoint in the first line using: "b main". To place a breakpoint in a function called "abc" use: "b ABC" (note: all in uppercase, GDB is case sensitive by default, but you can use the "set language pascal" command to change GDB to case-insensitive mode).
- Type "r" to start the application.
- Type "n" to step over function calls. Keep pressing [return] to skip to the next line.
- Type "s" to step into function calls. Same as above.
- Type "c" to continue execution until the next breakpoint.
- Use "print ABC" to show the contents of the variable called "abc". GDB supports pointer/pointer field dereferencing, indexing and arithmetics too, so "print *MYPOINTER" will also work. (note: undeclared variables or the ones with suffixes like % & ! # $ can't be printed).
- Use "disp ABC" to display the contents of a variable called "abc".
- Use "watch ABC" to stop each time a variable called "abc" is changed.
- Use "r" again to restart the application when finished.
- Type "q" to quit.
- Type "help" to see a list of commands, there are many others.