-
Notifications
You must be signed in to change notification settings - Fork 32
Debugging plug ins
Milan Jelisavcic edited this page Jun 30, 2017
·
1 revision
debugging (tol)-revolve cpp code with gdb:
In case a problem occurs with a C++ plugin for gazebo, which can not be fixed/reproduced without running gazebo debugging can be frustrating and time consuming when only using print statements, especially since not all the output might be given.
One way to solve this problem is to inject gdb
into process when it is already running using the following steps:
- optional only if the error occurs very fast and injection is not possible that fast: add
sleep(20)
to a line that occurs before the code crashed, then there is usually enough time. - add
-g
to the compiler options to have the option to view the current line of code etc. - open
htop/top
to get the PID of the gazebo process you started - run the code
- obtain the PID
- run
sudo gdb --pid=<pid>
optionally with--tui
for a nicer interface
if the code crashes before reaching the sleep(20)
even though the code up until there is surely correct this is often due to a linking problem (caused by errors in the cmake)
For more information about the Triangle of Life concept visit http://evosphere.eu/.
_________________
/ Premature \
| optimization |
| is the root of |
| all evil. |
| |
\ -- D.E. Knuth /
-----------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||