To use gdb to debug your program, you can start the debugger, and give it as an option the full name of your program:
gdb helloOr, under DOS :
gdb hello.exe
This starts the debugger, and the debugger immediately loads your program into memory, but it does not run the program yet. Instead, you are presented with the following (more or less) message, followed by the gdb prompt '(gdb)':
GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see the conditions. There is absolutely no warranty for GDB; type "show warranty" for details. GDB 4.15.1 (i486-slackware-linux), Copyright 1995 Free Software Foundation, Inc... (gdb)To start the program you can use the run command. You can optionally specify command-line parameters, which will then be fed to your program, for example:
(gdb) run -option -anotheroption needed_argumentIf your program runs without problems, gdb will inform you of this, and return the exit code of your program. If the exit code was zero, then the message 'Program exited normally'.
If something went wrong (a segmentation fault or so), gdb will stop the execution of your program, and inform you of this with an appropriate message. You can then use the other gdb commands to see what happened. Alternatively, you can instruct gdb to stop at a certain point in your program, with the break command.
Here is a short list of gdb commands, which you are likely to need when debugging your program:
for more information, see the gdb users' guide, or use the 'help' function in gdb.
The appendix F contains a sample init file for gdb, which produces good results when debugging Free Pascal programs.