Can not set breakpoints when debugging ros2 nodes

asked 2022-09-06 05:32:59 -0600

Bernat Gaston gravatar image

updated 2022-09-06 06:47:38 -0600

ljaniec gravatar image


I am new using debuggers in ros2. I have used previously gdb in c++ programs but not with ros2. I am getting a very weird behavior using different debugging approaches. I can set breakpoints but only outside iterative and conditional structures. If I try to set a breakpoint inside for example, a while, it does not allow me or it places it outside the function.

I have tried to do it with VSCode (using ROS:Launch and using the approach exposed here both answers) I also tried gdb directly. In GDB when I add a breakpoint it changes the line number

(gdb) break hello_world.cpp:12
Breakpoint 1 at 0x5555555568f7: file /home/bernat/ros2_ws/prova/src/hello_world_package/src/hello_world.cpp, line 18.

In VStudio see the video I posted here

My guess is that it is a problem with the debugging symbols. I used

colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo

But I am not solving the problem. Any idea? Many thanks!

edit retag flag offensive close merge delete