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

Conversation

Ryanf55
Copy link
Contributor

@Ryanf55 Ryanf55 commented Feb 16, 2024

Background

I ran into another test failure that I couldn't track down. According to the guide I wrote earlier, debug symbols only get loaded on the test itself.

Now, users are recommended to source their workspace. With this, gdb is aware of the path to all the libraries and get debug symbols correctly. I presume this is through LD_LIBRARY_PATH, but I could be wrong.

Additionally, exceptions thrown in ROS libraries are caught by gtest, and if you want to have gdb find them first, the workflow is slightly different.

There may be better ways to do this, but the workflow works well for me.

Real world example

ANYbotics/grid_map#401 (comment)

Why is this necessary

Well, I have grid_map installed with binaries, and then develop locally in the workspace with debug. The installed binaries are in release mode, so gdb is actually running the wrong library and I'm testing the wrong code under GDB. Forgetting to source the environment means you might be debugging the wrong code! This explains why any modifications I did seemed to have no effect.

What about VSCode

VSCode is great, but can't run a script before starting a debug session. This means that the GDB configuration cannot run source install/setup.bash and have the environment configured correctly. I have yet to find a way around this other than telling people to learn CLI GDB.
https://stackoverflow.com/questions/43836861/how-to-run-a-command-in-visual-studio-code-with-launch-json

Related

#3899

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, this is an improvement. i have a couple of minor comments.

source/Tutorials/Intermediate/Testing/CLI.rst Outdated Show resolved Hide resolved
source/Tutorials/Intermediate/Testing/CLI.rst Show resolved Hide resolved
Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given my comment below, I'm fine with this as-is. But I'd like to get @fujitatomoya to approve before we merge.

source/Tutorials/Intermediate/Testing/CLI.rst Show resolved Hide resolved
@fujitatomoya fujitatomoya merged commit d084dd8 into ros2:rolling Feb 16, 2024
3 checks passed
@Ryanf55 Ryanf55 deleted the document-improved-gdb-testing-workflow branch February 16, 2024 21:47
@Ryanf55
Copy link
Contributor Author

Ryanf55 commented Feb 20, 2024

Can we get a backport to iron and humble? :)

@clalancette
Copy link
Contributor

@Mergifyio backport iron humble

Copy link
Contributor

mergify bot commented Feb 20, 2024

backport iron humble

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Feb 20, 2024
#4175)

* Document LD_LIBRARY_PATH and catching exceptions

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>

* Uniform capitization of gdb

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>

* Remove extra line

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>

---------

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
(cherry picked from commit d084dd8)
mergify bot pushed a commit that referenced this pull request Feb 20, 2024
#4175)

* Document LD_LIBRARY_PATH and catching exceptions

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>

* Uniform capitization of gdb

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>

* Remove extra line

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>

---------

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
(cherry picked from commit d084dd8)
clalancette pushed a commit that referenced this pull request Feb 20, 2024
#4175) (#4176)

* Document LD_LIBRARY_PATH and catching exceptions

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>

* Uniform capitization of gdb

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>

* Remove extra line

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>

---------

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
(cherry picked from commit d084dd8)

Co-authored-by: Ryan <ryanfriedman5410+github@gmail.com>
clalancette pushed a commit that referenced this pull request Feb 20, 2024
#4175) (#4177)

* Document LD_LIBRARY_PATH and catching exceptions

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>

* Uniform capitization of gdb

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>

* Remove extra line

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>

---------

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
(cherry picked from commit d084dd8)

Co-authored-by: Ryan <ryanfriedman5410+github@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants