1 # Copyright 2021-2023 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Test DW_AT_location attribute referencing the .debug_loc section using
17 # the DW_FORM_sec_offset form.
21 if {![dwarf2_support]} {
25 # Test with 32-bit and 64-bit DWARF.
26 foreach_with_prefix is_64 {false true} {
28 standard_testfile .c -dw64.S
29 set testfile ${testfile}-dw64
31 standard_testfile .c -dw32.S
32 set testfile ${testfile}-dw32
35 lassign [function_range func1 $srcdir/$subdir/$srcfile] \
37 lassign [function_range func2 $srcdir/$subdir/$srcfile] \
40 set asm_file [standard_output_file $srcfile2]
41 Dwarf::assemble $asm_file {
42 global func1_addr func1_len
43 global func2_addr func2_len
52 declare_labels int_type1
53 declare_labels foo_location_list
57 int_type1: DW_TAG_base_type {
58 {DW_AT_byte_size 4 DW_FORM_data1}
59 {DW_AT_encoding @DW_ATE_signed}
65 {DW_AT_location $foo_location_list DW_FORM_sec_offset}
66 {DW_AT_type :$int_type1}
71 {DW_AT_low_pc $func1_addr}
72 {DW_AT_high_pc $func1_len DW_FORM_udata}
77 {DW_AT_low_pc $func2_addr}
78 {DW_AT_high_pc $func2_len DW_FORM_udata}
83 # Generate a .debug_loc contribution.
86 cu_version $cu_version
89 entry $func1_addr "$func1_addr + $func1_len" {
93 entry $func2_addr "$func2_addr + $func2_len" {
100 if { [prepare_for_testing "failed to prepare" ${testfile} \
101 [list $srcfile $asm_file] {nodebug}] } {
105 if { ![runto_main] } {
109 gdb_breakpoint "func1"
110 gdb_breakpoint "func2"
112 gdb_continue_to_breakpoint "func1"
113 with_test_prefix "at func1" {
114 gdb_test "print /x foo" " = 0x123456"
117 gdb_continue_to_breakpoint "func2"
118 with_test_prefix "at func2" {
119 gdb_test "print /x foo" " = 0x234567"