- This topic has 3 replies, 3 voices, and was last updated 4 years, 7 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
Home › Forum › SOFA › Programming with SOFA › [SOLVED] Debug C++ code from Qt Creator
Hello 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 in src/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 setting CMAKE_BUILD_TYPE
to debug
.
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.scn
from 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 (.scn
or .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.
Hi,
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 the Projects 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,
Vincent
Hello,
Thanks Vincent. Works like a charm!
Cheers
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.