1 # Copyright 2011-2021 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 { dwarf_version offset_size addr_size ref_addr_size two_cu } {
25 global testfile srcfile
27 set name "d${dwarf_version}o${offset_size}a${addr_size}r${ref_addr_size}t${two_cu}"
29 # Make some DWARF for the test.
30 set asm_file [standard_output_file ${testfile}-${name}.S]
31 Dwarf::assemble $asm_file {
32 upvar dwarf_version dwarf_version
33 upvar addr_size addr_size
34 upvar offset_size offset_size
35 upvar ref_addr_size ref_addr_size
38 set is_64 [expr { $offset_size == 4 ? 0 : 1 }]
41 version $dwarf_version
46 { producer "GNU C 4.4.3" }
47 { language @DW_LANG_C89 }
50 declare_labels struct_label variable_label int_label pointer_label
52 int_label: base_type {
53 { byte_size 4 DW_FORM_sdata }
54 { DW_AT_encoding @DW_ATE_signed }
58 struct_label: structure_type {
65 { data_member_location 0 data1 }
69 pointer_label: pointer_type {
70 { byte_size $Dwarf::_cu_addr_size sdata }
71 { type :$struct_label }
74 variable_label: DW_TAG_variable {
77 DW_OP_implicit_value 0x1 0x1 0x1 0x1
79 { type :$struct_label "DW_FORM_ref$ref_addr_size" }
84 {MACRO_AT_func {main}}
91 GNU_implicit_pointer $variable_label 0
93 { type :$pointer_label "DW_FORM_ref$ref_addr_size" }
102 version $dwarf_version
107 { producer "GNU C 4.4.3" }
108 { language @DW_LANG_C89 }
112 { MACRO_AT_func {main} }
119 GNU_implicit_pointer $variable_label 0
121 { type %$pointer_label }
129 # 32-bit targets do not support any of the testcases; keep quiet there.
131 set executable ${testfile}-${name}
132 if [prepare_for_testing "failed to prepare" $executable "${asm_file} ${srcfile}" $opts] {
140 gdb_test "p/x p->f" " = 0x1010101" $name
143 # DWARF_VERSION OFFSET_SIZE ADDR_SIZE REF_ADDR_SIZE TWO_CU