Debugging step by step


I created a C++ extension, which works quite fine but i never managed to make to debugger work.

I tried with several IDE QtCreator, Kdevelop, Clion, I correctly set the CMAKE_BUILD_TYPE Flag to debug (for my extension and for 3D Slicer), and each time i can’t get breakpoints working. It seems that debug symbols are not generated.

Am I missing something ?

Did you have a chance to read through the following page:

Yes quite a lot of times.

Assuming you are using Linux, did you try to:

  • start Slicer
  • start ddd and attach to the running process
  • set breakpoints

I’m indeed on linux (ubuntu 18.04.3 , using Qt 5.11.0 GCC 64bit)

I tried this kind of thing using QtCreator when i attach to the process i get this :

This does not seem to be a “Debug” build.
Setting breakpoints by file name and line number may fail.
Section .debug_info: Not found.
Section .debug_abbrev: Not found.
Section .debug_line: Not found.
Section .debug_str: Not found.
Section .debug_loc: Not found.
Section .debug_range: Not found.
Section .gdb_index: Not found.
Section Found.
Section .gnu.hash: Found.
Section .gnu_debuglink: Not found.

After googling it i just got advice to set BuilType to Debug, which was the first thing i did.
I though maybe the extension dependency to 3d slicer (which is also build in debug) was messing things up, but i did not found anything relevant.

For any futher user here how i fixed this :

The real process is not SlicerWith or Slicer but SlicerApp-real so you can’t debug at start, we need to attach to the process (ubuntu need some minor configuration to be able to do so, see below). From

GDB debug by attaching to running process: Starting with Ubuntu 10.10, ptracing of non-child processes by non-root users as been disabled -ie. only a process which is a parent of another process can ptrace it for normal users. You can temporarily disable this restriction by: $ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

To permanently allow it to edit /etc/sysctl.d/10-ptrace.conf and change the line: kernel.yama.ptrace_scope = 1 to read: kernel.yama.ptrace_scope = 0

Run SlicerWith*NameOfYourExtension, then attach to process SlicerApp-real

1 Like