]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/implptrconst.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / implptrconst.exp
1 # Copyright 2013-2024 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
16 load_lib dwarf.exp
17
18 # This test can only be run on targets which support DWARF-2 and use gas.
19 require dwarf2_support
20
21 require allow_cplus_tests
22
23 standard_testfile main.c -dw.S
24
25 # Make some DWARF for the test.
26 set asm_file [standard_output_file $srcfile2]
27 Dwarf::assemble $asm_file {
28 # Creating a CU with 4-byte addresses lets this test link on both
29 # 32- and 64-bit machines.
30 cu { addr_size 4 } {
31 compile_unit {} {
32 declare_labels byte_label size_type_label array_label
33 declare_labels var_label ptr_label
34
35 byte_label: base_type {
36 {name byte}
37 {encoding @DW_ATE_signed}
38 {byte_size 1 DW_FORM_sdata}
39 }
40
41 size_type_label: base_type {
42 {name sizetype}
43 {encoding @DW_ATE_unsigned}
44 {byte_size 4 DW_FORM_sdata}
45 }
46
47 array_label: array_type {
48 {type :$byte_label}
49 } {
50 subrange_type {
51 {type :$size_type_label}
52 {upper_bound 7 DW_FORM_data1}
53 }
54 }
55
56 var_label: DW_TAG_variable {
57 {name b}
58 {type :$array_label}
59 {const_value rstuvwxy DW_FORM_block1}
60 }
61
62 ptr_label: pointer_type {
63 {byte_size 4 DW_FORM_sdata}
64 {type :$byte_label}
65 }
66
67 DW_TAG_variable {
68 {name c}
69 {type :$ptr_label}
70 {location {
71 GNU_implicit_pointer $var_label 0
72 } SPECIAL_expr}
73 }
74
75 DW_TAG_variable {
76 {name d}
77 {type :$ptr_label}
78 {location {
79 GNU_implicit_pointer $var_label 2
80 } SPECIAL_expr}
81 }
82 }
83 }
84 }
85
86 if { [build_executable ${testfile}.exp ${testfile} \
87 [list $srcfile $asm_file] {nodebug}] } {
88 return -1
89 }
90
91 # We need --readnow because otherwise we never read in the CU we
92 # created above.
93 set saved_gdbflags $GDBFLAGS
94 set GDBFLAGS "$GDBFLAGS -readnow"
95 clean_restart ${testfile}
96 set GDBFLAGS $saved_gdbflags
97
98 if ![runto_main] {
99 return -1
100 }
101
102 gdb_test "print *c" " = 114 'r'"
103 gdb_test "print d\[-2\]" " = 114 'r'"