Robotics StackExchange | Archived questions

Can not set breakpoints when debugging ros2 nodes

Hi,

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 https://answers.ros.org/question/267261/how-can-i-run-ros2-nodes-in-a-debugger-eg-gdb/ 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.
(gdb) 

In VStudio see the video I posted here https://github.com/ms-iot/vscode-ros/issues/784

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!

Asked by Bernat Gaston on 2022-09-06 05:32:59 UTC

Comments

Answers