Difference between revisions of "Documentation/4.0/Developers/Tutorials/Debug Instructions"

From Slicer Wiki
Jump to: navigation, search
Line 17: Line 17:
  
 
===GDB debug by using exec-wrapper===
 
===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 with one command.
+
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:
 
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:

Revision as of 03:11, 9 October 2011

Home < Documentation < 4.0 < Developers < Tutorials < Debug Instructions

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 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

See this example script

Now, start gdb and do the following:

(gdb) set exec-wrapper ./WrapSlicer4 
(gdb) exec-file ./bin/SlicerQT-real
(gdb) run

GDB debug in CodeLite IDE

Linux debugging with CodeLite IDE