Skip to content

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:

  1. 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.
  2. add -g to the compiler options to have the option to view the current line of code etc.
  3. open htop/top to get the PID of the gazebo process you started
  4. run the code
  5. obtain the PID
  6. 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)

_________________
/ Premature      \
| optimization   |
| is the root of |
| all evil.      |
|                |
\ -- D.E. Knuth  /
-----------------
    \   ^__^
     \  (oo)\_______
        (__)\       )\/\
            ||----w |
            ||     ||
Clone this wiki locally