Documentation/4.0/Developers/Tutorials/Debug Instructions
Contents
Background
The executable Slicer application is: Slicer-build/Slicer (or Slicer.exe)
This is actually a wrapper created using the CTK AppLauncher. The wrapper exists to set library and environment paths before launching the real application binary in Slicer-build/bin/SlicerQT-real
- The wrapper is configured in Slicer4/Applications/QTGUI/CMakeLists.txt under the heading "Configure Slicer Launcher"
- The AppLauncher source code is here: https://github.com/commontk/AppLauncher
- The launcher configuration is put here: Slicer-build/SlicerLauncherSettings.ini
Linux
GDB debug with launch arguments
The Slicer app launcher provides options to start other programs with the Slicer environment settings.
- --launch: execute arbitrary program. For example, start gnome-terminal (then run GDB directly on SlicerQT-real)
- --gdb: run GDB. then exec SlicerQT-real from within the debugger environment.
GDB debug by attaching to running process
Run ./Slicer-build/Slicer
Now, run "ps -Afww | grep SlicerQT-real" and note the PID of this binary.
Now, run "gdb --pid $PIDABOVE"
GDB debug by using exec-wrapper
An alternative approach is to use a wrapper script to emulate the functionality of the app launcher. This will allow you to use gdb or a gdb-controlling program such as an IDE, in order to interactively debug directly from GDB without attaching.
The general idea of the wrapper is to set all of the appropriate environment variables as they would be set by the app launcher. From SlicerLauncherSettings:
- [LibraryPath] contents should be in LD_LIBRARY_PATH
- [Paths] contents should be in PATH
- [EnvironmentVariables] should each be set
Now, start gdb and do the following:
(gdb) set exec-wrapper ./WrapSlicer4 (gdb) exec-file ./bin/SlicerQT-real (gdb) run