aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada/array_return.exp
blob: a11cbea6bf8885c5bf3510f36f3a2e99a1ee62e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Copyright 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

if $tracelevel then {
    strace $tracelevel
}

load_lib "ada.exp"

if { [skip_ada_tests] } { return -1 }

set testdir "array_return"
set testfile "${testdir}/p"
set srcfile ${srcdir}/${subdir}/${testfile}.adb
set binfile ${objdir}/${subdir}/${testfile}

file mkdir ${objdir}/${subdir}/${testdir}
if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
    return -1
}

gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}

# Start the inferior

if ![runto_main] then {
   fail "Cannot run to main, testcase aborted"
   return 0
}

# Create a breakpoint in each function from which we want to test
# the "finish" command.

gdb_test "break create_small" \
         "Breakpoint \[0-9\]+ at.*: file .*pck.adb, line \[0-9\]+." \
         "insert breakpoint in create_small"

gdb_test "break create_large" \
         "Breakpoint \[0-9\]+ at.*: file .*pck.adb, line \[0-9\]+." \
         "insert breakpoint in create_large"

gdb_test "break create_small_float_vector" \
         "Breakpoint \[0-9\]+ at.*: file .*pck.adb, line \[0-9\]+." \
         "insert breakpoint in create_small_float_vector"

# Then continue until reaching the first breakpoint inside Create_Small,
# and then do a "finish".

gdb_test "cont" \
         "Breakpoint \[0-9\]+, pck.create_small \\(\\).*" \
         "Continuing to Create_Small"

gdb_test "finish" \
         "Value returned is \\\$\[0-9\]+ = \\(1, 1\\)" \
         "value printed by finish of Create_Small"

# Now continue until reaching the second breakpoint inside Create_Large,
# and then do another "finish".

gdb_test "cont" \
         "Breakpoint \[0-9\]+, pck.create_large \\(\\).*" \
         "Continuing to Create_Large"

# On hppa32, the value returned is too large to be returned via a register.
# Instead, it is returned using the struct convention, and the debugger
# unfortunately cannot find the address of the result.  The following
# test is therefore expected to fail for all hppa targets except hppa64.
if { ! [istarget "hppa*64*-*-*"] } then {
  setup_xfail "hppa*-*-*"
}

gdb_test "finish" \
         "Value returned is \\\$\[0-9\]+ = \\(2, 2, 2, 2\\)" \
         "value printed by finish of Create_Large"

# Now continue until reaching the third breakpoint, and then do another
# "finish" again.

gdb_test "cont" \
         "Breakpoint \[0-9\]+, pck.create_small_float_vector \\(\\).*" \
         "Continuing to Create_Small_Float_Vector"

gdb_test "finish" \
         "Value returned is \\\$\[0-9\]+ = \\(4.25, 4.25\\)" \
         "value printed by finish of Create_Small_Float_Vector"