Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2000-2020 Free Software Foundation, Inc. |
efb66345 MS |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
efb66345 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
efb66345 MS |
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. | |
e22f8b7c | 12 | # |
efb66345 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
efb66345 | 15 | |
efb66345 MS |
16 | # This file was written by Michael Snyder (msnyder@redhat.com) |
17 | ||
efb66345 | 18 | |
822bd149 TT |
19 | standard_testfile .c |
20 | ||
efb66345 | 21 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { |
84c93cd5 | 22 | untested "failed to compile" |
b60f0898 | 23 | return -1 |
efb66345 MS |
24 | } |
25 | ||
27aba047 YQ |
26 | set skip_float_test [gdb_skip_float_test] |
27 | ||
efb66345 MS |
28 | proc return_1 { type } { |
29 | global gdb_prompt | |
30 | ||
31 | gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \ | |
32 | "set break on ${type}_func" | |
33 | gdb_test "continue" "Breakpoint.* ${type}_func.*" \ | |
34 | "continue to ${type}_func" | |
02746bbc MS |
35 | |
36 | gdb_test_multiple "return testval.${type}_testval" \ | |
37 | "return from ${type}_func" { | |
38 | -re "Make ${type}_func return now.*y or n. $" { | |
39 | send_gdb "y\n" | |
40 | exp_continue | |
41 | } | |
42 | -re ".*${type}_resultval *= ${type}_func.*$gdb_prompt $" { | |
43 | send_gdb "step\n" | |
44 | exp_continue | |
45 | } | |
46 | -re ".*${type}_checkpoint.*$gdb_prompt $" { | |
47 | pass "return from ${type}_func" | |
48 | } | |
efb66345 | 49 | } |
efb66345 MS |
50 | gdb_test "print ${type}_resultval == testval.${type}_testval" ".* = 1" \ |
51 | "${type} value returned successfully" | |
52 | gdb_test "print ${type}_resultval != ${type}_returnval" ".* = 1" \ | |
c2b75043 | 53 | "validate result value not equal to program return value, ${type}" |
efb66345 MS |
54 | } |
55 | ||
56 | proc return_void { } { | |
57 | global gdb_prompt | |
58 | ||
59 | gdb_test "break void_func" "Breakpoint \[0123456789\].*" \ | |
60 | "set break on void_func" | |
61 | gdb_test "continue" "Breakpoint.* void_func.*" \ | |
62 | "continue to void_func" | |
02746bbc MS |
63 | |
64 | gdb_test_multiple "return" "return from void_func" { | |
efb66345 MS |
65 | -re "Make void_func return now.*y or n. $" { |
66 | send_gdb "y\n" | |
67 | exp_continue | |
68 | } | |
69 | -re ".*void_func.*call to void_func.*$gdb_prompt $" { | |
70 | send_gdb "step\n" | |
71 | exp_continue | |
72 | } | |
73 | -re ".*void_checkpoint.*$gdb_prompt $" { | |
74 | pass "return from void_func" | |
75 | } | |
efb66345 MS |
76 | } |
77 | gdb_test "print void_test == 0" ".* = 1" \ | |
78 | "void function returned successfully" | |
79 | } | |
80 | ||
81 | proc return2_tests { } { | |
27aba047 | 82 | global gdb_prompt skip_float_test |
efb66345 | 83 | |
3ad13771 | 84 | if { ! [ runto_main ] } then { |
84c93cd5 | 85 | untested "couldn't run to main" |
b60f0898 | 86 | return -1 |
efb66345 MS |
87 | } |
88 | ||
89 | return_void | |
90 | return_1 "char" | |
91 | return_1 "short" | |
92 | return_1 "int" | |
93 | return_1 "long" | |
686d097c | 94 | if { ! [istarget "m6811-*-*"] && ![istarget "h8300*-*"] } then { |
d6f5fea1 SC |
95 | return_1 "long_long" |
96 | } | |
27aba047 | 97 | if {!$skip_float_test} { |
d426f7b4 MS |
98 | return_1 "float" |
99 | if { ! [istarget "m6811-*-*"] } then { | |
100 | return_1 "double" | |
101 | } | |
d6f5fea1 | 102 | } |
efb66345 MS |
103 | } |
104 | ||
105 | # Start with a fresh gdb. | |
106 | ||
822bd149 | 107 | clean_restart ${binfile} |
efb66345 MS |
108 | |
109 | set timeout 30 | |
110 | return2_tests |