Slicer3:Execution Model Documentation:Debugging

From SlicerWiki
Jump to: navigation, search
Home < Slicer3:Execution Model Documentation:Debugging

Hints

You can use standard debuggers but you need to be sure that you have your path set correctly. You can use slicer3's launcher to set up the environment for you. See some windows examples.

Set the command line module (LinearRegistration in this example) to be the Start Up project for visual studio. You can cut and paste the arguments to the module from the log window (red X icon in lower right of the slicer interface).

The command line may look something like the following:

C:/pieper/bwh/slicer3/latest/Slicer3-build/bin/Debug/../../lib/Slicer3/Plugins/Debug/LinearRegistration.exe --histogrambins 30 --spatialsamples 10000 --iterations 1000,1000,500,200 --learningrate 0.01,0.005,0.0005,0.0002 --translationscale 100 c:/Documents and Settings/Administrator/Local Settings/Temp/Slicer3/EHGE_vtkMRMLScalarVolumeNodeB.nrrd c:/Documents and Settings/Administrator/Local Settings/Temp/Slicer3/EHGE_vtkMRMLScalarVolumeNodeD.nrrd c:/Documents and Settings/Administrator/Local Settings/Temp/Slicer3/EHGE_vtkMRMLScalarVolumeNodeE.nrrd 

(note you may need to put quotes around file names that have spaces).

By default slicer will delete the temp files after the module completes. To disable this, use a command like this in the Tcl console:

[$::slicer3::CommandLineModuleGUI_Linear_registration GetLogic] DeleteTemporaryFilesOff

Cut and paste this entire line (including the brackets and dollar signs), but change the name of the module, e.g. Linear_registration in the line above should be changed to the name of your module.

Another useful technique for Visual Studio is to right click on your module project and pick "Select As Startup Project" from the menu. Then in the right click menu pick "Properties" and go to "Debugging" and paste in the command line options. This way you can replicate the behavior of your module and single step through it.


Windows JIT debugging with Visual Studio

If you are working on Windows with Visual Studio there is a way to hook the command line process at launch and debug it:

1. Follow the steps described in MSDN How to Launch the Debugger Automatically to hook the command line module executable to the debugger. (make sure you use the instructions for your installed version of visual studio).

2. Load the command line module project into Visual Studio and set a break point.

3. Launch the command line module within 3D Slicer. The module should hang. Let it go through the regular procedure for processes that stop working and after clicking the send information button click debug and select the instance of Visual Studio with the breakpoint.

At this stage the command line module will run within the debugger. If it does not start, try pressing F5 or F10.