# Debugging cannot attach on Linux?

**URL:** <https://discourse.slicer.org/t/debugging-cannot-attach-on-linux/24526>\
**Category:** Development\
**Tags:** linux, debug\
**Created:** [July 27, 2022, 12:49pm UTC](https://discourse.slicer.org/t/debugging-cannot-attach-on-linux/24526 "2022-07-27T12:49:28Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [July 27, 2022, 12:49pm UTC](https://discourse.slicer.org/t/debugging-cannot-attach-on-linux/24526/1 "2022-07-27T12:49:28Z")

</div>

Hi all,

I’m trying to debug Slicer (few commits after 5.0.3) on Ubuntu 20.04. I built Slicer in debug mode, and tried the following:

- Attach debugger from VS Code after starting the debug Slicer with its launcher (Slicer-build/Slicer), but specifying the PID of SlicerApp-real. It thinks for a while, then detaches itself, saying the process was “Killed” [1]
- Launch Slicer from VS Code
  - It starts alright if I just specify SlicerApp-real, but then, because the environment is not set I guess, I cannot use SimpleITK, which would be needed to get to the point I want to debug
  - When I launch VS Code using the Slicer launcher, then try to launch SlicerApp-real, it gives me a traceback [2] and does not start Slicer

- Attach debugger using gdb. I get the exact same issue as the first bullet

I did the permanent solution from the [debug howto](https://slicer.readthedocs.io/en/latest/developer_guide/debugging/linuxcpp.html#gdb-debug-by-attaching-to-running-process-recommended) (editing that file), but haven’t restarted the computer, not sure if it’s an issue.

[1]

```auto
[1] + Killed /usr/bin/pkexec "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-14i5barx.5at" 1>"/tmp/Microsoft-MIEngine-Out-0lrss5ki.qlq"

```

[2]

```auto
Traceback (most recent call last):
  File "/home/csaba/Slicer/sD/python-install/lib/python3.9/site.py", line 73, in <module>
    import os
  File "/home/csaba/Slicer/sD/python-install/lib/python3.9/os.py", line 29, in <module>
    from _collections_abc import _check_methods
  File "/home/csaba/Slicer/sD/python-install/lib/python3.9/_collections_abc.py", line 12, in <module>
    GenericAlias = type(list[int])
TypeError: 'type' object is not subscriptable
[1] + Done(1) "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-p215jlbf.je2" 1>"/tmp/Microsoft-MIEngine-Out-k3buhqsc.s15"

```

Any help would be appreciated. Thank you!

---

<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:** [August 1, 2022, 9:29am UTC](https://discourse.slicer.org/t/debugging-cannot-attach-on-linux/24526/2 "2022-08-01T09:29:37Z")

</div>

I managed to attach the VS debugger to Slicer. Two things I did differently than the above. First, I restarted the computer (so maybe the “permanent solution” for debugging kicked in, not sure if it needed a restart), second, I attached the process during the PID window was shown (as in --attach-process). I managed to get a partial callstack, but then, when loading more of the stack gdb crashed. So still painful…
