From 7802e6e57d48189e339b4ab40189eb44d8123559 Mon Sep 17 00:00:00 2001 From: Ravi Bangoria Date: Tue, 16 Feb 2016 21:51:35 +0530 Subject: 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 Signed-off-by: Mark Wielaard --- libdwfl/linux-kernel-modules.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'libdwfl/linux-kernel-modules.c') 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); -- cgit v1.2.3