ROS 2 Application Remote Debugging
This section describes how to remotely debug ROS 2 applications on the Renesas RZ/V2H RDK platform by using GDB.
It covers the required setup, the debugging workflow, and practical notes for running a remote debugging session from VS Code.
Note
Before proceeding, make sure you have completed the previous sections for cross-compilation, deployment, and VS Code workspace configuration.
Prerequisites
Complete the Cross compilation environment setup section.
Make sure VS Code is configured with the required extensions and workspace settings for ROS 2 development, and that the application has been successfully deployed to the RZ/V2H RDK platform.
Make sure the required variables in
settings.jsonare configured correctly, especially:TARGET_IPEnsure that all runtime dependencies required by the application are installed on the target device.
Install
gdbserveron the RZ/V2H RDK platform if it is not already available:sudo apt-get update sudo apt-get install gdbserver
Debugging Workflow
Before starting the debugging workflow, open
settings.jsonand make sure the required variables are configured correctly for the mode you want to use.For debugging with
ros2 run, set:TARGET_IPNODE_PACKAGE_NAMENODE_EXECUTABLE_NAME
For debugging with
ros2 launch, set:TARGET_IPLAUNCH_PACKAGE_NAMELAUNCH_FILE_NAMENODE_PACKAGE_NAMENODE_EXECUTABLE_NAME
Open the Run and Debug view in VS Code:
Press
Ctrl+Shift+D.Select the appropriate debug configuration:
GDB for ROS2 Run to debug an application started with
ros2 runGDB for ROS2 Launch to debug an application started with
ros2 launch
If prompted, enter any required runtime arguments, such as ROS 2 parameters.
Start the corresponding VS Code task to begin the remote debugging session.
For ROS2: Debug Run (GDB), the following command is executed on the target device:
ros2 run --prefix 'gdbserver localhost:<debug_port>' <package_name> <executable_name>
For ROS2: Debug Launch (GDB), the following command is executed on the target device:
ros2 launch --launch-prefix 'gdbserver localhost:<debug_port>' --launch-prefix-filter '<executable_name>' <launch_package_name> <launch_file_name>
Note
The current debug task already performs a debug build before starting the session. Therefore, you do not need to run the build step manually.