1 # Copyright 2011-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/>.
17 # This test can only be run on targets which support DWARF-2 and use gas.
18 if {![dwarf2_support]} {
22 standard_testfile main.c
24 proc test_1 { name dwarf_version offset_size addr_size ref_addr_size two_cu } {
25 global testfile srcfile
27 # Make some DWARF for the test.
28 set asm_file [standard_output_file ${testfile}-${name}.S]
29 Dwarf::assemble $asm_file {
30 upvar dwarf_version dwarf_version
31 upvar addr_size addr_size
32 upvar offset_size offset_size
33 upvar ref_addr_size ref_addr_size
36 set is_64 [expr { $offset_size == 4 ? 0 : 1 }]
39 version $dwarf_version
44 { producer "GNU C 4.4.3" }
45 { language @DW_LANG_C89 }
48 declare_labels struct_label variable_label int_label pointer_label
50 int_label: base_type {
51 { byte_size 4 DW_FORM_sdata }
52 { DW_AT_encoding @DW_ATE_signed }
56 struct_label: structure_type {
63 { data_member_location 0 data1 }
67 pointer_label: pointer_type {
68 { byte_size $Dwarf::_cu_addr_size sdata }
69 { type :$struct_label }
72 variable_label: DW_TAG_variable {
75 DW_OP_implicit_value 0x1 0x1 0x1 0x1
77 { type :$struct_label "DW_FORM_ref$ref_addr_size" }
82 {MACRO_AT_func {main}}
89 GNU_implicit_pointer $variable_label 0
91 { type :$pointer_label "DW_FORM_ref$ref_addr_size" }
100 version $dwarf_version
105 { producer "GNU C 4.4.3" }
106 { language @DW_LANG_C89 }
110 { MACRO_AT_func {main} }
117 GNU_implicit_pointer $variable_label 0
119 { type %$pointer_label }
127 # 32-bit targets do not support any of the testcases; keep quiet there.
129 set executable ${testfile}-${name}
130 if [prepare_for_testing "failed to prepare" $executable "${asm_file} ${srcfile}" $opts] {
138 gdb_test "p/x p->f" " = 0x1010101"
141 proc test { dwarf_version offset_size addr_size ref_addr_size two_cu } {
145 "d${dwarf_version}" \
148 "r${ref_addr_size}" \
150 set name [join $name "-"]
151 with_test_prefix $name {
153 $dwarf_version $offset_size $addr_size $ref_addr_size $two_cu
157 # DWARF_VERSION OFFSET_SIZE ADDR_SIZE REF_ADDR_SIZE TWO_CU