public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: [RFC] elfutils: Checks for debuginfo file without .debug extension as well
Date: Tue, 16 Feb 2016 21:51:35 +0530	[thread overview]
Message-ID: <1455639695-8350-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 5557 bytes --]

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 lunchpad bug for the same:
  https://bugs.launchpad.net/ubuntu/+source/systemtap/+bug/1537125

This patch adds functionality to search for file without any extension
followed by searching file having .debug extension.

I've formatted this patch from elfutils-0.165

Before applying patch:

  # strace -o out -e open ./stap -v probe.stp
  Pass 1: parsed user script and 95 library script(s) using 42176virt/32128res/5952shr/25472data kb, in 190usr/20sys/222real ms.
  WARNING: cannot find module kernel debuginfo: No DWARF information found [man warning::debuginfo]
  semantic error: while resolving probe point: identifier 'kernel' at probe.stp:1:7
          source: probe kernel.function("do_fork")
                      ^

  semantic error: no match
  Pass 2: analyzed script: 0 probe(s), 0 function(s), 0 embed(s), 0 global(s) using 66688virt/34496res/7296shr/26432data kb, in 0usr/0sys/28real ms.
  Pass 2: analysis failed.  [man error::pass2]
  Tip: /usr/share/doc/systemtap/README.Debian should help you get started.

  # cat out | grep vmlinu
  open("/boot/vmlinux-3.13.0-76-generic", O_RDONLY) = 3
  open("/lib/modules/3.13.0-76-generic/build/vmlinux.id", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/boot/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/boot/.debug/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/usr/lib/debug/boot/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/var/cache/abrt-di/usr/lib/debug/boot/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/boot/build/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/boot/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/boot/.debug/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/usr/lib/debug/boot/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/var/cache/abrt-di/usr/lib/debug/boot/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/boot/build/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)

After applying patch:

  # strace -o out1 -e open ./stap -v probe.stp
  Pass 1: parsed user script and 95 library script(s) using 41856virt/32128res/5952shr/25472data kb, in 170usr/10sys/189real ms.
  Pass 2: analyzed script: 1 probe(s), 0 function(s), 0 embed(s), 0 global(s) using 242496virt/166912res/105088shr/60608data kb, in 700usr/100sys/1518real ms.
  Pass 3: translated to C into "/tmp/stapbbBu6y/stap_a18833407fc7a78b1251d743383f3fef_989_src.c" using 242496virt/167040res/105216shr/60608data kb, in 0usr/0sys/9real ms.
  Pass 4: compiled C into "stap_a18833407fc7a78b1251d743383f3fef_989.ko" in 6710usr/820sys/8338real ms.
  Pass 5: starting run.
  ^CPass 5: run completed in 0usr/10sys/3477real ms.

  # cat out1 | grep vmlinu
  open("/boot/vmlinux-3.13.0-76-generic", O_RDONLY) = 3
  open("/lib/modules/3.13.0-76-generic/build/vmlinux.id", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/boot/vmlinux-3.13.0-76-generic", O_RDONLY) = 4
  open("/boot/.debug/vmlinux-3.13.0-76-generic", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/boot/vmlinux-3.13.0-76-generic", O_RDONLY) = 4
  open("/usr/lib/debug/boot/vmlinux-3.13.0-76-generic", O_RDONLY) = 4

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
---
 libdwfl/dwfl_module_getdwarf.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
index 0e8810b..ad5054b 100644
--- a/libdwfl/dwfl_module_getdwarf.c
+++ b/libdwfl/dwfl_module_getdwarf.c
@@ -529,11 +529,22 @@ find_debuginfo (Dwfl_Module *mod)
   debuglink_file = INTUSE(dwelf_elf_gnu_debuglink) (mod->main.elf,
 						    &debuglink_crc);
 
-  mod->debug.fd = (*mod->dwfl->callbacks->find_debuginfo) (MODCB_ARGS (mod),
-							   mod->main.name,
-							   debuglink_file,
-							   debuglink_crc,
-							   &mod->debug.name);
+  /* First try to look for vmlinux file */
+  if (debuglink_file == NULL)
+    mod->debug.fd = (*mod->dwfl->callbacks->find_debuginfo) (MODCB_ARGS (mod),
+							     mod->main.name,
+							     basename(mod->main.name),
+							     debuglink_crc,
+							     &mod->debug.name);
+
+  /* Try to look for vmlinux.debug file */
+  if (mod->debug.fd <= 0)
+    mod->debug.fd = (*mod->dwfl->callbacks->find_debuginfo) (MODCB_ARGS (mod),
+							     mod->main.name,
+							     debuglink_file,
+							     debuglink_crc,
+							     &mod->debug.name);
+
   Dwfl_Error result = open_elf (mod, &mod->debug);
   if (result == DWFL_E_NOERROR && mod->debug.address_sync != 0)
     result = find_prelink_address_sync (mod, &mod->debug);
-- 
1.9.1

             reply	other threads:[~2016-02-16 16:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 16:21 Ravi Bangoria [this message]
2016-02-16 16:45 Mark Wielaard
2016-02-17  8:20 Ravi Bangoria
2016-02-17 15:49 Mark Wielaard
2016-02-19  9:37 Ravi Bangoria
2016-02-19 15:11 Mark Wielaard
2016-02-20 13:40 Ravi Bangoria
2016-02-22 13:45 Mark Wielaard
2016-02-22 17:12 Ravi Bangoria
2016-02-22 19:54 Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455639695-8350-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com \
    --to=ravi.bangoria@linux.vnet.ibm.com \
    --cc=elfutils-devel@lists.fedorahosted.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).