diff options
author | Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> | 2016-02-16 21:51:35 +0530 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2016-02-22 20:46:30 +0100 |
commit | 7802e6e57d48189e339b4ab40189eb44d8123559 (patch) | |
tree | 9126c9440766f6064f561735497a2bb542b188a4 /libdwfl/find-debuginfo.c | |
parent | 134684912cd18e824172b667ba13d1016782f93f (diff) | |
download | elfutils-7802e6e57d48189e339b4ab40189eb44d8123559.tar.gz |
libdwfl: Check for kernel debuginfo file without .debug extension as well
Elfutils, looking for kernel debuginfo file, tries to find it at
various places. If elfutils finds /boot/vmlinu*x* file, it checks
for debufginfo section. If debuginfo is not present, it saves it as
'main elf' and continue looking for debuginfo file having .debug
extension i.e. vmlinux-RELEASE.debug.
'Ubuntu on powerpc' installs kernel as /boot/vmlinux and installs
debuginfo without any extension as /usr/lib/debug/boot/vmlinux-RELEASE
and hence, elfutils is not able to find the debuginfo file.
Here is the launchpad bug for the same:
https://bugs.launchpad.net/ubuntu/+source/systemtap/+bug/1537125
This patch adds functionality to search for a kernel or debuginfo file
both with and without .debug extension.
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'libdwfl/find-debuginfo.c')
-rw-r--r-- | libdwfl/find-debuginfo.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c index 72461bc3..80515dbd 100644 --- a/libdwfl/find-debuginfo.c +++ b/libdwfl/find-debuginfo.c @@ -163,7 +163,11 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, const char *file_basename = file_name == NULL ? NULL : basename (file_name); char *localname = NULL; - if (debuglink_file == NULL) + + /* We invent a debuglink .debug name if NULL, but then want to try the + basename too. */ + bool debuglink_null = debuglink_file == NULL; + if (debuglink_null) { /* For a alt debug multi file we need a name, for a separate debug name we may be able to fall back on file_basename.debug. */ @@ -231,6 +235,10 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, check = *p++ == '+'; check = check && cancheck; + /* Try the basename too, if we made up the debuglink name and this + is not the main directory. */ + bool try_file_basename; + const char *dir, *subdir, *file; switch (p[0]) { @@ -239,6 +247,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, dir = file_dirname; subdir = NULL; file = debuglink_file; + try_file_basename = false; break; case '/': /* An absolute path says to look there for a subdirectory @@ -268,6 +277,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, subdir = NULL; file = basename (debuglink_file); } + try_file_basename = debuglink_null; break; default: /* A relative path says to try a subdirectory of that name @@ -275,11 +285,14 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, dir = file_dirname; subdir = p; file = debuglink_file; + try_file_basename = debuglink_null; break; } char *fname = NULL; int fd = try_open (&main_stat, dir, subdir, file, &fname); + if (fd < 0 && try_file_basename) + fd = try_open (&main_stat, dir, subdir, file_basename, &fname); if (fd < 0) switch (errno) { |