D How-to debug PRLT
Debugging PolimiRLToolkit is just like debugging any other application, there are several ways to do so. Choose the one that best fits your preferences.
The easiest, ugliest and roughest way is to add some cout lines in your source files. If you decide to use this sad way remember to add an identifier to each cout, so that you can recognize them from the output. After each cout use the endl keyword. This will flush the buffer letting you check every cout statement after the occasional breaking of the program.
Every other debug method requires that every file has been compiled with the flag CDEBUG on. Open prlt/core/src/Makefile
cd prtl/core/src kwrite Makefile
and decomment the line
CDEBUG = -ggdb -fPIC -O3
then you must clean the project and recompile it
make cleanall nice -n 19 make tests
This is the leet way. Enter the directory containing your executable (es toolkit)
and call gdb on it
This will enter you in the gdb shell. From here you can use some useful commands:
- run <executable filename> -n <parameters> will run it
- up and down will let you check the stack sequence of your executable once it crashed (eg. for a segmentation fault)
You can also directly call gdb passing all your programs parameters to it:
gdb --args ./toolkit -n ../data/experiment/smile/GridWorldOptions.xml
and then, from the gdb shell, call
- run and hit enter
NOTE you can also abbreviate run simply with r
ddd and kdbg
These are graphical interfaces to gdb. They are so intuitive that an explanation of their usage will just waste your time.
In order to debug a program you must be able to execute it via Eclipse itself. You can do it via the green icon with the arrow in the toolbar. Next to it you can find the debugger icon: the green one with a bug. Both icons share the same interface: use it to simply call the last started/debugged program, or press it some seconds to work on the related menu. From that menu you can also set program parameters.
Using the debug button will enable the debug perpective, that you can use to check watches, checkpoints, the stack and many other features.