This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/5] readelf: Print abbrev code for DIE with --debug-dump=info.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]