Rosanswers logo

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


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

Originally posted by AbdealiJK on ROS Answers with karma: 98 on 2015-06-13

Post score: 1


1 Answer 1


Rosanswers logo

Use the --prefix option to rosrun:

rosrun --prefix 'gdb --args' renv env --env 2 

Originally posted by ahendrix with karma: 47576 on 2015-06-13

This answer was ACCEPTED on the original site

Post score: 4

Original comments

Comment by AbdealiJK on 2015-06-13:
This makes complete sense but I never knew the --prefix option existed. Thanks !

Comment by physincubus on 2016-02-05:
supremely helpful


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.