1 # Copyright 2000, 2001, 2004 Free Software Foundation, Inc.
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Michael Snyder (msnyder@redhat.com)
29 set testfile "return2"
30 set srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
37 proc return_1 { type } {
40 gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \
41 "set break on ${type}_func"
42 gdb_test "continue" "Breakpoint.* ${type}_func.*" \
43 "continue to ${type}_func"
44 send_gdb "return testval.${type}_testval\n"
46 -re "Make ${type}_func return now.*y or n. $" {
50 -re ".*${type}_resultval *= ${type}_func.*$gdb_prompt $" {
54 -re ".*${type}_checkpoint.*$gdb_prompt $" {
55 pass "return from ${type}_func"
57 -re ".*$gdb_prompt $" {
58 fail "return from ${type}_func"
61 fail "return from ${type}_func (timeout)"
64 gdb_test "print ${type}_resultval == testval.${type}_testval" ".* = 1" \
65 "${type} value returned successfully"
66 gdb_test "print ${type}_resultval != ${type}_returnval" ".* = 1" \
67 "validate result value not equal to program return value"
70 proc return_void { } {
73 gdb_test "break void_func" "Breakpoint \[0123456789\].*" \
74 "set break on void_func"
75 gdb_test "continue" "Breakpoint.* void_func.*" \
76 "continue to void_func"
79 -re "Make void_func return now.*y or n. $" {
83 -re ".*void_func.*call to void_func.*$gdb_prompt $" {
87 -re ".*void_checkpoint.*$gdb_prompt $" {
88 pass "return from void_func"
90 -re ".*$gdb_prompt $" {
91 fail "return from void_func"
94 fail "return from void_func (timeout)"
97 gdb_test "print void_test == 0" ".* = 1" \
98 "void function returned successfully"
101 proc return2_tests { } {
104 if { ! [ runto_main ] } then {
114 if { ! [istarget "m6811-*-*"] && ![istarget "h8300*-*"] } then {
118 if { ! [istarget "m6811-*-*"] } then {
123 # Start with a fresh gdb.
127 gdb_reinitialize_dir $srcdir/$subdir