* [PATCH] readelf: Fix regression with multiple files and implicit debug_info reading.
@ 2018-05-29 7:57 Mark Wielaard
2018-05-31 12:22 ` Mark Wielaard
0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2018-05-29 7:57 UTC (permalink / raw)
To: elfutils-devel; +Cc: Mark Wielaard
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] readelf: Fix regression with multiple files and implicit debug_info reading.
2018-05-29 7:57 [PATCH] readelf: Fix regression with multiple files and implicit debug_info reading Mark Wielaard
@ 2018-05-31 12:22 ` Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2018-05-31 12:22 UTC (permalink / raw)
To: elfutils-devel
On Tue, 2018-05-29 at 09:57 +0200, Mark Wielaard wrote:
> 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.
Pushed to master.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-31 12:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-29 7:57 [PATCH] readelf: Fix regression with multiple files and implicit debug_info reading Mark Wielaard
2018-05-31 12:22 ` Mark Wielaard
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).