Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document LD_LIBRARY_PATH and catching exceptions with GDB when testing #4175

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

fujitatomoya marked this conversation as resolved.
Show resolved Hide resolved
Loading