diff options
-rw-r--r-- | src/ChangeLog | 5 | ||||
-rw-r--r-- | src/readelf.c | 14 | ||||
-rw-r--r-- | tests/ChangeLog | 10 | ||||
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rwxr-xr-x | tests/run-readelf-loc.sh | 289 | ||||
-rwxr-xr-x | tests/run-varlocs.sh | 42 | ||||
-rw-r--r-- | tests/splitdwarf4-not-split4.dwo.bz2 | bin | 0 -> 931 bytes | |||
-rwxr-xr-x | tests/testfile-splitdwarf4-not-split4.debug.bz2 | bin | 0 -> 2230 bytes |
8 files changed, 359 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0e6f1f27..3cd7ae7b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2018-05-31 Mark Wielaard <[email protected]> + + * readelf.c (attr_callback): Only register section_loc when not + looking at a split dwarf from a skeleton. + 2018-05-30 Mark Wielaard <[email protected]> * readelf.c (print_debug_loc_section): Use correct listptr for diff --git a/src/readelf.c b/src/readelf.c index db7723d3..45401b30 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -7077,9 +7077,17 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) { bool nlpt; if (cbargs->cu->version < 5) - nlpt = notice_listptr (section_loc, &known_locsptr, - cbargs->addrsize, cbargs->offset_size, - cbargs->cu, num, attr); + { + if (! cbargs->is_split) + { + nlpt = notice_listptr (section_loc, &known_locsptr, + cbargs->addrsize, + cbargs->offset_size, + cbargs->cu, num, attr); + } + else + nlpt = true; + } else { /* Only register for a real section offset. Otherwise diff --git a/tests/ChangeLog b/tests/ChangeLog index 1c1ef4ed..04b6e753 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,15 @@ 2018-05-31 Mark Wielaard <[email protected]> + * 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 + and testfile-splitdwarf4-not-split4.debug. + * run-varlocs.sh: Test testfile-splitdwarf4-not-split4.debug. + * Makefile.am (EXTRA_DIST): Add splitdwarf4-not-split4.dwo.bz2 + and testfile-splitdwarf4-not-split4.debug.bz2. + +2018-05-31 Mark Wielaard <[email protected]> + * test-subr.sh (self_test_files): Split into self_test_files_exe, self_test_files_lib and self_test_obj. (testrun_on_self_exe): New function. diff --git a/tests/Makefile.am b/tests/Makefile.am index e935410a..28ba9f79 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -238,6 +238,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ testfile-macros-0xff.bz2 \ run-readelf-macro.sh testfilemacro.bz2 \ run-readelf-loc.sh testfileloc.bz2 \ + splitdwarf4-not-split4.dwo.bz2 \ + testfile-splitdwarf4-not-split4.debug.bz2 \ run-readelf-ranges.sh \ run-readelf-aranges.sh run-readelf-line.sh testfilefoobarbaz.bz2 \ testfile-ppc64-min-instr.bz2 \ diff --git a/tests/run-readelf-loc.sh b/tests/run-readelf-loc.sh index 484db466..bf676f2b 100755 --- a/tests/run-readelf-loc.sh +++ b/tests/run-readelf-loc.sh @@ -868,4 +868,293 @@ DWARF section [ 3] '.debug_loc.dwo' at offset 0x225: [ 0] reg5 EOF +# Partial dwarf-4 and partial GNU DebugFission split-dwarf. +# +# = popcount.c = +# +# int popcount (unsigned char u) +# { +# int c = 0; +# while (u != 0) +# { +# if ((u & 1) == 1) +# c++; +# u >>= 1; +# } +# return c; +# } +# +# = splitdwarf4-not-split4.c = +# +# extern int popcount (unsigned char); +# +# int main (int argc, char **argv) +# { +# int i; +# int p = argc; +# for (i = 0; i < argc; ++i) +# p += popcount (argv[i][0]); +# i += p; +# return i; +# } +# +# gcc -gdwarf-4 -O2 -c popcount.c +# gcc -gdwarf-4 -gsplit-dwarf -O2 -c splitdwarf4-not-split4.c +# gcc -o testfile-splitdwarf4-not-split4 splitdwarf4-not-split4.o popcount.o +# eu-strip -f testfile-splitdwarf4-not-split4.debug \ +# testfile-splitdwarf4-not-split4 + +testfiles testfile-splitdwarf4-not-split4.debug +testfiles splitdwarf4-not-split4.dwo + +testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=info+ --debug-dump=loc testfile-splitdwarf4-not-split4.debug <<\EOF + +DWARF section [28] '.debug_info' at offset 0x330: + [Offset] + Compilation unit at offset 0: + Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4 + Unit type: skeleton (4), Unit id: 0x3d909d7bd0e69c0b + [ b] compile_unit abbrev: 1 + ranges (sec_offset) range list [ 0] + low_pc (addr) 000000000000000000 + stmt_list (sec_offset) 0 + GNU_dwo_name (strp) "splitdwarf4-not-split4.dwo" + comp_dir (strp) "/tmp" + GNU_pubnames (flag_present) yes + GNU_addr_base (sec_offset) address base [ 0] + GNU_dwo_id (data8) 0x3d909d7bd0e69c0b + GNU_ranges_base (sec_offset) 0 + Split compilation unit at offset 0: + Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4 + Unit type: skeleton (4), Unit id: 0x3d909d7bd0e69c0b + { b} compile_unit abbrev: 1 + producer (GNU_str_index) "GNU C17 9.0.0 20180528 (experimental) -mtune=generic -march=x86-64 -gdwarf-4 -gsplit-dwarf -O2" + language (data1) C99 (12) + name (GNU_str_index) "splitdwarf4-not-split4.c" + comp_dir (GNU_str_index) "/tmp" + GNU_dwo_id (data8) 0x3d909d7bd0e69c0b + { 18} subprogram abbrev: 2 + external (flag_present) yes + name (GNU_str_index) "main" + decl_file (data1) splitdwarf4-not-split4.c (1) + decl_line (data1) 3 + decl_column (data1) 5 + prototyped (flag_present) yes + type (ref4) { 6d} + low_pc (GNU_addr_index) [4] 0x0000000000401050 <main> + high_pc (data8) 76 (0x000000000040109c <_start>) + frame_base (exprloc) + [ 0] call_frame_cfa + GNU_all_call_sites (flag_present) yes + sibling (ref4) { 6d} + { 30} formal_parameter abbrev: 3 + name (GNU_str_index) "argc" + decl_file (data1) splitdwarf4-not-split4.c (1) + decl_line (data1) 3 + decl_column (data1) 15 + type (ref4) { 6d} + location (sec_offset) location list [ 0] + { 3d} formal_parameter abbrev: 3 + name (GNU_str_index) "argv" + decl_file (data1) splitdwarf4-not-split4.c (1) + decl_line (data1) 3 + decl_column (data1) 28 + type (ref4) { 74} + location (sec_offset) location list [ 28] + { 4a} variable abbrev: 4 + name (string) "i" + decl_file (data1) splitdwarf4-not-split4.c (1) + decl_line (data1) 5 + decl_column (data1) 7 + type (ref4) { 6d} + location (sec_offset) location list [ 47] + { 58} variable abbrev: 4 + name (string) "p" + decl_file (data1) splitdwarf4-not-split4.c (1) + decl_line (data1) 6 + decl_column (data1) 7 + type (ref4) { 6d} + location (sec_offset) location list [ 73] + { 66} GNU_call_site abbrev: 5 + low_pc (GNU_addr_index) [1] 0x000000000040107f <main+0x2f> + abstract_origin (ref4) { 84} + { 6d} base_type abbrev: 6 + byte_size (data1) 4 + encoding (data1) signed (5) + name (string) "int" + { 74} pointer_type abbrev: 7 + byte_size (data1) 8 + type (ref4) { 7a} + { 7a} pointer_type abbrev: 7 + byte_size (data1) 8 + type (ref4) { 80} + { 80} base_type abbrev: 8 + byte_size (data1) 1 + encoding (data1) signed_char (6) + name (GNU_str_index) "char" + { 84} subprogram abbrev: 9 + external (flag_present) yes + declaration (flag_present) yes + linkage_name (GNU_str_index) "popcount" + name (GNU_str_index) "popcount" + decl_file (data1) splitdwarf4-not-split4.c (1) + decl_line (data1) 1 + decl_column (data1) 12 + Compilation unit at offset 52: + Version: 4, Abbreviation section offset: 29, Address size: 8, Offset size: 4 + [ 3f] compile_unit abbrev: 1 + producer (strp) "GNU C17 9.0.0 20180528 (experimental) -mtune=generic -march=x86-64 -gdwarf-4 -O2" + language (data1) C99 (12) + name (strp) "popcount.c" + comp_dir (strp) "/tmp" + low_pc (addr) 0x0000000000401180 <popcount> + high_pc (data8) 33 (0x00000000004011a1) + stmt_list (sec_offset) 145 + [ 61] subprogram abbrev: 2 + external (flag_present) yes + name (strp) "popcount" + decl_file (data1) popcount.c (1) + decl_line (data1) 1 + decl_column (data1) 5 + prototyped (flag_present) yes + type (ref4) [ a0] + low_pc (addr) 0x0000000000401180 <popcount> + high_pc (data8) 33 (0x00000000004011a1) + frame_base (exprloc) + [ 0] call_frame_cfa + GNU_all_call_sites (flag_present) yes + sibling (ref4) [ a0] + [ 83] formal_parameter abbrev: 3 + name (string) "u" + decl_file (data1) popcount.c (1) + decl_line (data1) 1 + decl_column (data1) 29 + type (ref4) [ a7] + location (sec_offset) location list [ 0] + [ 91] variable abbrev: 4 + name (string) "c" + decl_file (data1) popcount.c (1) + decl_line (data1) 3 + decl_column (data1) 7 + type (ref4) [ a0] + location (sec_offset) location list [ 60] + [ a0] base_type abbrev: 5 + byte_size (data1) 4 + encoding (data1) signed (5) + name (string) "int" + [ a7] base_type abbrev: 6 + byte_size (data1) 1 + encoding (data1) unsigned_char (8) + name (strp) "unsigned char" + +DWARF section [32] '.debug_loc' at offset 0x5ef: + + CU [ 3f] base: 0x0000000000401180 <popcount> + [ 0] range 0, 9 + 0x0000000000401180 <popcount>.. + 0x0000000000401188 <popcount+0x8> + [ 0] reg5 + range 9, 1b + 0x0000000000401189 <popcount+0x9>.. + 0x000000000040119a <popcount+0x1a> + [ 0] reg1 + range 1b, 1d + 0x000000000040119b <popcount+0x1b>.. + 0x000000000040119c <popcount+0x1c> + [ 0] breg1 0 + [ 2] lit1 + [ 3] shr + [ 4] stack_value + range 1d, 21 + 0x000000000040119d <popcount+0x1d>.. + 0x00000000004011a0 <popcount+0x20> + [ 0] reg1 + [ 60] range 0, 9 + 0x0000000000401180 <popcount>.. + 0x0000000000401188 <popcount+0x8> + [ 0] lit0 + [ 1] stack_value + range 9, 20 + 0x0000000000401189 <popcount+0x9>.. + 0x000000000040119f <popcount+0x1f> + [ 0] reg0 + range 20, 21 + 0x00000000004011a0 <popcount+0x20>.. + 0x00000000004011a0 <popcount+0x20> + [ 0] lit0 + [ 1] stack_value +EOF + +testrun_compare ${abs_top_builddir}/src/readelf --dwarf-skeleton=testfile-splitdwarf4-not-split4.debug --debug-dump=loc splitdwarf4-not-split4.dwo <<\EOF + +DWARF section [ 3] '.debug_loc.dwo' at offset 0x15b: + + CU [ b] base: 000000000000000000 + [ 0] range 401050, 40106e + 0x0000000000401050 <main>.. + 0x000000000040106d <main+0x1d> + [ 0] reg5 + range 40106e, 401086 + 0x000000000040106e <main+0x1e>.. + 0x0000000000401085 <main+0x35> + [ 0] reg12 + range 401086, 401095 + 0x0000000000401086 <main+0x36>.. + 0x0000000000401094 <main+0x44> + [ 0] GNU_entry_value: + [ 0] reg5 + [ 3] stack_value + range 401095, 40109c + 0x0000000000401095 <main+0x45>.. + 0x000000000040109b <main+0x4b> + [ 0] reg5 + [ 28] range 401050, 40106e + 0x0000000000401050 <main>.. + 0x000000000040106d <main+0x1d> + [ 0] reg4 + range 40106e, 401095 + 0x000000000040106e <main+0x1e>.. + 0x0000000000401094 <main+0x44> + [ 0] GNU_entry_value: + [ 0] reg4 + [ 3] stack_value + range 401095, 40109c + 0x0000000000401095 <main+0x45>.. + 0x000000000040109b <main+0x4b> + [ 0] reg4 + [ 47] range 401050, 40106e + 0x0000000000401050 <main>.. + 0x000000000040106d <main+0x1d> + [ 0] lit0 + [ 1] stack_value + range 401086, 40108e + 0x0000000000401086 <main+0x36>.. + 0x000000000040108d <main+0x3d> + [ 0] breg12 0 + [ 2] breg6 0 + [ 4] plus + [ 5] stack_value + range 40108e, 401095 + 0x000000000040108e <main+0x3e>.. + 0x0000000000401094 <main+0x44> + [ 0] reg0 + range 401095, 40109c + 0x0000000000401095 <main+0x45>.. + 0x000000000040109b <main+0x4b> + [ 0] lit0 + [ 1] stack_value + [ 73] range 401050, 40106e + 0x0000000000401050 <main>.. + 0x000000000040106d <main+0x1d> + [ 0] reg5 + range 40106e, 401090 + 0x000000000040106e <main+0x1e>.. + 0x000000000040108f <main+0x3f> + [ 0] reg6 + range 401095, 40109c + 0x0000000000401095 <main+0x45>.. + 0x000000000040109b <main+0x4b> + [ 0] reg5 +EOF + exit 0 diff --git a/tests/run-varlocs.sh b/tests/run-varlocs.sh index e98d8e94..b2621776 100755 --- a/tests/run-varlocs.sh +++ b/tests/run-varlocs.sh @@ -559,4 +559,46 @@ module 'testfile-addrx_constx-4' location (exprloc) {addr: 0x404038, deref_size(4), GNU_push_tls_address, const: 0x403e08, deref_size(4), plus, GNU_push_tls_address, const: 0x403e0c, deref_size(4), plus, GNU_push_tls_address, const: 0x403e10, deref_size(4), plus, addr: 0x404034, deref_size(4), plus, addr: 0x40403c, deref_size(4), plus, stack_value} EOF +# See run-readelf-loc.sh +testfiles testfile-splitdwarf4-not-split4.debug +testfiles splitdwarf4-not-split4.dwo + +testrun_compare ${abs_top_builddir}/tests/varlocs --debug -e testfile-splitdwarf4-not-split4.debug <<\EOF +module 'testfile-splitdwarf4-not-split4.debug' +[b] CU 'splitdwarf4-not-split4.c' + [18] function 'main'@401050 + frame_base: {call_frame_cfa {...}} + [30] parameter 'argc' + [401050,40106e) {reg5} + [40106e,401086) {reg12} + [401086,401095) {GNU_entry_value(1) {reg5}, stack_value} + [401095,40109c) {reg5} + [3d] parameter 'argv' + [401050,40106e) {reg4} + [40106e,401095) {GNU_entry_value(1) {reg4}, stack_value} + [401095,40109c) {reg4} + [4a] variable 'i' + [401050,40106e) {lit0, stack_value} + [401086,40108e) {breg12(0), breg6(0), plus, stack_value} + [40108e,401095) {reg0} + [401095,40109c) {lit0, stack_value} + [58] variable 'p' + [401050,40106e) {reg5} + [40106e,401090) {reg6} + [401095,40109c) {reg5} +module 'testfile-splitdwarf4-not-split4.debug' +[3f] CU 'popcount.c'@401180 + [61] function 'popcount'@401180 + frame_base: {call_frame_cfa {...}} + [83] parameter 'u' + [401180,401189) {reg5} + [401189,40119b) {reg1} + [40119b,40119d) {breg1(0), lit1, shr, stack_value} + [40119d,4011a1) {reg1} + [91] variable 'c' + [401180,401189) {lit0, stack_value} + [401189,4011a0) {reg0} + [4011a0,4011a1) {lit0, stack_value} +EOF + exit 0 diff --git a/tests/splitdwarf4-not-split4.dwo.bz2 b/tests/splitdwarf4-not-split4.dwo.bz2 Binary files differnew file mode 100644 index 00000000..4346b2e6 --- /dev/null +++ b/tests/splitdwarf4-not-split4.dwo.bz2 diff --git a/tests/testfile-splitdwarf4-not-split4.debug.bz2 b/tests/testfile-splitdwarf4-not-split4.debug.bz2 Binary files differnew file mode 100755 index 00000000..6f4d701a --- /dev/null +++ b/tests/testfile-splitdwarf4-not-split4.debug.bz2 |