diff options
author | Martin Dorey <martin.dorey@hds.com> | 2016-06-30 12:52:24 -0700 |
---|---|---|
committer | Dave Watson <davejwatson@fb.com> | 2017-01-13 08:36:37 -0800 |
commit | 1f4929c05d5f3e97db51b818992963074346a79c (patch) | |
tree | 85a1a01070411f232737bce6e8a1a1b416aff6e3 /src/os-linux.c | |
parent | a51cf490318eb1f2390bcd36b77794c92107ad52 (diff) | |
download | libunwind-1f4929c05d5f3e97db51b818992963074346a79c.tar.gz |
linux: Add /usr/lib/debug symbol path checking
Debian likes to hive off symbol information to separate -dbg packages,
installing the debug information in a parallel tree rooted at /usr/lib/debug.
libunwind doesn't know how to find these files but it's easy, per the tested,
attached patch, to make it so. I don't see /usr/lib/debug at
http://www.pathname.com/fhs/pub/fhs-2.3.html#USRLIBLIBRARIESFORPROGRAMMINGANDPA
but
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Debugging_with_gdb/separate-debug-files.html
says it's not just Debian and hints it might be driven by gdb. I do see mention
of /usr/lib/debug in libunwind already, but only in a DWARF-specific part of
the code. A minor concern might be checking errno to see if the problem is
ENOENT before trying the alternate path. That might be better than flogging a
mmap problem or being out of file handles or whatever.
Diffstat (limited to 'src/os-linux.c')
-rw-r--r-- | src/os-linux.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/os-linux.c b/src/os-linux.c index 1cc9ba52..652d6f2f 100644 --- a/src/os-linux.c +++ b/src/os-linux.c @@ -37,6 +37,7 @@ tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, struct map_iterator mi; int found = 0, rc; unsigned long hi; + char debug_path[PATH_MAX]; if (maps_init (&mi, pid) < 0) return -1; @@ -57,7 +58,12 @@ tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, { strncpy(path, mi.path, pathlen); } - rc = elf_map_image (ei, mi.path); + snprintf (debug_path, sizeof (debug_path), "/usr/lib/debug%s", mi.path); + rc = elf_map_image (ei, debug_path); + if (rc != 0) + { + rc = elf_map_image (ei, mi.path); + } maps_close (&mi); return rc; } |