From 6053cecf4a4ffd19d1ac0a3bb3ffef100ab83fda Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 28 Jan 2020 15:48:42 -0500 Subject: [PATCH] RHBZ1795196: tolerate partial elf + missing dwarf vmlinuz for -d kernel Previous code in dump_symbol_tables() couldn't tolerate the case where new elfutils opened /boot/vmlinuz* as an elf file for the kernel, and could not extract a symbol table from that (nor an absent -debuginfo). New code instead emits a warning and moves on. A special error code triggers return to the dump_kallsyms() path that prior elfutils/stap versions rely on. --- testsuite/systemtap.base/kallsyms.exp | 3 +++ translate.cxx | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/testsuite/systemtap.base/kallsyms.exp b/testsuite/systemtap.base/kallsyms.exp index 8ee52422d..13ca4adec 100644 --- a/testsuite/systemtap.base/kallsyms.exp +++ b/testsuite/systemtap.base/kallsyms.exp @@ -5,7 +5,10 @@ if {![installtest_p]} {untested $test; return} set script {"probe timer.profile {print_stack(backtrace()); exit()}"} set passed 0 +# don't let stap find kernel debuginfo! setenv SYSTEMTAP_DEBUGINFO_PATH $srcdir +setenv DEBUGINFOD_URLS "" +setenv DEBUGINFOD_CACHE_PATH "/dev/null" eval spawn stap --all-modules -e $script expect { diff --git a/translate.cxx b/translate.cxx index f14266702..9e3042742 100644 --- a/translate.cxx +++ b/translate.cxx @@ -6786,7 +6786,17 @@ dump_symbol_tables (Dwfl_Module *m, dwfl_module_info (m, NULL, NULL, &end, NULL, NULL, NULL, NULL); int syments = dwfl_module_getsymtab(m); - DWFL_ASSERT (_F("Getting symbol table for %s", modname), syments >= 0); + if (syments < 0) // RHBZ1795196: elfutils 0.178+ can open vmlinuz as elf.main but fail here + { + c->session.print_warning(_F("libdwfl failure getting symbol table for %s: %s", + modname, dwfl_errmsg(-1))); + return DWARF_CB_ABORT; + + // signal to dump_unwindsyms() to not let things proceed all the way to + // dump_unwindsym_cxt(), which then believes it has all the info for a + // complete record about this module. In the kernel's case, this allows + // PR17921 fallback to /proc/kallsyms via dump_kallsyms(). + } // Look up the relocation basis for symbols int n = dwfl_module_relocations (m); -- 2.43.5