Blame tests/run-readelf-ranges.sh

Packit 032894
#! /bin/sh
Packit 032894
# Copyright (C) 2018 Red Hat, Inc.
Packit 032894
# This file is part of elfutils.
Packit 032894
#
Packit 032894
# This file is free software; you can redistribute it and/or modify
Packit 032894
# it under the terms of the GNU General Public License as published by
Packit 032894
# the Free Software Foundation; either version 3 of the License, or
Packit 032894
# (at your option) any later version.
Packit 032894
#
Packit 032894
# elfutils is distributed in the hope that it will be useful, but
Packit 032894
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 032894
# GNU General Public License for more details.
Packit 032894
#
Packit 032894
# You should have received a copy of the GNU General Public License
Packit 032894
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 032894
Packit 032894
. $srcdir/test-subr.sh
Packit 032894
Packit 032894
# See run-readelf-loc.sh
Packit 032894
Packit 032894
testfiles testfileloc
Packit 032894
Packit 032894
# Process values as offsets from base addresses and resolve to symbols.
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=ranges testfileloc<<\EOF
Packit 032894
Packit 032894
DWARF section [34] '.debug_ranges' at offset 0xd94:
Packit 032894
Packit 032894
 CU [     b] base: 0x0000000000400480 <main>
Packit 032894
 [     0] range 0, 2
Packit 032894
          0x0000000000400480 <main>..
Packit 032894
          0x0000000000400481 <main+0x1>
Packit 032894
          range 5, d
Packit 032894
          0x0000000000400485 <main+0x5>..
Packit 032894
          0x000000000040048c <main+0xc>
Packit 032894
Packit 032894
 CU [    e0] base: 0x00000000004004a0 <say>
Packit 032894
 [    30] range d, f
Packit 032894
          0x00000000004004ad <say+0xd>..
Packit 032894
          0x00000000004004ae <say+0xe>
Packit 032894
          range 12, 1a
Packit 032894
          0x00000000004004b2 <say+0x12>..
Packit 032894
          0x00000000004004b9 <say+0x19>
Packit 032894
EOF
Packit 032894
Packit 032894
# Don't resolve addresses to symbols.
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -N --debug-dump=ranges testfileloc<<\EOF
Packit 032894
Packit 032894
DWARF section [34] '.debug_ranges' at offset 0xd94:
Packit 032894
Packit 032894
 CU [     b] base: 0x0000000000400480
Packit 032894
 [     0] range 0, 2
Packit 032894
          0x0000000000400480..
Packit 032894
          0x0000000000400481
Packit 032894
          range 5, d
Packit 032894
          0x0000000000400485..
Packit 032894
          0x000000000040048c
Packit 032894
Packit 032894
 CU [    e0] base: 0x00000000004004a0
Packit 032894
 [    30] range d, f
Packit 032894
          0x00000000004004ad..
Packit 032894
          0x00000000004004ae
Packit 032894
          range 12, 1a
Packit 032894
          0x00000000004004b2..
Packit 032894
          0x00000000004004b9
Packit 032894
EOF
Packit 032894
Packit 032894
# Produce "raw" unprocessed content.
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=ranges testfileloc<<\EOF
Packit 032894
Packit 032894
DWARF section [34] '.debug_ranges' at offset 0xd94:
Packit 032894
Packit 032894
 CU [     b] base: 0x0000000000400480
Packit 032894
 [     0] range 0, 2
Packit 032894
          range 5, d
Packit 032894
Packit 032894
 CU [    e0] base: 0x00000000004004a0
Packit 032894
 [    30] range d, f
Packit 032894
          range 12, 1a
Packit 032894
EOF
Packit 032894
Packit 032894
# .debug_rnglists (DWARF5), see tests/testfile-dwarf-45.source
Packit 032894
testfiles testfile-dwarf-5
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=ranges testfile-dwarf-5<<\EOF
Packit 032894
Packit 032894
DWARF section [33] '.debug_rnglists' at offset 0x1d9a:
Packit 032894
Table at Offset 0x0:
Packit 032894
Packit 032894
 Length:               45
Packit 032894
 DWARF version:         5
Packit 032894
 Address size:          8
Packit 032894
 Segment size:          0
Packit 032894
 Offset entries:        0
Packit 032894
 CU [   218] base: 000000000000000000
Packit 032894
Packit 032894
  Offset: c, Index: 0
Packit 032894
    base_address 0x400583
Packit 032894
      0x0000000000400583 <calc+0x13>
Packit 032894
    offset_pair 0, 2
Packit 032894
      0x0000000000400583 <calc+0x13>..
Packit 032894
      0x0000000000400584 <calc+0x14>
Packit 032894
    offset_pair 5, 15
Packit 032894
      0x0000000000400588 <calc+0x18>..
Packit 032894
      0x0000000000400597 <calc+0x27>
Packit 032894
    end_of_list
Packit 032894
Packit 032894
  Offset: 1c, Index: 10
Packit 032894
    start_length 0x400570, 2b
Packit 032894
      0x0000000000400570 <calc>..
Packit 032894
      0x000000000040059a <calc+0x2a>
Packit 032894
    start_length 0x400410, 20
Packit 032894
      0x0000000000400410 <main>..
Packit 032894
      0x000000000040042f <main+0x1f>
Packit 032894
    end_of_list
Packit 032894
Packit 032894
EOF
Packit 032894
Packit 032894
# Same as above, but for DWARF4, note no header, and base address is not
Packit 032894
# given, but ranges are the same.
Packit 032894
testfiles testfile-dwarf-4
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=ranges testfile-dwarf-4<<\EOF
Packit 032894
Packit 032894
DWARF section [32] '.debug_ranges' at offset 0x1f96:
Packit 032894
Packit 032894
 CU [   21c] base: 000000000000000000
Packit 032894
 [     0] range 400583, 400585
Packit 032894
          0x0000000000400583 <calc+0x13>..
Packit 032894
          0x0000000000400584 <calc+0x14>
Packit 032894
          range 400588, 400598
Packit 032894
          0x0000000000400588 <calc+0x18>..
Packit 032894
          0x0000000000400597 <calc+0x27>
Packit 032894
 [    30] range 400570, 40059b
Packit 032894
          0x0000000000400570 <calc>..
Packit 032894
          0x000000000040059a <calc+0x2a>
Packit 032894
          range 400410, 400430
Packit 032894
          0x0000000000400410 <main>..
Packit 032894
          0x000000000040042f <main+0x1f>
Packit 032894
EOF
Packit 032894
Packit 032894
# Now with split dwarf. See tests/testfile-dwarf-45.source.
Packit 032894
# Note that this will have an offsets table that the .dwo can refer to.
Packit 032894
testfiles testfile-splitdwarf-5 testfile-hello5.dwo testfile-world5.dwo
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=ranges testfile-splitdwarf-5<<\EOF
Packit 032894
Packit 032894
DWARF section [35] '.debug_rnglists' at offset 0x393a:
Packit 032894
Table at Offset 0x0:
Packit 032894
Packit 032894
 Length:               53
Packit 032894
 DWARF version:         5
Packit 032894
 Address size:          8
Packit 032894
 Segment size:          0
Packit 032894
 Offset entries:        2
Packit 032894
 CU [    49] base: 000000000000000000
Packit 032894
Packit 032894
  Offsets starting at 0xc:
Packit 032894
   [     0] 0x8
Packit 032894
   [     1] 0x18
Packit 032894
Packit 032894
  Offset: 14, Index: 8
Packit 032894
    base_address 0x4011d3
Packit 032894
      0x00000000004011d3 <calc+0x13>
Packit 032894
    offset_pair 0, 2
Packit 032894
      0x00000000004011d3 <calc+0x13>..
Packit 032894
      0x00000000004011d4 <calc+0x14>
Packit 032894
    offset_pair 5, 15
Packit 032894
      0x00000000004011d8 <calc+0x18>..
Packit 032894
      0x00000000004011e7 <calc+0x27>
Packit 032894
    end_of_list
Packit 032894
Packit 032894
  Offset: 24, Index: 18
Packit 032894
    start_length 0x4011c0, 2b
Packit 032894
      0x00000000004011c0 <calc>..
Packit 032894
      0x00000000004011ea <calc+0x2a>
Packit 032894
    start_length 0x401060, 20
Packit 032894
      0x0000000000401060 <main>..
Packit 032894
      0x000000000040107f <main+0x1f>
Packit 032894
    end_of_list
Packit 032894
Packit 032894
EOF
Packit 032894
Packit 032894
# Note that the rnglist_base attribute of the second CU points to the offsets
Packit 032894
# above 0xc [c].
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=info testfile-splitdwarf-5<<\EOF
Packit 032894
Packit 032894
DWARF section [28] '.debug_info' at offset 0x3102:
Packit 032894
 [Offset]
Packit 032894
 Compilation unit at offset 0:
Packit 032894
 Version: 5, Abbreviation section offset: 0, Address size: 8, Offset size: 4
Packit 032894
 Unit type: skeleton (4), Unit id: 0xc422aa5c31fec205
Packit 032894
 [    14]  skeleton_unit        abbrev: 1
Packit 032894
           low_pc               (addr) 0x0000000000401160 <foo>
Packit 032894
           high_pc              (data8) 81 (0x00000000004011b1)
Packit 032894
           stmt_list            (sec_offset) 0
Packit 032894
           dwo_name             (strp) "testfile-hello5.dwo"
Packit 032894
           comp_dir             (strp) "/home/mark/src/elfutils/tests"
Packit 032894
           GNU_pubnames         (flag_present) yes
Packit 032894
           addr_base            (sec_offset) address base [     8]
Packit 032894
 Compilation unit at offset 53:
Packit 032894
 Version: 5, Abbreviation section offset: 21, Address size: 8, Offset size: 4
Packit 032894
 Unit type: skeleton (4), Unit id: 0xb6c8b9d97e6dfdfe
Packit 032894
 [    49]  skeleton_unit        abbrev: 1
Packit 032894
           ranges               (sec_offset) range list [    24]
Packit 032894
           low_pc               (addr) 000000000000000000
Packit 032894
           stmt_list            (sec_offset) 655
Packit 032894
           dwo_name             (strp) "testfile-world5.dwo"
Packit 032894
           comp_dir             (strp) "/home/mark/src/elfutils/tests"
Packit 032894
           GNU_pubnames         (flag_present) yes
Packit 032894
           addr_base            (sec_offset) address base [    a8]
Packit 032894
           rnglists_base        (sec_offset) range list [     c]
Packit 032894
EOF
Packit 032894
Packit 032894
# Same for DWARF4 GNU DebugFission. But now we need to scan the .dwo
Packit 032894
# explicitly to know it will use the first ranges.
Packit 032894
testfiles testfile-splitdwarf-4 testfile-hello4.dwo testfile-world4.dwo
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=ranges testfile-splitdwarf-4<<\EOF
Packit 032894
Packit 032894
DWARF section [32] '.debug_ranges' at offset 0x3611:
Packit 032894
Packit 032894
 CU [     b] base: 000000000000000000
Packit 032894
 [     0] range 4011d3, 4011d5
Packit 032894
          0x00000000004011d3 <calc+0x13>..
Packit 032894
          0x00000000004011d4 <calc+0x14>
Packit 032894
          range 4011d8, 4011e8
Packit 032894
          0x00000000004011d8 <calc+0x18>..
Packit 032894
          0x00000000004011e7 <calc+0x27>
Packit 032894
Packit 032894
 CU [    3f] base: 000000000000000000
Packit 032894
 [    30] range 4011c0, 4011eb
Packit 032894
          0x00000000004011c0 <calc>..
Packit 032894
          0x00000000004011ea <calc+0x2a>
Packit 032894
          range 401060, 401080
Packit 032894
          0x0000000000401060 <main>..
Packit 032894
          0x000000000040107f <main+0x1f>
Packit 032894
EOF
Packit 032894
Packit 032894
exit 0