Debugging your programs
Free Pascalsupports debug information for the GNUdebugger gdb, or its derivatives Insight on win32 or ddd on Linux. It can write 2 kinds of debug information:
- stabs
-
The old debug information format.
- dwarf
-
The new debug information format.
Both are understood by GDB.
This chapter briefly describes how to use this feature. It doesn’t attempt to describe completely the GNUdebugger, however. For more information on the workings of the GNUdebugger, see the GDB of User’s Guide.
Free Pascalalso supports gprof, the GNUprofiler. See section Debugging your programs for more information on profiling.
- Compiling your program with debugger supportFirst of all, you must be sure that the compiler is compiled with debugging support. Unfortunately, there is no way to check this at run time, except by trying
- Using gdb to debug your programTo use gdb to debug your program, you can start the debugger, and give it as an option the full name of your program: gdb hello Or, under DOS: gdb hello.exe Thi
- Caveats when debugging with gdbThere are some peculiarities of Free Pascalwhich you should be aware of when using gdb . We list the main ones here: Free Pascalgenerates information for GDB in
- Support for gprof , the GNUprofilerYou can compile your programs with profiling support. For this, you just have to use the compiler switch -pg . The compiler will insert the necessary stuff for
- Detecting heap memory leaksFree Pascalhas a built in mechanism to detect memory leaks. There is a plug-in unit for the memory manager that analyses the memory allocation/deallocation and
- Line numbers in run-time error backtracesNormally, when a run-time error occurs, you are presented with a list of addresses that represent the call stack backtrace, i.e. the addresses of all procedures
- Combining heaptrc and lineinfoIf you combine the lineinfo and the heaptrc information, then the output of the heaptrc unit will contain the names of the files and line numbers of the procedu
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
