0
$\begingroup$

Gazebo Answers logo

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


Originally posted by winter2016 on Gazebo Answers with karma: 1 on 2016-07-22

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Gazebo Answers logo

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

Originally posted by winter2016 with karma: 1 on 2016-07-26

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

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