Difference between revisions of "Documentation/Nightly/Extensions/DebuggingTools"

From Slicer Wiki
Jump to: navigation, search
(moved to github)
Tags: 2017 source edit, Replaced
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
<noinclude>{{documentation/versioncheck}}</noinclude>
+
{{documentation/banner
<!-- ---------------------------- -->
+
| text  = [https://github.com/SlicerRt/SlicerDebuggingTools This page has been moved to Github.]
{{documentation/{{documentation/version}}/module-header}}
+
| background-color = 8FBC8F }}
<!-- ---------------------------- -->
 
{{documentation/{{documentation/version}}/module-section|Introduction and Acknowledgements}}
 
Author: Andras Lasso (PerkLab, Queen's University), Mikael Brudfors (Laboratorio de Imagen Medica, Hospital Gregorio Maranon - http://image.hggm.es/)<br>
 
Contact: Andras Lasso, <email>lasso@queensu.ca</email><br>
 
Project website: http://www.slicerrt.org<br>
 
License: [http://www.slicer.org/pages/LicenseText Slicer license]
 
{{documentation/{{documentation/version}}/module-introduction-logo-gallery
 
|{{collaborator|logo|sparkit}}|SparKit
 
|{{collaborator|logo|namic}}|NA-MIC
 
|{{collaborator|logo|perklab}}|PerkLab
 
|{{collaborator|logo|ocairo}}|OCAIRO
 
}}
 
 
 
<!-- ---------------------------- -->
 
{{documentation/{{documentation/version}}/extension-section|Extension Description}}
 
 
 
Collection of tools for developing and debugging modules.
 
 
 
<!-- ---------------------------- -->
 
{{documentation/{{documentation/version}}/extension-section|Modules}}
 
 
 
* Python Debugger (in category: Developer Tools): allow debugging of Python scripts in the Eclipse integrated development environment using PyDev. Visual debugging (setting breakpoints, execute code step-by-step, view variables, stack, etc.) of Python scripted module is possible by using [http://pydev.org/ PyDev].
 
* Node modified statistics (in category: Developer Tools): Module for collecting statistics on timing of node Modified events. It is useful for estimating refresh rate when a live data stream or temporal data sequence is visualized.
 
 
 
<!-- ---------------------------- -->
 
{{documentation/{{documentation/version}}/extension-section|Use Cases}}
 
 
 
<gallery widths="200px" perrow="4">
 
Image:PyDevRemoteDebugSlicer.png|Debugging Slicer in PyDev
 
</gallery>
 
 
 
<!-- ---------------------------- -->
 
{{documentation/{{documentation/version}}/extension-section|Tutorials}}
 
 
 
===Visual Python debugging in PyCharm===
 
 
 
====One-time setup====
 
* Install '''Professional edition''' of [https://www.jetbrains.com/pycharm/download/ PyCharm]. Professional version is avaialable for anybody with an academic email address for free. Free Community edition will not work, as it does not include remote debug server.
 
* In PyCharm:
 
** In the menu select: Run / Edit configurations
 
** Click the small + icon in the top-left (Add new configuration)
 
** Select 'Python remote debug' configuration as a template
 
** Set Name: ''Slicer remote debugger''
 
** Set Port: 5678
 
** Click OK
 
* In Slicer:
 
** Install the Python debugger extension
 
** Open the ''Python debugger'' module (in ''Developer Tools'' category)
 
** In the ''Settings'' section select debugger: 'PyCharm'
 
** If pycharm-debug.egg path is not detected automatically then set the path with the selector
 
 
 
====Start debugging====
 
* In PyCharm:
 
** In the menu select: Run / Debug, click ''Slicer remote debugger''
 
* In Slicer:
 
** Open the ''Python debugger'' module (in ''Developer Tools'' category)
 
** Click on ''Connect'' button. Slicer will become unresponsive until the debugger is attached.
 
* In PyCharm:
 
** Load your .py file and add breakpoints (menu: Run / Toggle Line Breakpoint) where you want your execution to stop for debugging.
 
** Important: once Slicer is paused at a breakpoint, you can open a terminal, where you can enter Python commands (you have access to all Slicer variables, it has auto-complete, etc). Click the small terminal icon ''Show Python Prompt'' to open the Python console.
 
<gallery widths="200px" perrow="4">
 
Image:PyCharmDebugConsole.png|Python debugging console in PyCharm
 
</gallery>
 
===Visual Python debugging in Eclipse===
 
 
 
====One-time setup====
 
* Install Eclipse with PyDev: the simplest is to use the standalone preconfigured [http://brainwy.github.io/liclipse/ LiClipse] package
 
* Run PyDev and enable the remote debugger tool (if you have trouble following these steps then you can find detailed instructions [http://pydev.org/manual_adv_remote_debugger.html here]):
 
** Enable PyDev server: in the menu Window > Customize perspective > Command groups availability > PyDev debug
 
** Open the debug window: in the menu Window > Open Perspective > Other > Debug => <span style="color: red">Without this step the ''Resume'' button will be disabled and debugging cannot be started!</span>
 
* In Slicer:
 
* Install the Python debugger extension
 
** Open the ''Python debugger'' module (in ''Developer Tools'' category)
 
** In the ''Settings'' section set the directory that contains the ''pydevd.py'' file. Usually it is in the Eclipse plugins directory /...pydev.../pysrc.
 
 
 
====Start debugging====
 
* In PyDev
 
** Start the server: on the toolbar click the button "PyDev: start the pydev server"
 
[[File:PyDevStartRemoteDebug.png]]
 
* In Slicer:
 
** Open the ''Python debugger'' module (in ''Developer Tools'' category)
 
** Click on ''Connect''
 
** If the debugger is successfully attached, then it will pause Slicer, so Slicer becomes unresponsive (until its execution is resumed in PyDev)
 
* In PyDev.
 
** Slicer execution is now paused. Slicer will become unresponsive until the debugger is attached.
 
** Load your .py file into PyDev and add breakpoints (Ctrl+Shift+B) where you want your execution to stop for debugging.
 
** Important: you can open a terminal, where you can enter Python commands while the execution is paused (you have access to all Slicer variable, it has auto-complete, etc.) by clicking on "Open Console" (small button at the top of the console view) then chose "PyDev Console" and then "PyDev Debug Console" (after this the title of the console should be "PyDev Debug Console" instead of the default "Debug Server").
 
 
 
===Debugging in VisualStudio===
 
 
 
====One-time setup====
 
* Install Visual Studio 2013 or 2015.
 
* Install [https://github.com/Microsoft/PTVS/releases/v2.2.2 Python Tools for Visual Studio]
 
* In Slicer:
 
** Install the Python debugger extension
 
** Open the ''Python debugger'' module (in ''Developer Tools'' category)
 
** In the ''Settings'' section select debugger: 'VisualStudio'
 
 
 
====Start debugging====
 
* In Slicer:
 
** Open the ''Python debugger'' module (in ''Developer Tools'' category)
 
** Click on ''Connect'' button. Slicer will become unresponsive until the debugger is attached.
 
* In Visual Studio:
 
** In menu, select ''Debug > Attach to Process'' to display the ''Attach to Process'' window
 
** ''Transport'' -> ''Python remote (ptvsd)''
 
** ''Qualifier'' -> ''tcp://slicer@localhost:5678''
 
** Press Enter or click ''Refresh'' button. The Slicer process should appear in the list below.
 
** Double-click on the Slicer process or click ''Attach'' button.
 
 
 
<!-- ---------------------------- -->
 
{{documentation/{{documentation/version}}/extension-section|Similar Extensions}}
 
Alternatively, you can set up Microsoft Visual Studio for remote Python debugging [[documentation/{{documentation/version}}/Developers/Tutorials/Debugging_Python_in_Visual_Studio|as described here]]
 
<!-- ---------------------------- -->
 
<!--
 
{{documentation/{{documentation/version}}/extension-section|References}}
 
-->
 
 
 
<!-- ---------------------------- -->
 
{{documentation/{{documentation/version}}/extension-section|Information for Developers}}
 
* Source code: https://github.com/SlicerRt/SlicerDebuggingTools
 
* Issue tracker:  [https://github.com/SlicerRt/SlicerDebuggingTools/issues open issues and enhancement requests]
 
 
 
<!-- ---------------------------- -->
 
<!--
 
{{documentation/{{documentation/version}}/extension-section|Troubleshooting}}
 
-->
 
<!-- ---------------------------- -->
 
 
 
<!-- ---------------------------- -->
 
{{documentation/{{documentation/version}}/extension-footer}}
 
<!-- ---------------------------- -->
 

Latest revision as of 03:38, 14 April 2021

Home < Documentation < Nightly < Extensions < DebuggingTools