# Debug Slicer and SlicerRT Together

**URL:** <https://discourse.slicer.org/t/debug-slicer-and-slicerrt-together/26955>\
**Category:** Development\
**Tags:** slicerrt\
**Created:** [December 28, 2022, 5:25am UTC](https://discourse.slicer.org/t/debug-slicer-and-slicerrt-together/26955 "2022-12-28T05:25:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sani1486](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sani1486/32/17841_2.png) [@sani1486](https://discourse.slicer.org/u/sani1486)\
**Post date:** [December 28, 2022, 5:25am UTC](https://discourse.slicer.org/t/debug-slicer-and-slicerrt-together/26955/1 "2022-12-28T05:25:31Z")

</div>

Hello  
I am Looking for a way to simultaneously debug the slicer itself along with its Slicer RT extension together. I know how to run the slicerRt or Slicer in debug mode separately. But then I would actually like to check the call stacks and everything from SlicerRT to Slicer.  
Appreciation in Advance.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [December 28, 2022, 2:16pm UTC](https://discourse.slicer.org/t/debug-slicer-and-slicerrt-together/26955/2 "2022-12-28T14:16:31Z")

</div>

I guess you mean using an IDE debugger to look at the C++ code? Yes, that should work normally if you build both the Slicer core and the SlicerRT extension in debug mode and either start up the app from the IDE or connect to the running process.

---

<div class="post-metadata">

**Author:** ![sani1486](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sani1486/32/17841_2.png) [@sani1486](https://discourse.slicer.org/u/sani1486)\
**Post date:** [December 31, 2022, 9:22am UTC](https://discourse.slicer.org/t/debug-slicer-and-slicerrt-together/26955/3 "2022-12-31T09:22:18Z")

</div>

Thanks for your reply, I did build both of them in debug mode and i ran

```auto
.\S5D\Slicer-build\Slicer.exe --VisualStudio --launcher-no-splash --launcher-additional-settings E:/RTD/inner-build/AdditionalLauncherSettings.ini E:\RTD\inner-build\SlicerRT.sln

```

which eventually started SlicerRT sln, and I set up the ALL\_BUILD project according to [Debugging using Visual Studio](https://slicer.readthedocs.io/en/latest/developer_guide/debugging/windowscpp.html)  
from slicer doc. What is happening is I can set breakpoints in the slicer part of code, for example `vtkMRMLSegmentationNode.cxx`. but if I try to set a breakpoint in SlicerRT code, for example, `vtkSlicerDicomRtImportExportModuleLogic.cxx`, MSVC says breakpoint won’t be hit because no symbol is loaded, so I went ahead and loaded a Dicom RT structure file, in the Dicom data browser, and found RT Structure examine failed, apparently, the initiated slicer.exe don’t think a slicerRT extension is loaded, which by the way doesn’t happen when I run the `SlicerWithSlicerRT.exe` file found in SlicerRt’s inner-build. So I think SlicerRT and Slicer were built fine. I just can’t seem to understand why the slicerRT specific modules and debug symbols aren’t loaded.

---

<div class="post-metadata">

**Author:** ![sani1486](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sani1486/32/17841_2.png) [@sani1486](https://discourse.slicer.org/u/sani1486)\
**Post date:** [December 31, 2022, 9:40am UTC](https://discourse.slicer.org/t/debug-slicer-and-slicerrt-together/26955/4 "2022-12-31T09:40:21Z")

</div>

@pieper However, I got curious about the AdditionalLauncherSettings.ini file, and there are few paths listed, Strangely some of these paths don’t really exist on my device. the ini file is pasted down below. the c style `/**/` commented paths don’t exist.

```auto
[General]
additionalPathVariables=PYTHONPATH

[LibraryPaths]
1\path=E:/RTD/inner-build/lib/Slicer-5.3/cli-modules/Debug
2\path=E:/RTD/inner-build/lib/Slicer-5.3/qt-loadable-modules/Debug
/* 3\path=E:/RTD/lib/Slicer-5.3/Debug */
size=3

[Paths]
1\path=E:/RTD/inner-build/lib/Slicer-5.3/cli-modules/Debug
2\path=E:/RTD/inner-build/bin/Debug
/* 3\path=E:/RTD/bin/Debug */
size=3

[EnvironmentVariables]

[PYTHONPATH]
1\path=E:/RTD/inner-build/lib/Slicer-5.3/qt-scripted-modules
2\path=E:/RTD/inner-build/lib/Slicer-5.3/qt-loadable-modules/Debug
/* 3\path=E:/RTD/inner-build/lib/Slicer-5.3/qt-loadable-modules/Python */
/* 4\path=E:/RTD/lib/Slicer-5.3/Debug */
size=4

```

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 1, 2023, 8:45pm UTC](https://discourse.slicer.org/t/debug-slicer-and-slicerrt-together/26955/5 "2023-01-01T20:45:54Z")

</div>

It sounds like you are close. I haven’t debugged extensions with visual studio for quite a while myself, but I agree the paths look wrong in that ini file. Perhaps there’s been some format change in the visual studio build files and the launcher settings code needs to be updated.

What I would suggest though is to start Slicer with the `SlicerWithSlicerRT.exe` command and then just connect the debugger to the process once it starts so it should pick up all the paths from the running process. You can then load data and do your debugging.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [January 4, 2023, 11:17am UTC](https://discourse.slicer.org/t/debug-slicer-and-slicerrt-together/26955/6 "2023-01-04T11:17:30Z")

</div>

Your approach sounds good. This command starts VS for me with the ability to debug Slicer and SlicerRT:  
`..\S5D\Slicer-build\Slicer.exe --VisualStudio --launcher-no-splash --launcher-additional-settings ./SlicerRT_D/inner-build/AdditionalLauncherSettings.ini c:\d\_Extensions\SlicerRT_D\inner-build\SlicerRT.sln`

Then when the solution opens, make sure that you select a project other than `ALL_BUILD` as startup, it can be any of them (qSlicer… or vtkMRML…). Then, in the project settings you need to set the command to be the `SlicerApp-real.exe`, such as `c:\d\S5D\Slicer-build\bin\Debug\SlicerApp-real.exe`. Then when you start the debugger, the breakpoints in Slicer and SlicerRT (and CTK etc) should be hit.

Of course what @pieper suggests with `SlicerWithSlicerRT.exe` should work too, but what I have wrote above is how I have been doing it forever and it still works.
