2010-01-01 07:32:07 +00:00
|
|
|
# Copyright 2000, 2001, 2004, 2007, 2008, 2009, 2010
|
|
|
|
# Free Software Foundation, Inc.
|
2000-12-08 19:30:32 +00:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-08-23 18:14:19 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2000-12-08 19:30:32 +00:00
|
|
|
# (at your option) any later version.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2000-12-08 19:30:32 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2000-12-08 19:30:32 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 18:14:19 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2000-12-08 19:30:32 +00:00
|
|
|
|
|
|
|
# This file was written by Michael Snyder (msnyder@redhat.com)
|
|
|
|
|
|
|
|
if $tracelevel then {
|
|
|
|
strace $tracelevel
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set testfile "return2"
|
|
|
|
set srcfile ${testfile}.c
|
|
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
2006-08-10 05:27:22 +00:00
|
|
|
untested return2.exp
|
|
|
|
return -1
|
2000-12-08 19:30:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
proc return_1 { type } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \
|
|
|
|
"set break on ${type}_func"
|
|
|
|
gdb_test "continue" "Breakpoint.* ${type}_func.*" \
|
|
|
|
"continue to ${type}_func"
|
2010-05-27 23:44:51 +00:00
|
|
|
|
|
|
|
gdb_test_multiple "return testval.${type}_testval" \
|
|
|
|
"return from ${type}_func" {
|
|
|
|
-re "Make ${type}_func return now.*y or n. $" {
|
|
|
|
send_gdb "y\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
|
|
|
-re ".*${type}_resultval *= ${type}_func.*$gdb_prompt $" {
|
|
|
|
send_gdb "step\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
|
|
|
-re ".*${type}_checkpoint.*$gdb_prompt $" {
|
|
|
|
pass "return from ${type}_func"
|
|
|
|
}
|
2000-12-08 19:30:32 +00:00
|
|
|
}
|
|
|
|
gdb_test "print ${type}_resultval == testval.${type}_testval" ".* = 1" \
|
|
|
|
"${type} value returned successfully"
|
|
|
|
gdb_test "print ${type}_resultval != ${type}_returnval" ".* = 1" \
|
|
|
|
"validate result value not equal to program return value"
|
|
|
|
}
|
|
|
|
|
|
|
|
proc return_void { } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
gdb_test "break void_func" "Breakpoint \[0123456789\].*" \
|
|
|
|
"set break on void_func"
|
|
|
|
gdb_test "continue" "Breakpoint.* void_func.*" \
|
|
|
|
"continue to void_func"
|
2010-05-27 23:44:51 +00:00
|
|
|
|
|
|
|
gdb_test_multiple "return" "return from void_func" {
|
2000-12-08 19:30:32 +00:00
|
|
|
-re "Make void_func return now.*y or n. $" {
|
|
|
|
send_gdb "y\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
|
|
|
-re ".*void_func.*call to void_func.*$gdb_prompt $" {
|
|
|
|
send_gdb "step\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
|
|
|
-re ".*void_checkpoint.*$gdb_prompt $" {
|
|
|
|
pass "return from void_func"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gdb_test "print void_test == 0" ".* = 1" \
|
|
|
|
"void function returned successfully"
|
|
|
|
}
|
|
|
|
|
|
|
|
proc return2_tests { } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
2004-02-02 05:15:27 +00:00
|
|
|
if { ! [ runto_main ] } then {
|
2006-08-10 05:27:22 +00:00
|
|
|
untested return2.exp
|
|
|
|
return -1
|
2000-12-08 19:30:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return_void
|
|
|
|
return_1 "char"
|
|
|
|
return_1 "short"
|
|
|
|
return_1 "int"
|
|
|
|
return_1 "long"
|
2003-07-23 18:53:34 +00:00
|
|
|
if { ! [istarget "m6811-*-*"] && ![istarget "h8300*-*"] } then {
|
2001-07-16 18:49:43 +00:00
|
|
|
return_1 "long_long"
|
|
|
|
}
|
2000-12-08 19:30:32 +00:00
|
|
|
return_1 "float"
|
2001-07-16 18:49:43 +00:00
|
|
|
if { ! [istarget "m6811-*-*"] } then {
|
|
|
|
return_1 "double"
|
|
|
|
}
|
2000-12-08 19:30:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Start with a fresh gdb.
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
gdb_start
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
gdb_load ${binfile}
|
|
|
|
|
|
|
|
set timeout 30
|
|
|
|
return2_tests
|