How to debug ROS package [closed]

asked 2023-07-13 21:02:44 -0600

JohnDoe gravatar image

Hi!

I'm new to C++ and ROS.

Recently, I want to add some breakpoints and debug these ROS libraries step by step to learn how these member functions are called and run.

However, I found that all the functions of these ROS libraries are linked to .h files and I cannot see what is inside these functions.

Are there any available ways?

Thanks in advance!

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by tfoote
close date 2023-07-14 15:01:37.808743

Comments

This is a generic c++ question about debugging not about ROS or robotics. I recommend that you read up on gdb and search for some tutorials on c++ debugging with gdb. Header based implementations are still debuggable.

tfoote gravatar image tfoote  ( 2023-07-14 15:01:29 -0600 )edit

Hi! @tfoote As far as I know, installing via sudo apt-get install only installs some necessary binaries files, and hence I can only retrieve the header file. In contrast, source install can keep some cpp files and I can add breakpoints or modify these ROS packages. Am I right?

JohnDoe gravatar image JohnDoe  ( 2023-07-14 22:28:29 -0600 )edit

You're right about the default debs not installing the source files by default. But you're talking about linking to headers and the debug symbols are what you want mostly. I would suggest that you learn how to use a debugger on a much smaller program before trying to jump right into a full ROS system. The use of debuggers is a skill that you will want to develop incrementally. There's a lot of documentation of that elsewhere that's not ROS specific. You'll be much better off learning it there. And then in that context ROS is just like any other c++ library when you know how to setup and use your choice of debugger.

tfoote gravatar image tfoote  ( 2023-07-14 23:18:31 -0600 )edit

Thanks for your instruction!

JohnDoe gravatar image JohnDoe  ( 2023-07-15 00:30:18 -0600 )edit