public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH 2/5] readelf: Print abbrev code for DIE with --debug-dump=info.
Date: Wed, 29 Nov 2017 16:06:00 -0000	[thread overview]
Message-ID: <1511971553-30135-3-git-send-email-mark@klomp.org> (raw)
In-Reply-To: <1511971553-30135-1-git-send-email-mark@klomp.org>

If there is anything wrong with a DIE it is useful to know what the abbrev
code was so you can lookup the abbrev description.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 src/ChangeLog                   |  4 +++
 src/readelf.c                   |  9 ++++---
 tests/ChangeLog                 |  5 ++++
 tests/run-readelf-dwz-multi.sh  | 60 ++++++++++++++++++++---------------------
 tests/run-readelf-zdebug-rel.sh | 22 +++++++--------
 5 files changed, 56 insertions(+), 44 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index b88c319..e7e598d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
 2017-11-29  Mark Wielaard  <mark@klomp.org>
 
+	* readelf.c (print_debug_units): Print abbrev code after DIE tag.
+
+2017-11-29  Mark Wielaard  <mark@klomp.org>
+
 	* readelf.c (print_ops): Use only2 space for index. re-indent +5
 	for DW_OP_GNU_entry_value.
 
diff --git a/src/readelf.c b/src/readelf.c
index 2faa1d5..e9887c4 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -6371,9 +6371,12 @@ print_debug_units (Dwfl_Module *dwflmod,
 	}
 
       if (!silent)
-	printf (" [%6" PRIx64 "]  %*s%s\n",
-		(uint64_t) offset, (int) (level * 2), "",
-		dwarf_tag_name (tag));
+	{
+	  unsigned int code = dwarf_getabbrevcode (dies[level].abbrev);
+	  printf (" [%6" PRIx64 "]  %*s%-20s abbrev: %u\n",
+		  (uint64_t) offset, (int) (level * 2), "",
+		  dwarf_tag_name (tag), code);
+	}
 
       /* Print the attribute values.  */
       args.level = level;
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 9633cd1..f522a69 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,10 @@
 2017-11-29  Mark Wielaard  <mark@klomp.org>
 
+	* run-readelf-dwz-multi.sh: Add expected abbrev codes.
+	* run-readelf-zdebug-rel.sh: Likewise.
+
+2017-11-29  Mark Wielaard  <mark@klomp.org>
+
 	* run-readelf-dwz-multi.sh: Adjust expected ops index spaces.
 	* run-readelf-loc.sh: Likewise.
 	* run-readelf-zdebug-rel.sh: Likewise.
diff --git a/tests/run-readelf-dwz-multi.sh b/tests/run-readelf-dwz-multi.sh
index 139b8c1..21456fd 100755
--- a/tests/run-readelf-dwz-multi.sh
+++ b/tests/run-readelf-dwz-multi.sh
@@ -84,7 +84,7 @@ DWARF section [28] '.debug_info' at offset 0x1078:
  [Offset]
  Compilation unit at offset 0:
  Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
- [     b]  compile_unit
+ [     b]  compile_unit         abbrev: 6
            producer             (strp) "GNU C 4.7.0 20120507 (Red Hat 4.7.0-5) -mtune=generic -march=x86-64 -g"
            language             (data1) C89 (1)
            name                 (strp) "main.c"
@@ -92,12 +92,12 @@ DWARF section [28] '.debug_info' at offset 0x1078:
            low_pc               (addr) 0x00000000004006ac <main>
            high_pc              (udata) 44 (0x00000000004006d8)
            stmt_list            (sec_offset) 0
- [    26]    imported_unit
+ [    26]    imported_unit        abbrev: 5
              import               (GNU_ref_alt) [     b]
- [    2b]    pointer_type
+ [    2b]    pointer_type         abbrev: 1
              byte_size            (data1) 8
              type                 (GNU_ref_alt) [    53]
- [    31]    subprogram
+ [    31]    subprogram           abbrev: 3
              external             (flag_present) yes
              name                 (strp) "main"
              decl_file            (data1) 1
@@ -110,28 +110,28 @@ DWARF section [28] '.debug_info' at offset 0x1078:
               [ 0] call_frame_cfa
              GNU_all_tail_call_sites (flag_present) yes
              sibling              (ref_udata) [    6e]
- [    48]      formal_parameter
+ [    48]      formal_parameter     abbrev: 8
                name                 (strp) "argc"
                decl_file            (data1) 1
                decl_line            (data1) 3
                type                 (GNU_ref_alt) [    3e]
                location             (exprloc) 
                 [ 0] fbreg -36
- [    56]      formal_parameter
+ [    56]      formal_parameter     abbrev: 4
                name                 (strp) "argv"
                decl_file            (data1) 1
                decl_line            (data1) 3
                type                 (ref_udata) [    6e]
                location             (exprloc) 
                 [ 0] fbreg -48
- [    61]      variable
+ [    61]      variable             abbrev: 7
                name                 (string) "b"
                decl_file            (data1) 1
                decl_line            (data1) 5
                type                 (GNU_ref_alt) [    5a]
                location             (exprloc) 
                 [ 0] fbreg -32
- [    6e]    pointer_type
+ [    6e]    pointer_type         abbrev: 2
              byte_size            (data1) 8
              type                 (ref_udata) [    2b]
 EOF
@@ -145,7 +145,7 @@ DWARF section [28] '.debug_info' at offset 0x1078:
  [Offset]
  Compilation unit at offset 0:
  Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
- [     b]  compile_unit
+ [     b]  compile_unit         abbrev: 6
            producer             (strp) "GNU C 4.7.0 20120507 (Red Hat 4.7.0-5) -mtune=generic -march=x86-64 -g"
            language             (data1) C89 (1)
            name                 (strp) "main.c"
@@ -153,12 +153,12 @@ DWARF section [28] '.debug_info' at offset 0x1078:
            low_pc               (addr) 0x00000000004006ac <main>
            high_pc              (udata) 44 (0x00000000004006d8)
            stmt_list            (sec_offset) 0
- [    26]    imported_unit
+ [    26]    imported_unit        abbrev: 5
              import               (GNU_ref_alt) [     b]
- [    2b]    pointer_type
+ [    2b]    pointer_type         abbrev: 1
              byte_size            (data1) 8
              type                 (GNU_ref_alt) [    53]
- [    31]    subprogram
+ [    31]    subprogram           abbrev: 3
              external             (flag_present) yes
              name                 (strp) "main"
              decl_file            (data1) 1
@@ -171,28 +171,28 @@ DWARF section [28] '.debug_info' at offset 0x1078:
               [ 0] call_frame_cfa
              GNU_all_tail_call_sites (flag_present) yes
              sibling              (ref_udata) [    6e]
- [    48]      formal_parameter
+ [    48]      formal_parameter     abbrev: 8
                name                 (strp) "argc"
                decl_file            (data1) 1
                decl_line            (data1) 3
                type                 (GNU_ref_alt) [    3e]
                location             (exprloc) 
                 [ 0] fbreg -36
- [    56]      formal_parameter
+ [    56]      formal_parameter     abbrev: 4
                name                 (strp) "argv"
                decl_file            (data1) 1
                decl_line            (data1) 3
                type                 (ref_udata) [    6e]
                location             (exprloc) 
                 [ 0] fbreg -48
- [    61]      variable
+ [    61]      variable             abbrev: 7
                name                 (string) "b"
                decl_file            (data1) 1
                decl_line            (data1) 5
                type                 (GNU_ref_alt) [    5a]
                location             (exprloc) 
                 [ 0] fbreg -32
- [    6e]    pointer_type
+ [    6e]    pointer_type         abbrev: 2
              byte_size            (data1) 8
              type                 (ref_udata) [    2b]
 EOF
@@ -205,7 +205,7 @@ DWARF section [25] '.debug_info' at offset 0x106c:
  [Offset]
  Compilation unit at offset 0:
  Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
- [     b]  compile_unit
+ [     b]  compile_unit         abbrev: 3
            producer             (strp) "GNU C 4.7.0 20120507 (Red Hat 4.7.0-5) -fpreprocessed -mtune=generic -march=x86-64 -g -fPIC"
            language             (data1) C89 (1)
            name                 (strp) "shared.c"
@@ -213,9 +213,9 @@ DWARF section [25] '.debug_info' at offset 0x106c:
            low_pc               (addr) +0x0000000000000670 <call_foo>
            high_pc              (udata) 23 (+0x0000000000000687)
            stmt_list            (sec_offset) 0
- [    26]    imported_unit
+ [    26]    imported_unit        abbrev: 2
              import               (GNU_ref_alt) [     b]
- [    2b]    subprogram
+ [    2b]    subprogram           abbrev: 1
              external             (flag_present) yes
              name                 (strp) "call_foo"
              decl_file            (data1) 1
@@ -227,7 +227,7 @@ DWARF section [25] '.debug_info' at offset 0x106c:
              frame_base           (exprloc) 
               [ 0] call_frame_cfa
              GNU_all_call_sites   (flag_present) yes
- [    41]      formal_parameter
+ [    41]      formal_parameter     abbrev: 4
                name                 (string) "fb"
                decl_file            (data1) 1
                decl_line            (data1) 3
@@ -245,7 +245,7 @@ DWARF section [25] '.debug_info' at offset 0x106c:
  [Offset]
  Compilation unit at offset 0:
  Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
- [     b]  compile_unit
+ [     b]  compile_unit         abbrev: 3
            producer             (strp) "GNU C 4.7.0 20120507 (Red Hat 4.7.0-5) -fpreprocessed -mtune=generic -march=x86-64 -g -fPIC"
            language             (data1) C89 (1)
            name                 (strp) "shared.c"
@@ -253,9 +253,9 @@ DWARF section [25] '.debug_info' at offset 0x106c:
            low_pc               (addr) +0x0000000000000670 <call_foo>
            high_pc              (udata) 23 (+0x0000000000000687)
            stmt_list            (sec_offset) 0
- [    26]    imported_unit
+ [    26]    imported_unit        abbrev: 2
              import               (GNU_ref_alt) [     b]
- [    2b]    subprogram
+ [    2b]    subprogram           abbrev: 1
              external             (flag_present) yes
              name                 (strp) "call_foo"
              decl_file            (data1) 1
@@ -267,7 +267,7 @@ DWARF section [25] '.debug_info' at offset 0x106c:
              frame_base           (exprloc) 
               [ 0] call_frame_cfa
              GNU_all_call_sites   (flag_present) yes
- [    41]      formal_parameter
+ [    41]      formal_parameter     abbrev: 4
                name                 (string) "fb"
                decl_file            (data1) 1
                decl_line            (data1) 3
@@ -284,7 +284,7 @@ DWARF section [28] '.debug_info' at offset 0x1088:
  [Offset]
  Compilation unit at offset 0:
  Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
- [     b]  compile_unit
+ [     b]  compile_unit         abbrev: 5
            producer             (GNU_strp_alt) "GNU C 4.7.2 20121109 (Red Hat 4.7.2-8) -mtune=generic -march=x86-64 -g"
            language             (data1) C89 (1)
            name                 (GNU_strp_alt) "main.c"
@@ -292,9 +292,9 @@ DWARF section [28] '.debug_info' at offset 0x1088:
            low_pc               (addr) 0x00000000004004ec <main>
            high_pc              (udata) 18 (0x00000000004004fe)
            stmt_list            (sec_offset) 0
- [    26]    imported_unit
+ [    26]    imported_unit        abbrev: 2
              import               (GNU_ref_alt) [     b]
- [    2b]    subprogram
+ [    2b]    subprogram           abbrev: 4
              external             (flag_present) yes
              name                 (GNU_strp_alt) "main"
              decl_file            (data1) 1
@@ -306,21 +306,21 @@ DWARF section [28] '.debug_info' at offset 0x1088:
              frame_base           (exprloc) 
               [ 0] call_frame_cfa
              GNU_all_call_sites   (flag_present) yes
- [    41]      formal_parameter
+ [    41]      formal_parameter     abbrev: 1
                name                 (GNU_strp_alt) "argc"
                decl_file            (data1) 1
                decl_line            (data1) 8
                type                 (GNU_ref_alt) [    30]
                location             (exprloc) 
                 [ 0] fbreg -36
- [    4f]      formal_parameter
+ [    4f]      formal_parameter     abbrev: 1
                name                 (GNU_strp_alt) "argv"
                decl_file            (data1) 1
                decl_line            (data1) 8
                type                 (GNU_ref_alt) [    41]
                location             (exprloc) 
                 [ 0] fbreg -48
- [    5d]      variable
+ [    5d]      variable             abbrev: 3
                name                 (string) "fbb"
                decl_file            (data1) 1
                decl_line            (data1) 10
diff --git a/tests/run-readelf-zdebug-rel.sh b/tests/run-readelf-zdebug-rel.sh
index 082971e..93201ae 100755
--- a/tests/run-readelf-zdebug-rel.sh
+++ b/tests/run-readelf-zdebug-rel.sh
@@ -51,7 +51,7 @@ DWARF section [ 4] '.debug_info' at offset 0x58:
  [Offset]
  Compilation unit at offset 0:
  Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
- [     b]  compile_unit
+ [     b]  compile_unit         abbrev: 1
            producer             (strp) "GNU C11 5.3.1 20151207 (Red Hat 5.3.1-2) -mtune=generic -march=x86-64 -g -Og"
            language             (data1) C99 (12)
            name                 (strp) "testfile-zdebug-rel.c"
@@ -59,7 +59,7 @@ DWARF section [ 4] '.debug_info' at offset 0x58:
            low_pc               (addr) 000000000000000000
            high_pc              (data8) 24 (0x0000000000000018)
            stmt_list            (sec_offset) 0
- [    2d]    subprogram
+ [    2d]    subprogram           abbrev: 2
              external             (flag_present) yes
              name                 (strp) "main"
              decl_file            (data1) 1
@@ -72,47 +72,47 @@ DWARF section [ 4] '.debug_info' at offset 0x58:
               [ 0] call_frame_cfa
              GNU_all_call_sites   (flag_present) yes
              sibling              (ref4) [    80]
- [    4e]      formal_parameter
+ [    4e]      formal_parameter     abbrev: 3
                name                 (strp) "argc"
                decl_file            (data1) 1
                decl_line            (data1) 4
                type                 (ref4) [    80]
                location             (sec_offset) location list [     0]
- [    5d]      formal_parameter
+ [    5d]      formal_parameter     abbrev: 4
                name                 (strp) "argv"
                decl_file            (data1) 1
                decl_line            (data1) 4
                type                 (ref4) [    87]
                location             (exprloc) 
                 [ 0] reg4
- [    6a]      variable
+ [    6a]      variable             abbrev: 5
                name                 (string) "a"
                decl_file            (data1) 1
                decl_line            (data1) 6
                type                 (ref4) [    9a]
                const_value          (sdata) -9
- [    74]      variable
+ [    74]      variable             abbrev: 6
                name                 (string) "b"
                decl_file            (data1) 1
                decl_line            (data1) 7
                type                 (ref4) [    9a]
                location             (exprloc) 
                 [ 0] reg5
- [    80]    base_type
+ [    80]    base_type            abbrev: 7
              byte_size            (data1) 4
              encoding             (data1) signed (5)
              name                 (string) "int"
- [    87]    pointer_type
+ [    87]    pointer_type         abbrev: 8
              byte_size            (data1) 8
              type                 (ref4) [    8d]
- [    8d]    pointer_type
+ [    8d]    pointer_type         abbrev: 8
              byte_size            (data1) 8
              type                 (ref4) [    93]
- [    93]    base_type
+ [    93]    base_type            abbrev: 9
              byte_size            (data1) 1
              encoding             (data1) signed_char (6)
              name                 (strp) "char"
- [    9a]    base_type
+ [    9a]    base_type            abbrev: 9
              byte_size            (data1) 8
              encoding             (data1) unsigned (7)
              name                 (strp) "long unsigned int"
-- 
1.8.3.1

  parent reply	other threads:[~2017-11-29 16:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-29 16:06 Various eu-readelf --debug-dump improvements Mark Wielaard
2017-11-29 16:06 ` [PATCH 3/5] readelf: Print actual file for decl_file and call_file attributes Mark Wielaard
2017-11-29 16:06 ` [PATCH 1/5] readelf: Adjust print_ops formatting Mark Wielaard
2017-11-29 16:06 ` Mark Wielaard [this message]
2017-11-29 16:06 ` [PATCH 5/5] readelf: Print CU, base address and unresolved .debug_loc entries Mark Wielaard
2017-11-29 16:06 ` [PATCH 4/5] readelf: Print CU, base address and unresolved .debug_range entries Mark Wielaard
2017-12-10 16:00 ` Various eu-readelf --debug-dump improvements 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=1511971553-30135-3-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).