ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
4

How to debug executable, built with catkin_make (without roslaunch)

asked 2014-12-29 05:55:40 -0600

Rufio gravatar image

updated 2014-12-29 09:19:52 -0600

Hi,

in my project i built several executables with catkin_make and i want to debug it (e.g. with gdb). Usually when building with gcc one can just add the the argument -g. Is there similar why for catkin such that i can debug the executables afterwards with gdb and without using roslaunch?

I have tried starting gdb directly with the executable but it says no debugging symbols found.

I have also tried to do set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -std=c++11 -march=native" ) without success.

I haven't found anything regarding this on the internet so far. Thanks for helping

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
12

answered 2014-12-29 07:36:33 -0600

gvdhoorn gravatar image

updated 2014-12-29 09:33:13 -0600

You probably want to take a look at roslaunch/Tutorials/Roslaunch Nodes in Valgrind or GDB. Make sure to build proper Debug binaries.

Btw: this is not really specific to catkin_make. The launch-prefix just makes this convenient when starting things from launch files. For single nodes (and an already running master), you can also just do:

gdb --args /path/to/your/node/binary

[..] I haven't found anything regarding this on the internet so far.

The tutorial I linked was actually the first result after searching for ros gdb on Google.


Edit:

I have tried starting gdb directly with the executable but it says no debugging symbols found.

I have also tried to do set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -std=c++11 -march=native" ) without success.

This has been answered before, see fi Cmake debug option:

This will set -g for you:

catkin_make -DCMAKE_BUILD_TYPE=Debug

catkin is just a thin layer on top of CMake in this case.

And if you need optimisation with debug symbols, see catkin_make's option for optimization:

For a release configuration with opmizations and no debugging symbols, you can use the Release build type:

catkin_make -DCMAKE_BUILD_TYPE=Release

For a release with debug configuration, with optimizations and debug symbols, you can use the RelWithDebInfo build type:

catkin_make -DCMAKE_BUILD_TYPE=RelWithDebInfo

CMake's useful variables page gives more information about build types.

edit flag offensive delete link more

Comments

thanks for the answer. I want to do it without using roslaunch because i have some unresolved problems with roslaunch (i will edit that in the title) by using

gdb binary

i was not able to add some breakpoints and so on.

Rufio gravatar image Rufio  ( 2014-12-29 08:23:50 -0600 )edit

If you use gdb --args /path/to/binary, gdb should start, but the binary should not be started yet. In this state you should be able to set breakpoints, and do anything you'd normally do with gdb. "I was not able to .." is a bit vague. If you update your original question, we might be able to help.

gvdhoorn gravatar image gvdhoorn  ( 2014-12-29 08:41:57 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-12-29 05:55:40 -0600

Seen: 24,485 times

Last updated: Dec 29 '14