diff options
| -rw-r--r-- | libdwfl/ChangeLog | 10 | ||||
| -rw-r--r-- | libdwfl/find-debuginfo.c | 15 | ||||
| -rw-r--r-- | libdwfl/linux-kernel-modules.c | 20 |
3 files changed, 36 insertions, 9 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 69fd2337..462a61d0 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,13 @@ +2016-02-22 Ravi Bangoria <[email protected]> + Mark Wielaard <[email protected]> + + * find-debuginfo.c (find_debuginfo_in_path): Remember whether + debuglink_file is NULL. Try file basename (without .debug) ofr + absolute and relative path if debug_file was NULL. + * linux-kernel-modules.c (try_kernel_name): If try_debug is true call + dwfl_standard_find_debuginfo with NULL debuglink_file, otherwise with + basename of fname. + 2016-02-13 Mark Wielaard <[email protected]> * linux-proc-maps.c (proc_maps_report): Free last_file when ENOEXEC. 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) { diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index 79faf994..54c0b908 100644 --- a/libdwfl/linux-kernel-modules.c +++ b/libdwfl/linux-kernel-modules.c @@ -92,17 +92,21 @@ try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug) if (fd < 0) { Dwfl_Module fakemod = { .dwfl = dwfl }; - /* First try the file's unadorned basename as DEBUGLINK_FILE, - to look for "vmlinux" files. */ - fd = INTUSE(dwfl_standard_find_debuginfo) (&fakemod, NULL, NULL, 0, - *fname, basename (*fname), 0, - &fakemod.debug.name); - if (fd < 0 && try_debug) - /* Next, let the call use the default of basename + ".debug", - to look for "vmlinux.debug" files. */ + + if (try_debug) + /* Passing NULL for DEBUGLINK_FILE searches for both the basenamer + "vmlinux" and the default of basename + ".debug", to look for + "vmlinux.debug" files. */ fd = INTUSE(dwfl_standard_find_debuginfo) (&fakemod, NULL, NULL, 0, *fname, NULL, 0, &fakemod.debug.name); + else + /* Try the file's unadorned basename as DEBUGLINK_FILE, + to look only for "vmlinux" files. */ + fd = INTUSE(dwfl_standard_find_debuginfo) (&fakemod, NULL, NULL, 0, + *fname, basename (*fname), + 0, &fakemod.debug.name); + if (fakemod.debug.name != NULL) { free (*fname); |
