Bug 20288 - dwfl/elfutils problem when gathering line-record data for *symfile/*symline functions
Summary: dwfl/elfutils problem when gathering line-record data for *symfile/*symline f...
Status: NEW
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-21 21:38 UTC by Frank Ch. Eigler
Modified: 2017-10-11 10:48 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Ch. Eigler 2016-06-21 21:38:58 UTC
random git stap build running against f22

% ./stap -V
Systemtap translator/driver (version 3.1/0.166, commit release-3.0-110-g713029398d38 + changes)

% ./stap -p4 -e 'probe process("/bin/ls").function("main") { log(usymfile(0)) }' --vp 0044
[...]
dump_unwindsyms /usr/bin/ls index=2 base=0x400000
Found build-id in /usr/bin/ls, length 20, start at 0x400284
WARNING: No debug line data for /usr/bin/ls, no error
[...]

wait, wha?

% rpm -qf /usr/bin/ls
coreutils-8.23-11.fc22.x86_64
% rpm -q coreutils-debuginfo
coreutils-debuginfo-8.23-11.fc22.x86_64

% readelf -S /usr/lib/debug/usr/bin/ls.debug | grep -A1 debug.line
  [31] .debug_line       PROGBITS         0000000000000000  00017bc3
       0000000000006668  0000000000000000           0     0     1
Comment 1 Mark Wielaard 2016-06-21 22:08:08 UTC
The dwfl_errmsg (-1) looks bogus (or at least way too late). The code seems to use raw libelf calls. Here is a quick untested patch:

diff --git a/translate.cxx b/translate.cxx
index 4c91660..271f0e1 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -6453,6 +6453,7 @@ static void
 dump_line_tables (Dwfl_Module *m, unwindsym_dump_context *c,
                   const char *, Dwarf_Addr)
 {
+  Dwarf* dwarf;
   Elf* elf;
   Elf_Scn* scn = NULL;
   Elf_Data* data;
@@ -6462,7 +6463,11 @@ dump_line_tables (Dwfl_Module *m, unwindsym_dump_context *c,
 
   dwfl_module_info (m, NULL, &start, NULL, NULL, NULL, NULL, NULL);
 
-  elf = dwfl_module_getelf (m, &bias);
+  dwarf = dwfl_module_getdwarf (m, &bias);
+  if (dwarf == NULL)
+    return;
+
+  elf = dwarf_getelf (dwarf);
   if (elf == NULL)
     return;