Skip to content

Commit

Permalink
Document LD_LIBRARY_PATH and catching exceptions with GDB when testing (
Browse files Browse the repository at this point in the history
#4175)

* Document LD_LIBRARY_PATH and catching exceptions

Signed-off-by: Ryan Friedman <[email protected]>

* Uniform capitization of gdb

Signed-off-by: Ryan Friedman <[email protected]>

* Remove extra line

Signed-off-by: Ryan Friedman <[email protected]>

---------

Signed-off-by: Ryan Friedman <[email protected]>
(cherry picked from commit d084dd8)
  • Loading branch information
Ryanf55 authored and mergify[bot] committed Feb 20, 2024
1 parent 93eace5 commit 757ec09
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions source/Tutorials/Intermediate/Testing/CLI.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,33 @@ 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.

.. code-block:: console
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

0 comments on commit 757ec09

Please sign in to comment.