Debugging cannot attach on Linux?

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 (editing that file), but haven’t restarted the computer, not sure if it’s an issue.

[1]

[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]

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!

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…