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

From Slicer Wiki
Jump to: navigation, search
Line 26: Line 26:
 
See [[Slicer4:Example_Wrapper_Script|this example script]]
 
See [[Slicer4:Example_Wrapper_Script|this example script]]
  
See also: [[Slicer4:Linux_Debugging_CodeLite|Linux debugging with CodeLite]]
+
Now, start gdb and do the following:
 +
<pre>
 +
(gdb) set exec-wrapper ./WrapSlicer4
 +
(gdb) exec-file ./bin/SlicerQT-real
 +
(gdb) run
 +
</pre>
 +
 
 +
See also: [[Slicer4:Linux_Debugging_CodeLite|Linux debugging with CodeLite IDE]]

Revision as of 02:48, 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 attach 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 with one command.

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

See also: Linux debugging with CodeLite IDE