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

Running rosrun with gdb

asked 2015-12-14 16:29:09 -0500

sykatch gravatar image

updated 2015-12-16 01:33:32 -0500

I am running this in ros:

rosrun object_recognition_capture upload -i final.bag -n 'example' example --commit

object_recognition_capture is a package and I want to run it with all these options. How can I run it with debuger, if there is any possible way to do it? The problem is that this system is c++/python hybrid. Called upload program is a python code, but it calls c++ functions. So I can't use neither gdb nor pdb.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
6

answered 2015-12-15 16:47:33 -0500

demmeln gravatar image

updated 2015-12-16 01:52:57 -0500

If it is a Python script I guess gdb is not what you wan to be using. Instead, Python has pdb ( https://docs.python.org/2/library/pdb... ).

You could try

rosrun --prefix 'python -m pdb' object_recognition_capture upload -i final.bag -n 'example' example --commit

but this is just a guess. I have never started Python scripts this way with rosrun.

Edit: I guess for C++ code called from python scripts you could try to run the python executable with DGB, like described here: https://wiki.python.org/moin/Debuggin...

So best install the debugging symbols for your python interpreter and then try something like this:

rosrun --prefix 'gdb -ex run --args python' object_recognition_capture upload -i final.bag -n 'example' example --commit

Again, I haven't tried this, so its just a guess.

edit flag offensive delete link more

Comments

Thanks, I can run this upload file with pdb, but there is another problem now, I edit my question (c++/python hybrid code).

sykatch gravatar image sykatch  ( 2015-12-16 01:29:35 -0500 )edit

Yes, gdb runs the program now, but it runs it whole, till its end. There is no opportunity to step through the program. I'm trying to figure out what to do about it.

sykatch gravatar image sykatch  ( 2015-12-16 06:44:21 -0500 )edit
1

Yeah this is now not so much about ROS, but rather general Python / C++ debugging. You should be able to find lots of resources on the Web.

demmeln gravatar image demmeln  ( 2015-12-16 07:01:26 -0500 )edit

Yes, I'll try to find something, thanks a lot.

sykatch gravatar image sykatch  ( 2015-12-16 09:01:34 -0500 )edit
5

answered 2015-12-15 00:46:52 -0500

Mani gravatar image

If you are using ROS Indigo or newer, you can use --prefix command line argument of rosrun (ref)

rosrun --prefix 'gdb -ex run --args' object_recognition_capture upload -i final.bag -n 'example' example --commit

On older ROS versions (or as an alternative solution), you can wrap your node in a launch file, then add launch-prefix="gdb -ex run --args" to any <node> tag, as described in this tutorial.

edit flag offensive delete link more

Comments

Thanks for response. I tried it but gdb still says:

upload: not in executable format: File format not recognized
Starting program:  -i final.bag -n example example --commit
No executable file specified.

And it's true, upload is a python code from the package. So again, how to run it?

sykatch gravatar image sykatch  ( 2015-12-15 04:40:21 -0500 )edit

The first line of the file is #!/usr/bin/env python and I already changed permissions chmod 755 upload, but gdb still says it's not an executable.

sykatch gravatar image sykatch  ( 2015-12-15 07:22:33 -0500 )edit

Question Tools

Stats

Asked: 2015-12-14 16:29:09 -0500

Seen: 18,622 times

Last updated: Dec 16 '15