Update years in copyright notice for the GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / return2.exp
CommitLineData
28e7fd62 1# Copyright 2000-2013 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
MS
18
19set testfile "return2"
20set srcfile ${testfile}.c
21set binfile ${objdir}/${subdir}/${testfile}
22if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
23 untested return2.exp
24 return -1
efb66345
MS
25}
26
27proc return_1 { type } {
28 global gdb_prompt
29
30 gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \
31 "set break on ${type}_func"
32 gdb_test "continue" "Breakpoint.* ${type}_func.*" \
33 "continue to ${type}_func"
02746bbc
MS
34
35 gdb_test_multiple "return testval.${type}_testval" \
36 "return from ${type}_func" {
37 -re "Make ${type}_func return now.*y or n. $" {
38 send_gdb "y\n"
39 exp_continue
40 }
41 -re ".*${type}_resultval *= ${type}_func.*$gdb_prompt $" {
42 send_gdb "step\n"
43 exp_continue
44 }
45 -re ".*${type}_checkpoint.*$gdb_prompt $" {
46 pass "return from ${type}_func"
47 }
efb66345 48 }
efb66345
MS
49 gdb_test "print ${type}_resultval == testval.${type}_testval" ".* = 1" \
50 "${type} value returned successfully"
51 gdb_test "print ${type}_resultval != ${type}_returnval" ".* = 1" \
52 "validate result value not equal to program return value"
53}
54
55proc return_void { } {
56 global gdb_prompt
57
58 gdb_test "break void_func" "Breakpoint \[0123456789\].*" \
59 "set break on void_func"
60 gdb_test "continue" "Breakpoint.* void_func.*" \
61 "continue to void_func"
02746bbc
MS
62
63 gdb_test_multiple "return" "return from void_func" {
efb66345
MS
64 -re "Make void_func return now.*y or n. $" {
65 send_gdb "y\n"
66 exp_continue
67 }
68 -re ".*void_func.*call to void_func.*$gdb_prompt $" {
69 send_gdb "step\n"
70 exp_continue
71 }
72 -re ".*void_checkpoint.*$gdb_prompt $" {
73 pass "return from void_func"
74 }
efb66345
MS
75 }
76 gdb_test "print void_test == 0" ".* = 1" \
77 "void function returned successfully"
78}
79
80proc return2_tests { } {
81 global gdb_prompt
82
3ad13771 83 if { ! [ runto_main ] } then {
b60f0898
JB
84 untested return2.exp
85 return -1
efb66345
MS
86 }
87
88 return_void
89 return_1 "char"
90 return_1 "short"
91 return_1 "int"
92 return_1 "long"
686d097c 93 if { ! [istarget "m6811-*-*"] && ![istarget "h8300*-*"] } then {
d6f5fea1
SC
94 return_1 "long_long"
95 }
d426f7b4
MS
96 if ![target_info exists gdb,skip_float_tests] {
97 return_1 "float"
98 if { ! [istarget "m6811-*-*"] } then {
99 return_1 "double"
100 }
d6f5fea1 101 }
efb66345
MS
102}
103
104# Start with a fresh gdb.
105
106gdb_exit
107gdb_start
108gdb_reinitialize_dir $srcdir/$subdir
109gdb_load ${binfile}
110
111set timeout 30
112return2_tests
This page took 1.24961 seconds and 4 git commands to generate.