Allow getting full path with gdb even for absolute file path#204
Open
kenkinming2002 wants to merge 2 commits intonakst:masterfrom
Open
Allow getting full path with gdb even for absolute file path#204kenkinming2002 wants to merge 2 commits intonakst:masterfrom
kenkinming2002 wants to merge 2 commits intonakst:masterfrom
Conversation
This is necessary due to the usage of debuginfod to distribute debug information by some distributions (e.g. Arch Linux). In such a case, the location of source files given by the "bt" will be different from that given by "info source". The former comes from where the package is compiled whereas the latter will be somewhere under ~/.cache/debuginfod_client. Checking if a path is absolute cannot distinguish both cases. For example, running "gdb clang++" with debuginfod enabled (with "set debuginfod enabled on" and appropriate DEBUGINFOD_URLS set) and stopping at main with "start": Output of "bt": (gdb) bt #0 main () at /usr/src/debug/clang/clang-19.1.7.src/build/tools/driver/clang-driver.cpp:15 Output of "info source" (gdb) info source Current source file is /usr/src/debug/clang/clang-19.1.7.src/build/tools/driver/clang-driver.cpp Compilation directory is /usr/src/debug/clang/clang-19.1.7.src/build Located in /home/kenkwok/.cache/debuginfod_client/26bd1c4553c96fda902722481961f99b194900ea/source-d8de072c-#usr#src#debug#clang#clang-19.1.7.src#build#tools#driver#clang-driver.cpp Contains 18 lines. Source language is c++. Producer is GNU GIMPLE 14.2.1 20250207 -march=x86-64 -mtune=generic -mno-omit-leaf-frame-pointer -g -g1 -O3 -O3 -O2 -O3 -fno-openmp -fno-openacc -fcf-protection=full -funwind-tables -fno-plt -fexceptions -fstack-clash-protection -fcf-protection=full -fno-omit-frame-pointer -fPIC -fno-semantic-interposition -fno-lifetime-dse -ffunction-sections -fdata-sections -fno-common -fno-strict-aliasing -fltrans. Compiled with DWARF 5 debugging format. Does not include preprocessor macro info. (gdb) In both case, the path is absolute but the path in the former case does not exist as Arch is not a source-based distro.
3b071c0 to
488c16c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is necessary due to the usage of debuginfod to distribute debug information by some distributions (e.g. Arch Linux). In such a case, the location of source files given by the "bt" will be different from that given by "info source". The former comes from where the package is compiled whereas the latter will be somewhere under ~/.cache/debuginfod_client.
Checking if a path is absolute cannot distinguish both cases.
For example, running "gdb clang++" with debuginfod enabled (with "set debuginfod enabled on" and appropriate DEBUGINFOD_URLS set) and stopping at main with "start":
Output of "bt":
(gdb) bt
#0 main () at /usr/src/debug/clang/clang-19.1.7.src/build/tools/driver/clang-driver.cpp:15
Output of "info source"
(gdb) info source
Current source file is /usr/src/debug/clang/clang-19.1.7.src/build/tools/driver/clang-driver.cpp
Compilation directory is /usr/src/debug/clang/clang-19.1.7.src/build
Located in /home/kenkwok/.cache/debuginfod_client/26bd1c4553c96fda902722481961f99b194900ea/source-d8de072c-#usr#src#debug#clang#clang-19.1.7.src#build#tools#driver#clang-driver.cpp
Contains 18 lines.
Source language is c++.
Producer is GNU GIMPLE 14.2.1 20250207 -march=x86-64 -mtune=generic -mno-omit-leaf-frame-pointer -g -g1 -O3 -O3 -O2 -O3 -fno-openmp -fno-openacc -fcf-protection=full -funwind-tables -fno-plt -fexceptions -fstack-clash-protection -fcf-protection=full -fno-omit-frame-pointer -fPIC -fno-semantic-interposition -fno-lifetime-dse -ffunction-sections -fdata-sections -fno-common -fno-strict-aliasing -fltrans.
Compiled with DWARF 5 debugging format.
Does not include preprocessor macro info.
(gdb)
In both case, the path is absolute but the path in the former case does not exist as Arch is not a source-based distro.