Created
July 4, 2014 12:32
-
-
Save OliverUv/2bb1f143c2e01b068ebc to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
EXARGS=1 | |
E_BADARGS=65 | |
if [ $# -ne $EXARGS ] ; then | |
cat <<-EOF | |
Usage: $(basename $0) [p] | |
Where p is the path to the .so file you wish to inspect. Prints the | |
source path for a .so file, assuming you have debug symbols for that | |
library installed. GDB and other debuggers will automatically try to | |
load the source from this path, so it is useful to know it if you | |
want to map it to the path where it resides on your computer. | |
This can be done with GDB's substitute-path command (see | |
https://sourceware.org/gdb/onlinedocs/gdb/Source-Path.html), or in | |
Qt Creator's Tools->Options->Debugger->General->Source Paths Mapping. | |
EOF | |
exit $E_BADARGS | |
else | |
XX=$(readelf -n "$1" | sed -nr 's/.*Build ID: (..).*/\1/p') | |
YY=$(readelf -n "$1" | sed -nr 's/.*Build ID: [0-9][0-9]([0-9]*)/\1/p') | |
readelf -wi "/usr/lib/debug/.build-id/$XX/$YY.debug" | grep DW_AT_comp_dir | |
# | awk '{print $8}' if you want pretty output | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment