From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58320 invoked by alias); 29 Nov 2017 16:06:25 -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 58269 invoked by uid 89); 29 Nov 2017 16:06:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KB_WAM_FROM_NAME_SINGLEWORD autolearn=ham version=3.3.2 spammy= X-Spam-Status: No, score=-25.7 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KB_WAM_FROM_NAME_SINGLEWORD 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; Wed, 29 Nov 2017 16:06:23 +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 BD3A530007B4; Wed, 29 Nov 2017 17:06:20 +0100 (CET) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id B8F3B413C06B; Wed, 29 Nov 2017 17:06:20 +0100 (CET) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH 3/5] readelf: Print actual file for decl_file and call_file attributes. Date: Wed, 29 Nov 2017 16:06:00 -0000 Message-Id: <1511971553-30135-4-git-send-email-mark@klomp.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1511971553-30135-1-git-send-email-mark@klomp.org> References: <1511971553-30135-1-git-send-email-mark@klomp.org> X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2017-q4/txt/msg00080.txt.bz2 When we see a DW_AT_decl_file or DW_AT_call_file attribute print the actual file name. The current interface gives us a full (absolute) patch, but we only want to show the file name for now to not clutter the output too much. This helps a lot when trying to determine where something was declared if you are just looking at the DIE tree. Otherwise you'll have to cross match the number by hand with the corresponding line table entry. Signed-off-by: Mark Wielaard --- src/ChangeLog | 5 +++++ src/readelf.c | 22 ++++++++++++++++++++++ tests/ChangeLog | 5 +++++ tests/run-readelf-dwz-multi.sh | 32 ++++++++++++++++---------------- tests/run-readelf-zdebug-rel.sh | 10 +++++----- 5 files changed, 53 insertions(+), 21 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e7e598d..12cd571 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2017-11-29 Mark Wielaard + * readelf.c (attr_callback): Set valuestr to resolved file name + for DW_AT_decl_file and DW_AT_call_file. + +2017-11-29 Mark Wielaard + * readelf.c (print_debug_units): Print abbrev code after DIE tag. 2017-11-29 Mark Wielaard diff --git a/src/readelf.c b/src/readelf.c index e9887c4..8661ba8 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -6126,6 +6126,28 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) case DW_AT_discr_list: valuestr = dwarf_discr_list_name (num); break; + case DW_AT_decl_file: + case DW_AT_call_file: + { + /* Try to get the actual file, the current interface only + gives us full paths, but we only want to show the file + name for now. */ + Dwarf_Die cudie; + if (dwarf_cu_die (cbargs->cu, &cudie, + NULL, NULL, NULL, NULL, NULL, NULL) != NULL) + { + Dwarf_Files *files; + size_t nfiles; + if (dwarf_getsrcfiles (&cudie, &files, &nfiles) == 0) + { + valuestr = dwarf_filesrc (files, num, NULL, NULL); + char *filename = strrchr (valuestr, '/'); + if (filename != NULL) + valuestr = filename + 1; + } + } + } + break; default: /* Nothing. */ break; diff --git a/tests/ChangeLog b/tests/ChangeLog index f522a69..c9fc53a 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,10 @@ 2017-11-29 Mark Wielaard + * run-readelf-dwz-multi.sh: Add expected file names. + * run-readelf-zdebug-rel.sh: Likewise. + +2017-11-29 Mark Wielaard + * run-readelf-dwz-multi.sh: Add expected abbrev codes. * run-readelf-zdebug-rel.sh: Likewise. diff --git a/tests/run-readelf-dwz-multi.sh b/tests/run-readelf-dwz-multi.sh index 21456fd..4f317ac 100755 --- a/tests/run-readelf-dwz-multi.sh +++ b/tests/run-readelf-dwz-multi.sh @@ -100,7 +100,7 @@ DWARF section [28] '.debug_info' at offset 0x1078: [ 31] subprogram abbrev: 3 external (flag_present) yes name (strp) "main" - decl_file (data1) 1 + decl_file (data1) main.c (1) decl_line (data1) 3 prototyped (flag_present) yes type (GNU_ref_alt) [ 3e] @@ -112,21 +112,21 @@ DWARF section [28] '.debug_info' at offset 0x1078: sibling (ref_udata) [ 6e] [ 48] formal_parameter abbrev: 8 name (strp) "argc" - decl_file (data1) 1 + decl_file (data1) main.c (1) decl_line (data1) 3 type (GNU_ref_alt) [ 3e] location (exprloc) [ 0] fbreg -36 [ 56] formal_parameter abbrev: 4 name (strp) "argv" - decl_file (data1) 1 + decl_file (data1) main.c (1) decl_line (data1) 3 type (ref_udata) [ 6e] location (exprloc) [ 0] fbreg -48 [ 61] variable abbrev: 7 name (string) "b" - decl_file (data1) 1 + decl_file (data1) main.c (1) decl_line (data1) 5 type (GNU_ref_alt) [ 5a] location (exprloc) @@ -161,7 +161,7 @@ DWARF section [28] '.debug_info' at offset 0x1078: [ 31] subprogram abbrev: 3 external (flag_present) yes name (strp) "main" - decl_file (data1) 1 + decl_file (data1) main.c (1) decl_line (data1) 3 prototyped (flag_present) yes type (GNU_ref_alt) [ 3e] @@ -173,21 +173,21 @@ DWARF section [28] '.debug_info' at offset 0x1078: sibling (ref_udata) [ 6e] [ 48] formal_parameter abbrev: 8 name (strp) "argc" - decl_file (data1) 1 + decl_file (data1) main.c (1) decl_line (data1) 3 type (GNU_ref_alt) [ 3e] location (exprloc) [ 0] fbreg -36 [ 56] formal_parameter abbrev: 4 name (strp) "argv" - decl_file (data1) 1 + decl_file (data1) main.c (1) decl_line (data1) 3 type (ref_udata) [ 6e] location (exprloc) [ 0] fbreg -48 [ 61] variable abbrev: 7 name (string) "b" - decl_file (data1) 1 + decl_file (data1) main.c (1) decl_line (data1) 5 type (GNU_ref_alt) [ 5a] location (exprloc) @@ -218,7 +218,7 @@ DWARF section [25] '.debug_info' at offset 0x106c: [ 2b] subprogram abbrev: 1 external (flag_present) yes name (strp) "call_foo" - decl_file (data1) 1 + decl_file (data1) shared.c (1) decl_line (data1) 3 prototyped (flag_present) yes type (GNU_ref_alt) [ 3e] @@ -229,7 +229,7 @@ DWARF section [25] '.debug_info' at offset 0x106c: GNU_all_call_sites (flag_present) yes [ 41] formal_parameter abbrev: 4 name (string) "fb" - decl_file (data1) 1 + decl_file (data1) shared.c (1) decl_line (data1) 3 type (GNU_ref_alt) [ 76] location (exprloc) @@ -258,7 +258,7 @@ DWARF section [25] '.debug_info' at offset 0x106c: [ 2b] subprogram abbrev: 1 external (flag_present) yes name (strp) "call_foo" - decl_file (data1) 1 + decl_file (data1) shared.c (1) decl_line (data1) 3 prototyped (flag_present) yes type (GNU_ref_alt) [ 3e] @@ -269,7 +269,7 @@ DWARF section [25] '.debug_info' at offset 0x106c: GNU_all_call_sites (flag_present) yes [ 41] formal_parameter abbrev: 4 name (string) "fb" - decl_file (data1) 1 + decl_file (data1) shared.c (1) decl_line (data1) 3 type (GNU_ref_alt) [ 76] location (exprloc) @@ -297,7 +297,7 @@ DWARF section [28] '.debug_info' at offset 0x1088: [ 2b] subprogram abbrev: 4 external (flag_present) yes name (GNU_strp_alt) "main" - decl_file (data1) 1 + decl_file (data1) main.c (1) decl_line (data1) 8 prototyped (flag_present) yes type (GNU_ref_alt) [ 30] @@ -308,21 +308,21 @@ DWARF section [28] '.debug_info' at offset 0x1088: GNU_all_call_sites (flag_present) yes [ 41] formal_parameter abbrev: 1 name (GNU_strp_alt) "argc" - decl_file (data1) 1 + decl_file (data1) main.c (1) decl_line (data1) 8 type (GNU_ref_alt) [ 30] location (exprloc) [ 0] fbreg -36 [ 4f] formal_parameter abbrev: 1 name (GNU_strp_alt) "argv" - decl_file (data1) 1 + decl_file (data1) main.c (1) decl_line (data1) 8 type (GNU_ref_alt) [ 41] location (exprloc) [ 0] fbreg -48 [ 5d] variable abbrev: 3 name (string) "fbb" - decl_file (data1) 1 + decl_file (data1) main.c (1) decl_line (data1) 10 type (GNU_ref_alt) [ 14] location (exprloc) diff --git a/tests/run-readelf-zdebug-rel.sh b/tests/run-readelf-zdebug-rel.sh index 93201ae..2b57d05 100755 --- a/tests/run-readelf-zdebug-rel.sh +++ b/tests/run-readelf-zdebug-rel.sh @@ -62,7 +62,7 @@ DWARF section [ 4] '.debug_info' at offset 0x58: [ 2d] subprogram abbrev: 2 external (flag_present) yes name (strp) "main" - decl_file (data1) 1 + decl_file (data1) testfile-zdebug-rel.c (1) decl_line (data1) 4 prototyped (flag_present) yes type (ref4) [ 80] @@ -74,26 +74,26 @@ DWARF section [ 4] '.debug_info' at offset 0x58: sibling (ref4) [ 80] [ 4e] formal_parameter abbrev: 3 name (strp) "argc" - decl_file (data1) 1 + decl_file (data1) testfile-zdebug-rel.c (1) decl_line (data1) 4 type (ref4) [ 80] location (sec_offset) location list [ 0] [ 5d] formal_parameter abbrev: 4 name (strp) "argv" - decl_file (data1) 1 + decl_file (data1) testfile-zdebug-rel.c (1) decl_line (data1) 4 type (ref4) [ 87] location (exprloc) [ 0] reg4 [ 6a] variable abbrev: 5 name (string) "a" - decl_file (data1) 1 + decl_file (data1) testfile-zdebug-rel.c (1) decl_line (data1) 6 type (ref4) [ 9a] const_value (sdata) -9 [ 74] variable abbrev: 6 name (string) "b" - decl_file (data1) 1 + decl_file (data1) testfile-zdebug-rel.c (1) decl_line (data1) 7 type (ref4) [ 9a] location (exprloc) -- 1.8.3.1