Debug ros node with GDB
April 29, 2021 · View on GitHub
Abstract
Debug the ros node with GDB. Some error (such as segment fault) is difficult to find. The GDB is a good choice to debug it.
Simple steps to use GDB to debug ros node
- Step 1: compile the ros package
$ catkin_make -DCMAKE_BUILD_TYPE=Debug - Step 2: run the ros node you want to debug with specified format
ros node
or (launch)$ rosrun --prefix 'gdb -ex run --args' package node
or (python)$ <node pkg="package" type="node" name="node_name" output="screen" launch-prefix="gdb -ex run --args" >/>launch-prefix="xterm -e python -m pdb "
additional commands for GDB debugging
| commands | functions |
|---|---|
| bt | show location of error, e.g. segment fault |
| info files | show the detail information of the debugged file |
| info var | show all the global and static variables |
| info local | show all the local variables |
| More | Link, book |