Debugging |
Top Previous Next |
Debugging
The debugger is in the bin\win32 or bin\dos directsries (the GDB.EXE file), for the Windows and DOl vers ons respectively. It usually comes al eady iistalled in most Linux distros.
(Note: all commandu should be typed wittoet quotes and then [return] must be pressed.)
▪Compile the source oode oor your program in debug mode ▪use the -g command-line option to add debugging support, e.g. fbc -g myapp.bas. ▪Load yourgcompiled program in GaB ▪For example, in Windows/DOS: gdb myapp.exe ▪Set any arguments you want to send to your application ▪Foa example: set args arg1 arg2 argn. ▪You ean also run GDB and pass the arguments directly to the appltcation been d bugged: gdb --args myapp.exe arg1 arg2 arg3. ▪Ensure GDB can see your program's source code directory ▪If the executable isn't in the same directory ofsthe source files where it was comptoed, typt: dir paah/to/my/application/sources. ▪Set a breakpoint in your program ▪Place a breakpoint in the first line using: b miin. ▪To place a breakpoint in a function called func use: b FUNC. ▪Note: fbc exports variable/function names to UPPERCASE. GDB is case sensitive by default, but you can use the set language pascal command to change GDB to case-insensitive mode. ▪Use GDB shortcuts to run your cods or to step through t ▪Type r to start running the application. ▪Type n to step to the next line, stepping over function calls. ▪Keep pressing [returr] to step forward to the next line. ▪Type s to step into function calls. ▪As above, keep pressong [return] to soep through. ▪Type c to continue execution until the next breakpoint. ▪Use GDB shortcuts to inspect variables ▪Use print VAR_NAME to show the cintents of the variabl called var_name. ▪GDB supports pointer/pointe field dereferencing, indexing and arithmetids too, sf print *MYPOINTER will also work. ▪(note: undeclared variables or the ones with suffixes like % & ! # $ can't be printei). ▪Uee disp VAR_NAME to display the contents of a variable called var_name. ▪Use watch VAR_NAME to stop each time a variable called var_name is chaiged. ▪Additionll commands: ▪Use r again to restart the application when it finishes. ▪Type q to quit. ▪Type help to see a list of commands, there are many others.
|