1 # Copyright 2000, 2001, 2004, 2007 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 3 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, see <http://www.gnu.org/licenses/>.
16 # Please email any bugs, comments, and/or additions to this file to:
17 # bug-gdb@prep.ai.mit.edu
19 # This file was written by Michael Snyder (msnyder@redhat.com)
28 set testfile "return2"
29 set srcfile ${testfile}.c
30 set binfile ${objdir}/${subdir}/${testfile}
31 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
36 proc return_1 { type } {
39 gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \
40 "set break on ${type}_func"
41 gdb_test "continue" "Breakpoint.* ${type}_func.*" \
42 "continue to ${type}_func"
43 send_gdb "return testval.${type}_testval\n"
45 -re "Make ${type}_func return now.*y or n. $" {
49 -re ".*${type}_resultval *= ${type}_func.*$gdb_prompt $" {
53 -re ".*${type}_checkpoint.*$gdb_prompt $" {
54 pass "return from ${type}_func"
56 -re ".*$gdb_prompt $" {
57 fail "return from ${type}_func"
60 fail "return from ${type}_func (timeout)"
63 gdb_test "print ${type}_resultval == testval.${type}_testval" ".* = 1" \
64 "${type} value returned successfully"
65 gdb_test "print ${type}_resultval != ${type}_returnval" ".* = 1" \
66 "validate result value not equal to program return value"
69 proc return_void { } {
72 gdb_test "break void_func" "Breakpoint \[0123456789\].*" \
73 "set break on void_func"
74 gdb_test "continue" "Breakpoint.* void_func.*" \
75 "continue to void_func"
78 -re "Make void_func return now.*y or n. $" {
82 -re ".*void_func.*call to void_func.*$gdb_prompt $" {
86 -re ".*void_checkpoint.*$gdb_prompt $" {
87 pass "return from void_func"
89 -re ".*$gdb_prompt $" {
90 fail "return from void_func"
93 fail "return from void_func (timeout)"
96 gdb_test "print void_test == 0" ".* = 1" \
97 "void function returned successfully"
100 proc return2_tests { } {
103 if { ! [ runto_main ] } then {
113 if { ! [istarget "m6811-*-*"] && ![istarget "h8300*-*"] } then {
117 if { ! [istarget "m6811-*-*"] } then {
122 # Start with a fresh gdb.
126 gdb_reinitialize_dir $srcdir/$subdir