From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] readelf: Fix regression with multiple files and implicit debug_info reading.
Date: Tue, 29 May 2018 07:57:00 -0000 [thread overview]
Message-ID: <1527580648-18586-1-git-send-email-mark@klomp.org> (raw)
Commit 314e9d7d "readelf: Handle .debug_info first if any other debug
section needs it" introduced a regression when handling multiple files.
The implicit and explicit printing of debuginfo weren't reset and so
the second file would not show (or scan) the .debug_info section when
needed.
Fix by resetting the implicit and explicit section printing flags.
Add a testcase that prints the .debug_loc section for two files and
check that the CUs are resolved.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
src/ChangeLog | 5 +++++
src/readelf.c | 10 +++++++++-
tests/ChangeLog | 4 ++++
tests/run-readelf-twofiles.sh | 43 ++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index b6f66bd..e7ba6cb 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2018-05-29 Mark Wielaard <mark@klomp.org>
+
+ * readelf.c (print_debug): Record and reset section_info status in
+ implicit_debug_sections and print_debug_sections.
+
2018-05-28 Mark Wielaard <mark@klomp.org>
* readelf.c (print_debug_units): Turn "Could not find split compile
diff --git a/src/readelf.c b/src/readelf.c
index bfa1d16..390f244 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -10894,7 +10894,9 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr)
we must make sure to handle it before handling any other debug
section. Various other sections depend on the CU DIEs being
scanned (silently) first. */
- if ((implicit_debug_sections & section_info) != 0)
+ bool implicit_info = (implicit_debug_sections & section_info) != 0;
+ bool explicit_info = (print_debug_sections & section_info) != 0;
+ if (implicit_info)
{
Elf_Scn *scn = NULL;
while ((scn = elf_nextscn (ebl->elf, scn)) != NULL)
@@ -11012,6 +11014,12 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr)
dwfl_end (skel_dwfl);
free (skel_name);
+ /* Turn implicit and/or explicit back on in case we go over another file. */
+ if (implicit_info)
+ implicit_debug_sections |= section_info;
+ if (explicit_info)
+ print_debug_sections |= section_info;
+
reset_listptr (&known_locsptr);
reset_listptr (&known_loclistsptr);
reset_listptr (&known_rangelistptr);
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 4d69515..682fffc 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2018-05-29 Mark Wielaard <mark@klomp.org>
+
+ * run-readelf-twofiles.sh: Add --debug-dump=loc testcase.
+
2018-05-28 Mark Wielaard <mark@klomp.org>
* run-readelf-info-plus.sh: New test.
diff --git a/tests/run-readelf-twofiles.sh b/tests/run-readelf-twofiles.sh
index 46eec7b..fc5f3e7 100755
--- a/tests/run-readelf-twofiles.sh
+++ b/tests/run-readelf-twofiles.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2011 Red Hat, Inc.
+# Copyright (C) 2011, 2018 Red Hat, Inc.
# This file is part of elfutils.
#
# This file is free software; you can redistribute it and/or modify
@@ -21,4 +21,45 @@ testfiles testfile14
testrun >/dev/null ${abs_top_builddir}/src/readelf -w testfile14 testfile14
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=loc testfile14 testfile14 << EOF
+
+testfile14:
+
+
+DWARF section [33] '.debug_loc' at offset 0xca9:
+
+ CU [ b] base: 0x0000000000400468 <caller>
+ [ 0] range 34, 35
+ 0x000000000040049c <main>..
+ 0x000000000040049c <main>
+ [ 0] breg7 -8
+ range 35, 46
+ 0x000000000040049d <main+0x1>..
+ 0x00000000004004ad <main+0x11>
+ [ 0] breg7 0
+ range 46, 47
+ 0x00000000004004ae <main+0x12>..
+ 0x00000000004004ae <main+0x12>
+ [ 0] breg7 -8
+
+testfile14:
+
+
+DWARF section [33] '.debug_loc' at offset 0xca9:
+
+ CU [ b] base: 0x0000000000400468 <caller>
+ [ 0] range 34, 35
+ 0x000000000040049c <main>..
+ 0x000000000040049c <main>
+ [ 0] breg7 -8
+ range 35, 46
+ 0x000000000040049d <main+0x1>..
+ 0x00000000004004ad <main+0x11>
+ [ 0] breg7 0
+ range 46, 47
+ 0x00000000004004ae <main+0x12>..
+ 0x00000000004004ae <main+0x12>
+ [ 0] breg7 -8
+EOF
+
exit 0
--
1.8.3.1
next reply other threads:[~2018-05-29 7:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-29 7:57 Mark Wielaard [this message]
2018-05-31 12:22 ` 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=1527580648-18586-1-git-send-email-mark@klomp.org \
--to=mark@klomp.org \
--cc=elfutils-devel@sourceware.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).