1# Copyright 2005-2020 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
16load_lib "ada.exp"
17
18if { [skip_ada_tests] } { return -1 }
19
20standard_ada_testfile p
21
22if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
23    return -1
24}
25
26if [get_compiler_info] {
27    return -1
28}
29set old_gcc [expr [test_compiler_info {gcc-[0-3]-*}] \
30	     || [test_compiler_info {gcc-4-[0-6]-*}]]
31
32clean_restart ${testfile}
33
34set bp_location [gdb_get_line_number "START" ${testdir}/p.adb]
35runto "p.adb:$bp_location"
36
37# First, print all the arrays without indexes
38
39gdb_test_no_output "set print array-indexes off"
40
41if $old_gcc {
42    setup_xfail "*-*-*"
43}
44gdb_test "print one_two_three" \
45         "= \\(1, 2, 3\\)" \
46         "print one_two_three, indexes off"
47
48gdb_test "print e_one_two_three" \
49         "= \\(1, 2, 3\\)" \
50         "print e_one_two_three, indexes off"
51
52gdb_test "print r_two_three" \
53         "= \\(two => 2, 3\\)" \
54         "print r_two_three, indexes off"
55
56gdb_test "print u_one_two_three" \
57         "= \\(1, 2, 3\\)" \
58         "print u_one_two_three, indexes off"
59
60gdb_test "print p_one_two_three" \
61         "= \\(false, true, true\\)" \
62         "print p_one_two_three, indexes off"
63
64if $old_gcc {
65    setup_xfail "*-*-*"
66}
67gdb_test "print few_reps" \
68         "= \\(1, 2, 3, 3, 3, 3, 3, 4, 5\\)" \
69         "print few_reps, indexes off"
70
71if $old_gcc {
72    setup_xfail "*-*-*"
73}
74gdb_test "print many_reps" \
75         "= \\(1, 2, 3 <repeats 12 times>, 4, 5\\)" \
76         "print many_reps, indexes off"
77
78if $old_gcc {
79    setup_xfail "*-*-*"
80}
81gdb_test "print empty" \
82         "= \\(\\)" \
83         "print empty, indexes off"
84
85# Next, print all the arrays with the indexes
86
87gdb_test_no_output "set print array-indexes on"
88
89if $old_gcc {
90    setup_xfail "*-*-*"
91}
92gdb_test "print one_two_three" \
93         "= \\(1 => 1, 2 => 2, 3 => 3\\)"
94
95gdb_test "print e_one_two_three" \
96         "= \\(one => 1, two => 2, three => 3\\)"
97
98gdb_test "print r_two_three" \
99         "= \\(two => 2, three => 3\\)"
100
101gdb_test "print u_one_two_three" \
102         "= \\(1 => 1, 2 => 2, 3 => 3\\)"
103
104gdb_test "print p_one_two_three" \
105         "= \\(one => false, two => true, three => true\\)"
106
107if $old_gcc {
108    setup_xfail "*-*-*"
109}
110gdb_test "print few_reps" \
111         "= \\(1 => 1, 2 => 2, 3 => 3, 4 => 3, 5 => 3, 6 => 3, 7 => 3, 8 => 4, 9 => 5\\)"
112
113if $old_gcc {
114    setup_xfail "*-*-*"
115}
116gdb_test "print many_reps" \
117         "= \\(1 => 1, 2 => 2, 3 => 3 <repeats 12 times>, 15 => 4, 16 => 5\\)"
118
119if $old_gcc {
120    setup_xfail "*-*-*"
121}
122gdb_test "print empty" \
123         "= \\(\\)"
124