]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.ada/arraydim.exp
087e2c1e6b7d1a983b35a42a3ed3d5baaf57a860
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.ada / arraydim.exp
1 # Copyright 2013-2023 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 "ada.exp"
17
18 require allow_ada_tests
19
20 standard_ada_testfile foo
21
22 set cfile "inc"
23 set csrcfile ${srcdir}/${subdir}/${testdir}/${cfile}.c
24 set cobject [standard_output_file ${cfile}.o]
25
26 gdb_compile "${csrcfile}" "${cobject}" object [list debug]
27 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-largs additional_flags=${cobject} additional_flags=-margs]] != "" } {
28 return -1
29 }
30
31 clean_restart ${testfile}
32
33 set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
34 runto "foo.adb:$bp_location"
35
36 gdb_test "ptype m" \
37 "array \\(1 \\.\\. 1, 2 \\.\\. 3, 4 \\.\\. 6\\) of integer"
38
39 gdb_test "print m'first" " = 1"
40 gdb_test "print m'last" " = 1"
41 gdb_test "print m'length" " = 1"
42
43 gdb_test "print m'first(1)" " = 1"
44 gdb_test "print m'last(1)" " = 1"
45 gdb_test "print m'length(1)" " = 1"
46
47 gdb_test "print m'first(2)" " = 2"
48 gdb_test "print m'last(2)" " = 3"
49 gdb_test "print m'length(2)" " = 2"
50
51 gdb_test "print m'first(3)" " = 4"
52 gdb_test "print m'last(3)" " = 6"
53 gdb_test "print m'length(3)" " = 3"
54
55 gdb_test "ptype global_3dim_for_gdb_testing" \
56 "array \\(0 \\.\\. 0, 0 \\.\\. 1, 0 \\.\\. 2\\) of int"
57
58 gdb_test "print global_3dim_for_gdb_testing'first" " = 0"
59 gdb_test "print global_3dim_for_gdb_testing'last" " = 0"
60 gdb_test "print global_3dim_for_gdb_testing'length" " = 1"
61
62 gdb_test "print global_3dim_for_gdb_testing'first(1)" " = 0"
63 gdb_test "print global_3dim_for_gdb_testing'last(1)" " = 0"
64 gdb_test "print global_3dim_for_gdb_testing'length(1)" " = 1"
65
66 gdb_test "print global_3dim_for_gdb_testing'first(2)" " = 0"
67 gdb_test "print global_3dim_for_gdb_testing'last(2)" " = 1"
68 gdb_test "print global_3dim_for_gdb_testing'length(2)" " = 2"
69
70 gdb_test "print global_3dim_for_gdb_testing'first(3)" " = 0"
71 gdb_test "print global_3dim_for_gdb_testing'last(3)" " = 2"
72 gdb_test "print global_3dim_for_gdb_testing'length(3)" " = 3"