From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103649 invoked by alias); 29 May 2018 07:57:46 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 103622 invoked by uid 89); 29 May 2018 07:57:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 May 2018 07:57:39 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 55E183000913; Tue, 29 May 2018 09:57:36 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id E98F94158C1A; Tue, 29 May 2018 09:57:35 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] readelf: Fix regression with multiple files and implicit debug_info reading. Date: Tue, 29 May 2018 07:57:00 -0000 Message-Id: <1527580648-18586-1-git-send-email-mark@klomp.org> X-Mailer: git-send-email 1.8.3.1 X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2018-q2/txt/msg00097.txt.bz2 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 --- 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 + + * readelf.c (print_debug): Record and reset section_info status in + implicit_debug_sections and print_debug_sections. + 2018-05-28 Mark Wielaard * 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 + + * run-readelf-twofiles.sh: Add --debug-dump=loc testcase. + 2018-05-28 Mark Wielaard * 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 + [ 0] range 34, 35 + 0x000000000040049c
.. + 0x000000000040049c
+ [ 0] breg7 -8 + range 35, 46 + 0x000000000040049d .. + 0x00000000004004ad + [ 0] breg7 0 + range 46, 47 + 0x00000000004004ae .. + 0x00000000004004ae + [ 0] breg7 -8 + +testfile14: + + +DWARF section [33] '.debug_loc' at offset 0xca9: + + CU [ b] base: 0x0000000000400468 + [ 0] range 34, 35 + 0x000000000040049c
.. + 0x000000000040049c
+ [ 0] breg7 -8 + range 35, 46 + 0x000000000040049d .. + 0x00000000004004ad + [ 0] breg7 0 + range 46, 47 + 0x00000000004004ae .. + 0x00000000004004ae + [ 0] breg7 -8 +EOF + exit 0 -- 1.8.3.1