Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / arr-stride.exp
CommitLineData
88b9d363 1# Copyright 2014-2022 Free Software Foundation, Inc.
dc53a7ad
JB
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/>.
15load_lib dwarf.exp
16
17# This test can only be run on targets which support DWARF-2 and use gas.
18if {![dwarf2_support]} {
19 return 0
20}
21
8c161360 22standard_testfile main.c -dw.S
dc53a7ad
JB
23
24# Make some DWARF for the test.
25set asm_file [standard_output_file $srcfile2]
26Dwarf::assemble $asm_file {
27 cu {} {
28 DW_TAG_compile_unit {
29 {DW_AT_language @DW_LANG_Ada95}
30 {DW_AT_name foo.adb}
31 {DW_AT_comp_dir /tmp}
32 } {
33 declare_labels integer_label array_elt_label array_label \
a15a276b 34 big_array_label struct_label
dc53a7ad
JB
35
36 integer_label: DW_TAG_base_type {
37 {DW_AT_byte_size 4 DW_FORM_sdata}
38 {DW_AT_encoding @DW_ATE_signed}
39 {DW_AT_name integer}
40 }
41
42 array_elt_label: DW_TAG_subrange_type {
43 {DW_AT_lower_bound 0xe0 DW_FORM_data1}
44 {DW_AT_upper_bound 0x1f DW_FORM_data1}
45 {DW_AT_name pck__item}
46 {DW_AT_type :$integer_label}
47 }
48
49 DW_TAG_typedef {
50 {DW_AT_name pck__table}
51 {DW_AT_type :$array_label}
52 }
53
54 array_label: DW_TAG_array_type {
55 {DW_AT_name pck__table}
56 {DW_AT_bit_stride 6 DW_FORM_data1}
57 {DW_AT_type :$array_elt_label}
58 } {
59 DW_TAG_subrange_type {
60 {DW_AT_type :$integer_label}
61 {DW_AT_lower_bound 0 DW_FORM_data1}
62 {DW_AT_upper_bound 4 DW_FORM_data1}
63 }
64 }
65
66 DW_TAG_typedef {
67 {DW_AT_name pck__big_table}
68 {DW_AT_type :$big_array_label}
69 }
70
71 big_array_label: DW_TAG_array_type {
72 {DW_AT_name pck__big_table}
73 {DW_AT_byte_stride 1 DW_FORM_data1}
74 {DW_AT_type :$array_elt_label}
75 } {
76 DW_TAG_subrange_type {
77 {DW_AT_type :$integer_label}
78 {DW_AT_lower_bound 0 DW_FORM_data1}
79 {DW_AT_upper_bound 4 DW_FORM_data1}
80 }
81 }
a15a276b
TT
82
83 struct_label: DW_TAG_structure_type {
84 {name struct_type}
85 {byte_size 16 DW_FORM_sdata}
86 } {
87 member {
88 {name intfield}
89 {type :$integer_label}
90 {data_member_location 0 DW_FORM_sdata}
91 }
92 member {
93 {name arrayfield}
94 {type :$array_label}
95 {data_member_location 4 DW_FORM_sdata}
96 }
97 }
98
99 DW_TAG_variable {
100 {name the_struct}
101 {external 1 DW_FORM_flag}
102 {location {
103 DW_OP_const1u 1
104 DW_OP_stack_value
105 DW_OP_piece 4
106 DW_OP_piece 12
107 } SPECIAL_expr}
108 {type :$struct_label}
109 }
dc53a7ad
JB
110 }
111 }
112}
113
5b362f04 114if { [prepare_for_testing "failed to prepare" ${testfile} \
e0c0f156 115 [list $srcfile $asm_file] {nodebug}] } {
dc53a7ad
JB
116 return -1
117}
118
dc53a7ad
JB
119gdb_test_no_output "set language ada"
120
121gdb_test "ptype pck.table" \
122 "type = array \\(0 \\.\\. 4\\) of pck\\.item <packed: 6-bit elements>"
123
124gdb_test "ptype pck.big_table" \
125 "type = array \\(0 \\.\\. 4\\) of pck\\.item <packed: 8-bit elements>"
a15a276b
TT
126
127gdb_test "print the_struct" \
128 "\\(intfield => 1, arrayfield => \\(0 => <optimized out>\\)\\)"
This page took 0.889639 seconds and 4 git commands to generate.