Copyright year update in most files of the GDB Project.
[external/binutils.git] / gdb / testsuite / gdb.ada / array_return.exp
1 # Copyright 2005-2012 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 if $tracelevel then {
17     strace $tracelevel
18 }
19
20 load_lib "ada.exp"
21
22 if { [skip_ada_tests] } { return -1 }
23
24 set testdir "array_return"
25 set testfile "${testdir}/p"
26 set srcfile ${srcdir}/${subdir}/${testfile}.adb
27 set binfile ${objdir}/${subdir}/${testfile}
28
29 file mkdir ${objdir}/${subdir}/${testdir}
30 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
31     return -1
32 }
33
34 clean_restart ${testfile}
35
36 # Start the inferior
37
38 if ![runto_main] then {
39    fail "Cannot run to main, testcase aborted"
40    return 0
41 }
42
43 # Create a breakpoint in each function from which we want to test
44 # the "finish" command.
45
46 gdb_test "break create_small" \
47          "Breakpoint \[0-9\]+ at.*: file .*pck.adb, line \[0-9\]+." \
48          "insert breakpoint in create_small"
49
50 gdb_test "break create_large" \
51          "Breakpoint \[0-9\]+ at.*: file .*pck.adb, line \[0-9\]+." \
52          "insert breakpoint in create_large"
53
54 gdb_test "break create_small_float_vector" \
55          "Breakpoint \[0-9\]+ at.*: file .*pck.adb, line \[0-9\]+." \
56          "insert breakpoint in create_small_float_vector"
57
58 # Then continue until reaching the first breakpoint inside Create_Small,
59 # and then do a "finish".
60
61 gdb_test "cont" \
62          "Breakpoint \[0-9\]+, pck.create_small \\(\\).*" \
63          "Continuing to Create_Small"
64
65 gdb_test "finish" \
66          "Value returned is \\\$\[0-9\]+ = \\(1, 1\\)" \
67          "value printed by finish of Create_Small"
68
69 # Now continue until reaching the second breakpoint inside Create_Large,
70 # and then do another "finish".
71
72 gdb_test "cont" \
73          "Breakpoint \[0-9\]+, pck.create_large \\(\\).*" \
74          "Continuing to Create_Large"
75
76 # On hppa32, the value returned is too large to be returned via a register.
77 # Instead, it is returned using the struct convention, and the debugger
78 # unfortunately cannot find the address of the result.  The following
79 # test is therefore expected to fail for all hppa targets except hppa64.
80 if { ! [istarget "hppa*64*-*-*"] } then {
81   setup_xfail "hppa*-*-*"
82 }
83
84 gdb_test "finish" \
85          "Value returned is \\\$\[0-9\]+ = \\(2, 2, 2, 2\\)" \
86          "value printed by finish of Create_Large"
87
88 # Now continue until reaching the third breakpoint, and then do another
89 # "finish" again.
90
91 gdb_test "cont" \
92          "Breakpoint \[0-9\]+, pck.create_small_float_vector \\(\\).*" \
93          "Continuing to Create_Small_Float_Vector"
94
95 gdb_test "finish" \
96          "Value returned is \\\$\[0-9\]+ = \\(4.25, 4.25\\)" \
97          "value printed by finish of Create_Small_Float_Vector"
98