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