mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-02 19:46:09 +08:00

It is possible for the tables in the .debug_{rng,loc}lists sections to not have an array of offsets. In that case, the offset_entry_count field of the header is 0. The forms DW_FORM_{rng,loc}listx (reference by index) can't be used with that table. Instead, the DW_FORM_sec_offset form, which references a {rng,loc}list by direct offset in the section, must be used. From what I saw, this is what GCC currently produces. Add tests for this case. I didn't see any bug related to this, I just think that it would be nice to have coverage for this. A new `-with-offset-array` option is added to the `table` procs, used when generating {rng,loc}lists, to decide whether to generate the offset array. gdb/testsuite/ChangeLog: * lib/dwarf.exp (rnglists): Add -no-offset-array option to table proc. * gdb.dwarf2/rnglists-sec-offset.exp: Add test for .debug_rnglists table without offset array. * gdb.dwarf2/loclists-sec-offset.exp: Add test for .debug_loclists table without offset array. Change-Id: I8e34a7bf68c9682215ffbbf66600da5b7db91ef7
144 lines
3.6 KiB
Plaintext
144 lines
3.6 KiB
Plaintext
# Copyright 2020 Free Software Foundation, Inc.
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# Test DW_AT_ranges attributes referencing the .debug_rnglists section using the
|
|
# DW_FORM_sec_offset form.
|
|
|
|
load_lib dwarf.exp
|
|
|
|
if {![dwarf2_support]} {
|
|
return 0
|
|
}
|
|
|
|
foreach_with_prefix is_64 {false true} {
|
|
if { $is_64 } {
|
|
standard_testfile main.c -dw64.S
|
|
set testfile ${testfile}-dw64
|
|
} else {
|
|
standard_testfile main.c -dw32.S
|
|
set testfile ${testfile}-dw32
|
|
}
|
|
|
|
set asm_file [standard_output_file $srcfile2]
|
|
Dwarf::assemble $asm_file {
|
|
global is_64
|
|
|
|
declare_labels cu1_range_list cu2_range_list cu3_range_list
|
|
declare_labels foo_range_list bar_range_list baz_range_list
|
|
|
|
# This CU uses the DW_FORM_sec_offset form to refer to the .debug_rnglists
|
|
# section.
|
|
cu {
|
|
version 5
|
|
is_64 $is_64
|
|
} {
|
|
DW_TAG_compile_unit {
|
|
{DW_AT_ranges $cu1_range_list DW_FORM_sec_offset}
|
|
} {
|
|
DW_TAG_subprogram {
|
|
{DW_AT_name "foo"}
|
|
{DW_AT_ranges $foo_range_list DW_FORM_sec_offset}
|
|
}
|
|
}
|
|
}
|
|
|
|
# This CU uses the DW_FORM_sec_offset form to refer to the
|
|
# .debug_rnglists section, but also has the DW_AT_rnglists_base
|
|
# attribute present. The DW_AT_rnglists_base attribute is not used to
|
|
# interpret the DW_AT_ranges value, but it should also do no harm.
|
|
cu {
|
|
version 5
|
|
is_64 $is_64
|
|
} {
|
|
DW_TAG_compile_unit {
|
|
{DW_AT_ranges $cu2_range_list DW_FORM_sec_offset}
|
|
{DW_AT_rnglists_base cu2_table DW_FORM_sec_offset}
|
|
} {
|
|
DW_TAG_subprogram {
|
|
{DW_AT_name "bar"}
|
|
{DW_AT_ranges $bar_range_list DW_FORM_sec_offset}
|
|
}
|
|
}
|
|
}
|
|
|
|
# This CU uses the DW_FORM_sec_offset form to refer to the .debug_rnglists
|
|
# section. The corresponding contribution in the .debug_rnglists has no
|
|
# offset array.
|
|
cu {
|
|
version 5
|
|
is_64 $is_64
|
|
} {
|
|
DW_TAG_compile_unit {
|
|
{DW_AT_ranges $cu3_range_list DW_FORM_sec_offset}
|
|
} {
|
|
DW_TAG_subprogram {
|
|
{DW_AT_name "baz"}
|
|
{DW_AT_ranges $baz_range_list DW_FORM_sec_offset}
|
|
}
|
|
}
|
|
}
|
|
|
|
rnglists -is-64 $is_64 {
|
|
# The lists in this table are accessed by direct offset
|
|
# (DW_FORM_sec_offset).
|
|
table {
|
|
# For the first CU.
|
|
cu1_range_list: list_ {
|
|
start_end 0x4000 0x5000
|
|
}
|
|
|
|
# For function foo.
|
|
foo_range_list: list_ {
|
|
start_end 0x4000 0x4010
|
|
}
|
|
}
|
|
|
|
table -post-header-label cu2_table {
|
|
# For the second CU.
|
|
cu2_range_list: list_ {
|
|
start_end 0x5000 0x6000
|
|
}
|
|
|
|
# For the bar function.
|
|
bar_range_list: list_ {
|
|
start_end 0x5000 0x5010
|
|
}
|
|
}
|
|
|
|
table -with-offset-array false {
|
|
# For the third CU.
|
|
cu3_range_list: list_ {
|
|
start_end 0x6000 0x7000
|
|
}
|
|
|
|
# For the baz function.
|
|
baz_range_list: list_ {
|
|
start_end 0x6000 0x6010
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if { [prepare_for_testing "failed to prepare" ${testfile} \
|
|
[list $srcfile $asm_file] {nodebug}] } {
|
|
return -1
|
|
}
|
|
|
|
# Sanity checks to make sure GDB slurped the symbols correctly.
|
|
gdb_test "p/x &foo" " = 0x4000"
|
|
gdb_test "p/x &bar" " = 0x5000"
|
|
gdb_test "p/x &baz" " = 0x6000"
|
|
}
|