Ask Your Question

How can I run ROS2 nodes in a debugger (e.g. gdb)?

asked 2017-07-24 14:52:24 -0500

Is there something like the --prefix argument from rosrun in ros2 (see #q222530)?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2017-07-28 10:27:35 -0500

The --prefix argument is now working with ros2 run. So you can use it in the same way as known from rosrun, e.g.:

ros2 run --prefix 'gdb -ex run --args' package_name executable_name (see #q222530 for more examples).

At the moment this feature is only available on ROS2 installations, which were built from the development sources (master branch).

edit flag offensive delete link more


I don't want to create a new question for this but; how would that be written for lldb ? probably trivial but I couldn't get it to work.

klintan gravatar image klintan  ( 2019-09-11 20:04:45 -0500 )edit

answered 2020-08-20 00:29:04 -0500

klintan gravatar image

Had some issues getting gdb running on Mac, so had to use LLDB instead:

Make sure to build with debugging symbols. colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo

Further you can start your node by referencing the executables directly (in this case my packages is called arke_base): lldb -f arke_base/install/arke_base/lib/arke_base/arke_hardware_interface_node -- --ros-args --params-file arke_base/config/arke_diff_drive_controller.yaml

The command also shows arguments added, in this case a config file.

edit flag offensive delete link more

answered 2017-07-24 15:30:32 -0500

William gravatar image

There is not an option like that. You can just run the binary directly from its location in gdb <install_prefix>/lib/<package_name>/<executable_name>. You can open an issue or pull request on ros2 run to make this case better:

edit flag offensive delete link more


Thanks for the quick answer!

Andre Volk gravatar image Andre Volk  ( 2017-07-24 15:34:41 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2017-07-24 14:52:24 -0500

Seen: 1,756 times

Last updated: Aug 20