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

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 close merge delete 1 Answer Sort by » oldest newest most voted 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.

more

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.

( 2014-12-29 08:23:50 -0500 )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.

( 2014-12-29 08:41:57 -0500 )edit