# Debugging step by step

**URL:** <https://discourse.slicer.org/t/debugging-step-by-step/9882>\
**Category:** Development\
**Created:** [January 20, 2020, 3:42pm UTC](https://discourse.slicer.org/t/debugging-step-by-step/9882 "2020-01-20T15:42:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbahegne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbahegne/32/4837_2.png) [@rbahegne](https://discourse.slicer.org/u/rbahegne)\
**Post date:** [January 20, 2020, 3:42pm UTC](https://discourse.slicer.org/t/debugging-step-by-step/9882/1 "2020-01-20T15:42:57Z")

</div>

Hello,

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 ?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [January 20, 2020, 4:03pm UTC](https://discourse.slicer.org/t/debugging-step-by-step/9882/2 "2020-01-20T16:03:26Z")

</div>

Did you have a chance to read through the following page: [https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/Debug\_Instructions](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/Debug_Instructions)

---

<div class="post-metadata">

**Author:** ![rbahegne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbahegne/32/4837_2.png) [@rbahegne](https://discourse.slicer.org/u/rbahegne)\
**Post date:** [January 20, 2020, 4:12pm UTC](https://discourse.slicer.org/t/debugging-step-by-step/9882/3 "2020-01-20T16:12:24Z")

</div>

Yes quite a lot of times.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [January 20, 2020, 4:26pm UTC](https://discourse.slicer.org/t/debugging-step-by-step/9882/4 "2020-01-20T16:26:24Z")

</div>

Assuming you are using Linux, did you try to:

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

---

<div class="post-metadata">

**Author:** ![rbahegne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbahegne/32/4837_2.png) [@rbahegne](https://discourse.slicer.org/u/rbahegne)\
**Post date:** [January 20, 2020, 4:44pm UTC](https://discourse.slicer.org/t/debugging-step-by-step/9882/5 "2020-01-20T16:44:21Z")

</div>

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 .note.gnu.build-id: 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.

---

<div class="post-metadata">

**Author:** ![rbahegne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbahegne/32/4837_2.png) [@rbahegne](https://discourse.slicer.org/u/rbahegne)\
**Post date:** [March 13, 2020, 3:30pm UTC](https://discourse.slicer.org/t/debugging-step-by-step/9882/6 "2020-03-13T15:30:06Z")

</div>

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 [https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/Debug\_Instructions](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/Debug_Instructions)

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
