Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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/194be8500fef81593f79607a21ee2badd9700a0e/drcsim_gazebo/scripts/run_gzserver_gdb?at=default&fileviewer=file-view-default

https://bitbucket.org/osrf/drcsim/src/194be8500fef81593f79607a21ee2badd9700a0e/drcsim_gazebo/scripts/gdbrun?at=default&fileviewer=file-view-default

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