Home › Forum › SOFA › Programming with SOFA › [SOLVED] Debug C++ code from Qt Creator
- This topic has 3 replies, 3 voices, and was last updated 5 years, 7 months ago by
Hugo.
-
AuthorPosts
-
16 April 2020 at 14:44 #15787
MarcoMag
BlockedHello everyone,
I have started using SOFA a couple of days ago, so I am sorry in advance if the question I am going to ask is trivial for some of you.
My (long-term) goal is to implement some contact routines for beam-to-beam contact in SOFA.
Prior to that, I need to understand the collision models already existing for the contact between beams, for instance the ones used insrc/examples/Components/forcefield/BeamFEMForceField.scn.
It would be super useful to me to understand the different phases of the contact treatment in general (contact collision and response).My strategy to get familiar with this is to use the debugger in C++.
To this end, I compiled SOFA by settingCMAKE_BUILD_TYPEtodebug.
Now, I set a breakpoint somewhere in the source code, for instance in a constructor of a class that is being used.
I would like the code to stop when that breakpoint is hit. That would allow me to go through the code step by step.When I run
sofa/build/debug/bin/runSofa_d sofa/src/examples/Components/forcefield/BeamFEMForceField.scnfrom the terminal, obviously the code does not stop at the breakpoint I set (in Qtcreator).My question is: how to proceed to stop the code at a given breakpoint?
Maybe if I launch a schene (
.scnor.py) from Qtcreator, it would help. But I don’t know if it is possible to do this at all.Thanks in advance for your help.
16 April 2020 at 15:12 #15788Vincent
BlockedHi,
To be able to stop execution at certain points in the code, you need to run sofa through a debugger. In QtCreator, this can be made simply by clicking “Start debugging”.
You need to set up your project so that the executable is runSofa_d and the arguments point to your scene (in theProjects tab->Build & Run->Run)You may also use the console, but it is much harder to follow anything that happens. For example, you can start using
gdb sofa/build/debug/bin/runSofa_d, then run using your scene as an argument.Hope this helps.
Cheers,
Vincent16 April 2020 at 15:14 #15789MarcoMag
BlockedHello,
Thanks Vincent. Works like a charm!
Cheers
16 April 2020 at 15:18 #15790 -
AuthorPosts
- You must be logged in to reply to this topic.

