From 1f4929c05d5f3e97db51b818992963074346a79c Mon Sep 17 00:00:00 2001 From: Martin Dorey Date: Thu, 30 Jun 2016 12:52:24 -0700 Subject: [PATCH] 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. --- src/os-linux.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; }