Ask Your Question
1

debug gdb and ROS

asked 2015-06-13 03:16:35 -0500

AbdealiJK gravatar image

updated 2015-06-13 03:21:14 -0500

I have been trying to debug my rosnode with gdb because I am getting a segmentation fault. My package name is renv and the executable inside it is names env

I can run rosrun renv env --env 1 and it works. When I do rosrun renv env --env 2 it gives me a SegFault.

I tried:

gdb --args rosrun renv env --env 2 and gdb says rosrun is not executable (makes sense as it's a shell script)

gdb --args renv env --env 2 and gdb says renv not found

gdb --args env --env 2 and gdb gets confused and trued running /usr/bin/env

I have enabled debugging symbols in CMake using

if(MSVC)  
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")  
else()  
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")  
endif()

And I find a lot of answers pointing to Roslaunch nodes and gdb + valgrind ... and It's difficult for me to understand that ... I think it says to use gdb --args for the gdb part - But I don't know what to put after that :P

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2015-06-13 12:36:44 -0500

ahendrix gravatar image

Use the --prefix option to rosrun:

rosrun --prefix 'gdb --args' renv env --env 2
edit flag offensive delete link more

Comments

This makes complete sense but I never knew the --prefix option existed. Thanks !

AbdealiJK gravatar image AbdealiJK  ( 2015-06-13 12:53:43 -0500 )edit

supremely helpful

physincubus gravatar image physincubus  ( 2016-02-05 10:36:51 -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

1 follower

Stats

Asked: 2015-06-13 03:16:35 -0500

Seen: 7,951 times

Last updated: Jun 13 '15