run copyright.sh for 2011.
[external/binutils.git] / gdb / testsuite / gdb.ada / array_return.exp
1 # Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011
2 # Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 if $tracelevel then {
18     strace $tracelevel
19 }
20
21 load_lib "ada.exp"
22
23 if { [skip_ada_tests] } { return -1 }
24
25 set testdir "array_return"
26 set testfile "${testdir}/p"
27 set srcfile ${srcdir}/${subdir}/${testfile}.adb
28 set binfile ${objdir}/${subdir}/${testfile}
29
30 file mkdir ${objdir}/${subdir}/${testdir}
31 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
32     return -1
33 }
34
35 gdb_exit
36 gdb_start
37 gdb_reinitialize_dir $srcdir/$subdir
38 gdb_load ${binfile}
39
40 # Start the inferior
41
42 if ![runto_main] then {
43    fail "Cannot run to main, testcase aborted"
44    return 0
45 }
46
47 # Create a breakpoint in each function from which we want to test
48 # the "finish" command.
49
50 gdb_test "break create_small" \
51          "Breakpoint \[0-9\]+ at.*: file .*pck.adb, line \[0-9\]+." \
52          "insert breakpoint in create_small"
53
54 gdb_test "break create_large" \
55          "Breakpoint \[0-9\]+ at.*: file .*pck.adb, line \[0-9\]+." \
56          "insert breakpoint in create_large"
57
58 gdb_test "break create_small_float_vector" \
59          "Breakpoint \[0-9\]+ at.*: file .*pck.adb, line \[0-9\]+." \
60          "insert breakpoint in create_small_float_vector"
61
62 # Then continue until reaching the first breakpoint inside Create_Small,
63 # and then do a "finish".
64
65 gdb_test "cont" \
66          "Breakpoint \[0-9\]+, pck.create_small \\(\\).*" \
67          "Continuing to Create_Small"
68
69 gdb_test "finish" \
70          "Value returned is \\\$\[0-9\]+ = \\(1, 1\\)" \
71          "value printed by finish of Create_Small"
72
73 # Now continue until reaching the second breakpoint inside Create_Large,
74 # and then do another "finish".
75
76 gdb_test "cont" \
77          "Breakpoint \[0-9\]+, pck.create_large \\(\\).*" \
78          "Continuing to Create_Large"
79
80 # On hppa32, the value returned is too large to be returned via a register.
81 # Instead, it is returned using the struct convention, and the debugger
82 # unfortunately cannot find the address of the result.  The following
83 # test is therefore expected to fail for all hppa targets except hppa64.
84 if { ! [istarget "hppa*64*-*-*"] } then {
85   setup_xfail "hppa*-*-*"
86 }
87
88 gdb_test "finish" \
89          "Value returned is \\\$\[0-9\]+ = \\(2, 2, 2, 2\\)" \
90          "value printed by finish of Create_Large"
91
92 # Now continue until reaching the third breakpoint, and then do another
93 # "finish" again.
94
95 gdb_test "cont" \
96          "Breakpoint \[0-9\]+, pck.create_small_float_vector \\(\\).*" \
97          "Continuing to Create_Small_Float_Vector"
98
99 gdb_test "finish" \
100          "Value returned is \\\$\[0-9\]+ = \\(4.25, 4.25\\)" \
101          "value printed by finish of Create_Small_Float_Vector"
102