]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / ada-valprint-error.exp
1 # Copyright 2017-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 load_lib dwarf.exp
16
17 # This test can only be run on targets which support DWARF-2 and use gas.
18 require dwarf2_support
19
20 standard_testfile .c -dw.S
21
22 # We need to know the size of integer and address types in order
23 # to write some of the debugging info we'd like to generate.
24 #
25 # For that, we ask GDB by debugging our ada-valprint-error.c program.
26 # Any program would do, but since we already have ada-valprint-error.c
27 # specifically for this testcase, might as well use that.
28
29 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
30 untested "failed to compile"
31 return -1
32 }
33
34 # Make some DWARF for the test.
35 set asm_file [standard_output_file $srcfile2]
36 Dwarf::assemble $asm_file {
37 cu {} {
38 DW_TAG_compile_unit {
39 {DW_AT_language @DW_LANG_Ada95}
40 {DW_AT_name fd.adb}
41 {DW_AT_comp_dir /tmp}
42 } {
43 declare_labels array_elt_label integer_label array_label \
44 typedef_label ref_type_label
45 set ptr_size [get_sizeof "void *" 96]
46 set int_size [get_sizeof "int" 4]
47
48 # A structure with no size attribute, to mimick structures
49 # in Ada that have a dynamic size...
50 array_elt_label: structure_type {
51 {name fd__Tints_doubledC}
52 {artificial 1 DW_FORM_flag_present}
53 }
54
55 # ... and a corresponding XVZ variable, supposed to be there
56 # to provide the actual size. Except that, in this case,
57 # the variable has no address, to simulate the fact that
58 # it has been optimized out (which the compiler can do,
59 # even if it at the expense of debuggability).
60 DW_TAG_variable {
61 {name fd__Tints_doubledC___XVZ}
62 {DW_AT_type :$integer_label}
63 {artificial 1 DW_FORM_flag_present}
64 }
65
66 integer_label: DW_TAG_base_type {
67 {DW_AT_byte_size $int_size DW_FORM_sdata}
68 {DW_AT_encoding @DW_ATE_signed}
69 {DW_AT_name integer}
70 }
71
72 array_label: DW_TAG_array_type {
73 {DW_AT_name fd__ints_doubled}
74 {DW_AT_type :$array_elt_label}
75 } {
76 DW_TAG_subrange_type {
77 {DW_AT_type :$integer_label}
78 {DW_AT_upper_bound 2 DW_FORM_data1}
79 }
80 }
81
82 typedef_label: DW_TAG_typedef {
83 {DW_AT_name fd__ints_doubled}
84 {DW_AT_type :$array_label}
85 }
86
87 ref_type_label: DW_TAG_reference_type {
88 {DW_AT_byte_size $ptr_size DW_FORM_sdata}
89 {DW_AT_type :$typedef_label}
90 }
91
92 DW_TAG_variable {
93 {name fd__global}
94 {DW_AT_type :$ref_type_label}
95 {DW_AT_location {
96 DW_OP_addr [gdb_target_symbol fd__global]
97 } SPECIAL_expr}
98 {external 1 flag}
99 }
100
101 }
102 }
103 }
104
105 if { [prepare_for_testing ${testfile}.exp ${testfile} \
106 [list $srcfile $asm_file] {nodebug}] } {
107 return -1
108 }
109
110 gdb_test_no_output "set language ada"
111
112 gdb_test "print fd.global" \
113 " = <error reading variable: unable to read value of fd__Tints_doubledC___XVZ \\(value has been optimized out\\)>"