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

Debugging ROS package with Qtcreator???

asked 2012-05-27 03:29:46 -0600

tony gravatar image

updated 2014-01-28 17:12:28 -0600

ngrennan gravatar image

Hi, all

I want to integrate ROS with Qtcreator. When I use Qtcreator to debugging the existing ROS package, I met this problem: Lowest section in /usr/lib/ is at 000000f4 Anyone knows how to solve this problem? And is there anyone that using ROS with Qtcreator successfully?

Thanks Tony

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-05-27 07:54:24 -0600

updated 2014-09-15 02:58:23 -0600

bvbdort gravatar image

QtCreator is a good choice for ROS related development as it natively "understands" CMake projects. For easy debugging, the relevant node can be compiled as "Debug" or "RelWithDebInfo" and then started normally via a launch file. One can then attach the QtCreator debugger to the running node via "Debug"->"Start Debugging"->"Attach to running external Application...". This works very well for me and has the advantage that one does not have to setup parameters/remappings etc. for the node in a separate step.

/edit: It is required to follow the instructions in the answer here if one gets a "ptrace operation not allowed" error.

Edit: To make debug build add set(CMAKE_BUILD_TYPE Debug) to CMakeLists.txt

edit flag offensive delete link more


Hi Stefan, I tried to do just as you say, but I'm having problems with ptrace not being allowed. Also, doesn't this mean you cannot set breakpoints from QtCreator? If I try to debug the relevant node from QtCreator itself it seems to get stuck in "Setting breakpoints...", though...

Miguel Prada gravatar image Miguel Prada  ( 2012-09-20 21:38:15 -0600 )edit

I've been digging a bit deeper and it seems that I can start the debugging from the QtCreator interface, set breakpoints and so on, and everything goes fine until I reach a ros::spin() call. Any idea why this might be?

Miguel Prada gravatar image Miguel Prada  ( 2012-09-21 06:09:12 -0600 )edit

How would this work with Groovy/Catkin now that RelWithDebInfo does not seem to make any difference? Thanks in advance.

f_r__ gravatar image f_r__  ( 2013-06-10 07:35:47 -0600 )edit

Hi, i am not able to debug breakpoints, after attaching, its showing assembly code. I did debug build with set( DCMAKE_BUILD_TYPE Debug) in cmakelists.txt.

bvbdort gravatar image bvbdort  ( 2014-09-11 09:13:09 -0600 )edit

If you set from CMakeLists.txt, you have to omit the D in front of CMAKE_BUILD_TYPE. Only when setting the definition from command line (e.g. "catkin_make -DCMAKE_BUILD_TYPE=Debug") you have to add it.

Stefan Kohlbrecher gravatar image Stefan Kohlbrecher  ( 2014-09-15 00:00:12 -0600 )edit

@Stefan Kohlbrecher thanks it worked

bvbdort gravatar image bvbdort  ( 2014-09-15 02:47:27 -0600 )edit

@Stefan Kohlbrecher thanks it worked! As a side note, I had to run qtcreator with "sudo" for the debugging from Qtcreator to work; otherwise it works perfectly.

jespestana gravatar image jespestana  ( 2015-05-15 03:49:31 -0600 )edit

@jespestana Instead of running qtcreator as sudo, you should allow ptrace of non-child-processes for gdb

sudo apt-get install libcap2-bin 
sudo setcap cap_sys_ptrace=eip /usr/bin/gdb

or enable ptrace globally echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope (not recommended)

anonymous userAnonymous ( 2015-07-08 08:34:56 -0600 )edit

answered 2015-08-27 06:00:41 -0600

rbaleksandar gravatar image

updated 2015-08-27 06:03:15 -0600

What @Stefan Kohlbrecher suggests is correct but only partially. Attaching to an external process is an option and in fact it's the only option when you use roslaunch. However hooking to an external process adds an extra layer of complexity and if you can't use ptrace you are basically screwed. If you stick to rosrun you can simply dump the rosrun part and debug your node straight away using the "normal" debug mode in Qt Creator. Why? Because what the node basically is, is a normal application. Rosrun and especially roslaunch simply wrap some ROS functionality (such as passing node parameters via launch files) around it so that it's easier for the user to run nodes. If command line arguments are important for your node, you can modify your node to get those from pure argv (not through the NodeHandle) or read from a text file.

edit flag offensive delete link more


That's why I wrote "for easy debugging" :) You can of course replicate a launch setup via command line (and it's good you explicitely describe how), but this is relatively unwieldy for complex setups.

Stefan Kohlbrecher gravatar image Stefan Kohlbrecher  ( 2015-08-28 04:01:50 -0600 )edit

True, useful only for simple setups. :)

rbaleksandar gravatar image rbaleksandar  ( 2015-08-28 04:18:03 -0600 )edit

Question Tools



Asked: 2012-05-27 03:29:46 -0600

Seen: 11,810 times

Last updated: Aug 27 '15