Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2000-2016 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}] != "" } { |
b60f0898 JB |
22 | untested return2.exp |
23 | return -1 | |
efb66345 MS |
24 | } |
25 | ||
26 | proc return_1 { type } { | |
27 | global gdb_prompt | |
28 | ||
29 | gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \ | |
30 | "set break on ${type}_func" | |
31 | gdb_test "continue" "Breakpoint.* ${type}_func.*" \ | |
32 | "continue to ${type}_func" | |
02746bbc MS |
33 | |
34 | gdb_test_multiple "return testval.${type}_testval" \ | |
35 | "return from ${type}_func" { | |
36 | -re "Make ${type}_func return now.*y or n. $" { | |
37 | send_gdb "y\n" | |
38 | exp_continue | |
39 | } | |
40 | -re ".*${type}_resultval *= ${type}_func.*$gdb_prompt $" { | |
41 | send_gdb "step\n" | |
42 | exp_continue | |
43 | } | |
44 | -re ".*${type}_checkpoint.*$gdb_prompt $" { | |
45 | pass "return from ${type}_func" | |
46 | } | |
efb66345 | 47 | } |
efb66345 MS |
48 | gdb_test "print ${type}_resultval == testval.${type}_testval" ".* = 1" \ |
49 | "${type} value returned successfully" | |
50 | gdb_test "print ${type}_resultval != ${type}_returnval" ".* = 1" \ | |
51 | "validate result value not equal to program return value" | |
52 | } | |
53 | ||
54 | proc return_void { } { | |
55 | global gdb_prompt | |
56 | ||
57 | gdb_test "break void_func" "Breakpoint \[0123456789\].*" \ | |
58 | "set break on void_func" | |
59 | gdb_test "continue" "Breakpoint.* void_func.*" \ | |
60 | "continue to void_func" | |
02746bbc MS |
61 | |
62 | gdb_test_multiple "return" "return from void_func" { | |
efb66345 MS |
63 | -re "Make void_func return now.*y or n. $" { |
64 | send_gdb "y\n" | |
65 | exp_continue | |
66 | } | |
67 | -re ".*void_func.*call to void_func.*$gdb_prompt $" { | |
68 | send_gdb "step\n" | |
69 | exp_continue | |
70 | } | |
71 | -re ".*void_checkpoint.*$gdb_prompt $" { | |
72 | pass "return from void_func" | |
73 | } | |
efb66345 MS |
74 | } |
75 | gdb_test "print void_test == 0" ".* = 1" \ | |
76 | "void function returned successfully" | |
77 | } | |
78 | ||
79 | proc return2_tests { } { | |
80 | global gdb_prompt | |
81 | ||
3ad13771 | 82 | if { ! [ runto_main ] } then { |
b60f0898 JB |
83 | untested return2.exp |
84 | return -1 | |
efb66345 MS |
85 | } |
86 | ||
87 | return_void | |
88 | return_1 "char" | |
89 | return_1 "short" | |
90 | return_1 "int" | |
91 | return_1 "long" | |
686d097c | 92 | if { ! [istarget "m6811-*-*"] && ![istarget "h8300*-*"] } then { |
d6f5fea1 SC |
93 | return_1 "long_long" |
94 | } | |
d426f7b4 MS |
95 | if ![target_info exists gdb,skip_float_tests] { |
96 | return_1 "float" | |
97 | if { ! [istarget "m6811-*-*"] } then { | |
98 | return_1 "double" | |
99 | } | |
d6f5fea1 | 100 | } |
efb66345 MS |
101 | } |
102 | ||
103 | # Start with a fresh gdb. | |
104 | ||
822bd149 | 105 | clean_restart ${binfile} |
efb66345 MS |
106 | |
107 | set timeout 30 | |
108 | return2_tests |