From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 102661 invoked by alias); 1 Jun 2018 02:11:45 -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 102272 invoked by uid 89); 1 Jun 2018 02:11: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,KAM_SHORT,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,KAM_SHORT,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; Fri, 01 Jun 2018 02:11:41 +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 9C0083000702; Fri, 1 Jun 2018 04:11:38 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 518A34107850; Fri, 1 Jun 2018 04:11:38 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] readelf: Fix .debug_types printing with implicit section_info. Date: Fri, 01 Jun 2018 02:11:00 -0000 Message-Id: <1527819083-9232-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/msg00133.txt.bz2 Commit 314e9d7d "readelf: Handle .debug_info first if any other debug section needs it" disabled section_info printing if it was already handled. But section_types was an alias for section_info. So unless section_info was explicitly printed, .debug_types wasn't. Make section_types its own thing to print .debug_types and make section_info imply section_types. Add a testcase to make sure .debug_types is now printed. Signed-off-by: Mark Wielaard --- src/ChangeLog | 9 ++++ src/readelf.c | 16 +++--- tests/ChangeLog | 6 +++ tests/Makefile.am | 2 + tests/run-readelf-types.sh | 122 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 149 insertions(+), 6 deletions(-) create mode 100755 tests/run-readelf-types.sh diff --git a/src/ChangeLog b/src/ChangeLog index 55e735b..fc41892 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,14 @@ 2018-05-31 Mark Wielaard + * readelf.c (enum section_e): Make section_types not an alias of + section_info. + (section_all): Add section_types. + (parse_opt): Add both section_info and section_types for "info" + and "info+". + (print_debug_units): Don't be silent for debug_types. + +2018-05-31 Mark Wielaard + * readelf.c (attr_callback): Only register section_loc when not looking at a split dwarf from a skeleton. diff --git a/src/readelf.c b/src/readelf.c index e2d9c69..78e3cd7 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -237,8 +237,7 @@ static enum section_e section_abbrev = 1, /* .debug_abbrev */ section_aranges = 2, /* .debug_aranges */ section_frame = 4, /* .debug_frame or .eh_frame & al. */ - section_info = 8, /* .debug_info, .debug_types */ - section_types = section_info, + section_info = 8, /* .debug_info, (implies .debug_types) */ section_line = 16, /* .debug_line */ section_loc = 32, /* .debug_loc */ section_pubnames = 64, /* .debug_pubnames */ @@ -248,12 +247,13 @@ static enum section_e section_exception = 1024, /* .eh_frame & al. */ section_gdb_index = 2048, /* .gdb_index */ section_macro = 4096, /* .debug_macro */ - section_addr = 8192, + section_addr = 8192, /* .debug_addr */ + section_types = 16384, /* .debug_types (implied by .debug_info) */ section_all = (section_abbrev | section_aranges | section_frame | section_info | section_line | section_loc | section_pubnames | section_str | section_macinfo | section_ranges | section_exception | section_gdb_index - | section_macro | section_addr) + | section_macro | section_addr | section_types) } print_debug_sections, implicit_debug_sections; /* Select hex dumping of sections. */ @@ -463,10 +463,14 @@ parse_opt (int key, char *arg, else if (strcmp (arg, "frame") == 0 || strcmp (arg, "frames") == 0) print_debug_sections |= section_frame; else if (strcmp (arg, "info") == 0) - print_debug_sections |= section_info; + { + print_debug_sections |= section_info; + print_debug_sections |= section_types; + } else if (strcmp (arg, "info+") == 0) { print_debug_sections |= section_info; + print_debug_sections |= section_types; show_split_units = true; } else if (strcmp (arg, "loc") == 0) @@ -7448,7 +7452,7 @@ print_debug_units (Dwfl_Module *dwflmod, Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg, bool debug_types) { - const bool silent = !(print_debug_sections & section_info); + const bool silent = !(print_debug_sections & section_info) && !debug_types; const char *secname = section_name (ebl, ehdr, shdr); if (!silent) diff --git a/tests/ChangeLog b/tests/ChangeLog index 04b6e75..e3599b2 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,11 @@ 2018-05-31 Mark Wielaard + * run-readelf-types.sh: New test. + * Makefile.am (TESTS): Add run-readelf-types.sh. + (EXTRA_DIST): Likewise. + +2018-05-31 Mark Wielaard + * splitdwarf4-not-split4.dwo.bz2: New test file. * testfile-splitdwarf4-not-split4.debug.bz2: Likewise. * run-readelf-loc.sh: Add test for splitdwarf4-not-split4.dwo diff --git a/tests/Makefile.am b/tests/Makefile.am index 28ba9f7..b45ecdc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -131,6 +131,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ run-backtrace-demangle.sh run-stack-d-test.sh run-stack-i-test.sh \ run-stack-demangled-test.sh run-readelf-zx.sh run-readelf-zp.sh \ run-readelf-addr.sh run-readelf-str.sh \ + run-readelf-types.sh \ run-readelf-dwz-multi.sh run-allfcts-multi.sh run-deleted.sh \ run-linkmap-cut.sh run-aggregate-size.sh run-peel-type.sh \ vdsosyms run-readelf-A.sh \ @@ -250,6 +251,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ testfile_multi.dwz.bz2 testfile_multi_main.bz2 \ testfile-dwzstr.bz2 testfile-dwzstr.multi.bz2 \ run-readelf-addr.sh run-readelf-str.sh \ + run-readelf-types.sh \ run-allfcts-multi.sh \ test-offset-loop.bz2 test-offset-loop.alt.bz2 \ run-prelink-addr-test.sh \ diff --git a/tests/run-readelf-types.sh b/tests/run-readelf-types.sh new file mode 100755 index 0000000..a7af573 --- /dev/null +++ b/tests/run-readelf-types.sh @@ -0,0 +1,122 @@ +#! /bin/sh +# Copyright (C) 2018 Red Hat, Inc. +# This file is part of elfutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# elfutils is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. $srcdir/test-subr.sh + +# Make sure --debug-dump=info implies .debug_types, even when implicit. +# See run-typeiter.sh +testfiles testfile-debug-types + +testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=str --debug-dump=info testfile-debug-types<<\EOF + +DWARF section [28] '.debug_info' at offset 0x1089: + [Offset] + Compilation unit at offset 0: + Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4 + [ b] compile_unit abbrev: 8 + producer (strp) "GNU C++ 4.8.2 20140120 (Red Hat 4.8.2-16) -mtune=generic -march=x86-64 -g -fdebug-types-section" + language (data1) C_plus_plus (4) + comp_dir (strp) "/home/mark/src/elfutils/tests" + low_pc (addr) 0x00000000004005b0
+ high_pc (data8) 11 (0x00000000004005bb) + stmt_list (sec_offset) 0 + [ 29] subprogram abbrev: 9 + external (flag_present) yes + name (strp) "main" + decl_file (data1) (1) + decl_line (data1) 1 + type (ref4) [ 46] + low_pc (addr) 0x00000000004005b0
+ high_pc (data8) 11 (0x00000000004005bb) + frame_base (exprloc) + [ 0] call_frame_cfa + GNU_all_call_sites (flag_present) yes + [ 46] base_type abbrev: 10 + byte_size (data1) 4 + encoding (data1) signed (5) + name (string) "int" + [ 4d] variable abbrev: 11 + name (string) "a" + decl_file (data1) (1) + decl_line (data1) 1 + type (ref_sig8) {18763953736e2de0} + external (flag_present) yes + location (exprloc) + [ 0] addr 0x601030 + [ 64] variable abbrev: 11 + name (string) "b" + decl_file (data1) (1) + decl_line (data1) 1 + type (ref_sig8) {7cf9bbf793fcaf13} + external (flag_present) yes + location (exprloc) + [ 0] addr 0x601031 + +DWARF section [31] '.debug_str' at offset 0x11dd: + Offset String + [ 0] "/home/mark/src/elfutils/tests" + [ 1e] "GNU C++ 4.8.2 20140120 (Red Hat 4.8.2-16) -mtune=generic -march=x86-64 -g -fdebug-types-section" + [ 7e] "main" + +DWARF section [32] '.debug_types' at offset 0x1260: + [Offset] + Type unit at offset 0: + Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4 + Type signature: 0x7cf9bbf793fcaf13, Type offset: 0x38 [38] + [ 17] type_unit abbrev: 1 + language (data1) C_plus_plus (4) + GNU_odr_signature (data8) 4783233826607187165 + stmt_list (sec_offset) 0 + [ 25] structure_type abbrev: 2 + name (string) "A" + signature (ref_sig8) {18763953736e2de0} + declaration (flag_present) yes + sibling (ref4) [ 38] + [ 34] structure_type abbrev: 3 + name (string) "B" + declaration (flag_present) yes + [ 38] structure_type abbrev: 4 + name (string) "B" + byte_size (data1) 1 + decl_file (data1) (1) + decl_line (data1) 1 + specification (ref4) [ 34] + Type unit at offset 67: + Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4 + Type signature: 0x18763953736e2de0, Type offset: 0x25 [25] + [ 5a] type_unit abbrev: 1 + language (data1) C_plus_plus (4) + GNU_odr_signature (data8) 16005269134005989797 + stmt_list (sec_offset) 0 + [ 68] structure_type abbrev: 5 + name (string) "A" + byte_size (data1) 1 + decl_file (data1) (1) + decl_line (data1) 1 + [ 6e] structure_type abbrev: 6 + name (string) "B" + declaration (flag_present) yes + signature (ref_sig8) {7cf9bbf793fcaf13} + [ 79] member abbrev: 7 + name (string) "x" + decl_file (data1) (1) + decl_line (data1) 1 + type (ref4) [ 6e] + data_member_location (data1) 0 +EOF + +exit 0 -- 1.8.3.1