Home | Tutorials | Wiki | Issues
Ask Your Question
0

How to debug a gazebo model plugin with setting breaktpoints and the drcsim run_gzserver_gdb script?

asked 2016-07-22 07:49:45 -0500

winter2016 gravatar image

Hello,

I am quite new to gazebo and I would like to debug my gazebo plugin with breakpoints.
I found a few questions here that do point out a similar problem.

Some of the answers included the run_gzserver_gdb script of the drcSim. I copied the related drcSim scripts and only changed the package to my own. I did not modify the actual gdbrun script.

https://bitbucket.org/osrf/drcsim/src...

https://bitbucket.org/osrf/drcsim/src...

When I run my project with these scripts the server just starts running and I can only interact with gdb once my project has crashed.

#!/bin/bash
#gdbrun of drcSim
extra_text=""

if [ "$1" == "--break-main" ]; then
  extra_text="break main"
  shift
fi
EXEC="$1"
shift

run_text="run"
for a in "$@"; do
  run_text="${run_text} \"$a\""
done

TMPFILE=/tmp/gdbrun.$$.$#.tmp
cat > ${TMPFILE} <<EOF
${extra_text}
${run_text}
EOF

gdb -x ${TMPFILE} "${EXEC}"
rm -f "${TMPFILE}"

I get that the problem is somewhere along these lines:

run_text="run"
for a in "$@"; do
  run_text="${run_text} \"$a\""
done

TMPFILE=/tmp/gdbrun.$$.$#.tmp
cat > ${TMPFILE} <<EOF
${extra_text}
${run_text}
EOF

The problem is that the gazebo sever is run directly since the temp file will only create a run confguration:

run  (gzserver and configuration args I pass to gzserver)

If I try running this by hand and add breackpoints the server does not start properly and shuts down after 30 seconds.

  • How do I have to modify the script so I can set breackpoints?
  • If it is not possible to use these scripts how could I possibly debug my plugin with gdb and breakpoints?

Regards

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-07-26 08:21:20 -0500

winter2016 gravatar image

Here is the solution, that worked for me. Add a breakpoint to wahtever you want to debug. Do so at the very beginning of the gdb command in gdbrun.

gdb -ex "set breakpoint pending on"  -ex "break <some source file from plugin>:line_nr" -x ${TMPFILE} "${EXEC}"

For debugging:

  1. Only start the gzserver in the roslaunchfile
  2. Check in the output if the breakpoints are set pending
  3. start the gzclient manually in an extra window
  4. set additional breakpoints if required once gdb stops the gzserver
  5. usual gdb debugging
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-07-22 07:49:45 -0500

Seen: 559 times

Last updated: Jul 26 '16