diff --git a/source/Tutorials/Intermediate/Testing/CLI.rst b/source/Tutorials/Intermediate/Testing/CLI.rst index 3579c52b2f..cdd8374ef8 100644 --- a/source/Tutorials/Intermediate/Testing/CLI.rst +++ b/source/Tutorials/Intermediate/Testing/CLI.rst @@ -35,7 +35,7 @@ To see the exact test cases which fail, use the ``--verbose`` flag: Debugging tests with GDB ^^^^^^^^^^^^^^^^^^^^^^^^ -If a C++ test is failing, gdb can be used directly on the test executable in the build directory. +If a C++ test is failing, GDB can be used directly on the test executable in the build directory. Ensure to build the code in debug mode. Since the previous build type may be cached by CMake, clean the cache and rebuild. @@ -43,9 +43,25 @@ Since the previous build type may be cached by CMake, clean the cache and rebuil colcon build --cmake-clean-cache --mixin debug -Next, run the test directly through gdb. +In order for GDB to load debug symbols for any shared libraries called, make sure to source your environment. +This configures the value of ``LD_LIBRARY_PATH``. + +.. code-block:: console + + source install/setup.bash + +Finally, run the test directly through GDB. For example: .. code-block:: console gdb -ex run ./build/rcl/test/test_logging + +If the code is throwing an unhandled exception, you can catch it in GDB before gtest handles it. + +.. code-block:: console + + gdb ./build/rcl/test/test_logging + catch throw + run +