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

Debugging ROS package with Qtcreator???

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

tony gravatar image

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

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/libicudata.so.42 is .note.gnu.build-id 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
11

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

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

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

Comments

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 -0500 )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 -0500 )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 -0500 )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 -0500 )edit
1

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 -0500 )edit

@Stefan Kohlbrecher thanks it worked

bvbdort gravatar image bvbdort  ( 2014-09-15 02:47:27 -0500 )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 -0500 )edit
1

@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 -0500 )edit
0

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

rbaleksandar gravatar image

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

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

Comments

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 -0500 )edit

True, useful only for simple setups. :)

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

Question Tools

2 followers

Stats

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

Seen: 11,837 times

Last updated: Aug 27 '15