Using the GDB debugger with ROS nodes

In order to debug a C/C++ node with the gdb debugger, all we need to know is the location of the node executable. With the ROS Kinetic and catkin packages, the node executable is placed inside the devel/lib/<package> folder within the workspace. For example, in order to run the example1 node from the chapter3_tutorials package in gdb, we have to proceed as follows, starting from the workspace folder (/home/<user>/book_ws):

    $ cd devel/lib/chapter3_tutorials

If you have run catkin_make install, you can also navigate to the install/lib/chapter3_tutorials directory using the following command:

    $ cd install/lib/chapter3_tutorials  

Now we can run the node executable inside gdb with the following command:

    $ gdb example1  
Remember that you must have roscore running before you start your node because it will need the master/server running.

Once roscore is running, you can start your node in gdb by pressing the R key (and Enter), and you can also list the associated source code with the L key as well as set breakpoints or any of the functionalities that gdb comes with. If everything is correct, you should see the following output in the gdb terminal after running the node:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.199.162