aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@vmware.com>2000-12-08 19:30:32 +0000
committerMichael Snyder <msnyder@vmware.com>2000-12-08 19:30:32 +0000
commitefb663452cd2fe274e04bb1e2553d00288f5537b (patch)
treef6337707848b86602023fdfbb7c6a92bd6b87fbe /gdb/testsuite/gdb.base
parent435b1e90b1015d1457ac8d7a4efcce1c505b4fe8 (diff)
downloadgdb-efb663452cd2fe274e04bb1e2553d00288f5537b.zip
gdb-efb663452cd2fe274e04bb1e2553d00288f5537b.tar.gz
gdb-efb663452cd2fe274e04bb1e2553d00288f5537b.tar.bz2
2000-12-07 Michael Snyder <msnyder@cleaver.cygnus.com>
* gdb.base/finish.exp: New test for gdb's "finish" command. * gdb.base/return2.exp: New test for gdb's "return" command. * gdb.base/return2.c: New source file for above.
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/finish.exp111
-rw-r--r--gdb/testsuite/gdb.base/return2.c91
-rw-r--r--gdb/testsuite/gdb.base/return2.exp125
3 files changed, 327 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/finish.exp b/gdb/testsuite/gdb.base/finish.exp
new file mode 100644
index 0000000..c329fc4
--- /dev/null
+++ b/gdb/testsuite/gdb.base/finish.exp
@@ -0,0 +1,111 @@
+# Copyright (C) 2000 Free Software Foundation, Inc.
+
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@redhat.com)
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+# re-use the program from the "return2" test.
+set testfile "return2"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+proc finish_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"
+ send_gdb "finish\n"
+ gdb_expect {
+ -re ".*Value returned is .* = 1 '.001'\r\n$gdb_prompt $" {
+ if { $type == "char" } {
+ pass "finish from char_func"
+ } else {
+ fail "finish from char_func"
+ }
+ }
+ -re ".*Value returned is .* = 1\r\n$gdb_prompt $" {
+ pass "finish from ${type}_func"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "finish from ${type}_func"
+ }
+ timeout {
+ fail "finish from ${type}_func (timeout)"
+ }
+ }
+}
+
+proc finish_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"
+ send_gdb "finish\n"
+ gdb_expect {
+ -re ".*void_checkpoint.*$gdb_prompt $" {
+ pass "finish from void_func"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "finish from void_func"
+ }
+ timeout {
+ fail "finish from void_func (timeout)"
+ }
+ }
+}
+
+proc finish_tests { } {
+ global gdb_prompt
+
+ if { ! [ runto main ] } then {
+ gdb_suppress_entire_file "Run to main failed, so all tests in this file will automatically fail."
+ }
+
+ finish_void
+ finish_1 "char"
+ finish_1 "short"
+ finish_1 "int"
+ finish_1 "long"
+ finish_1 "long_long"
+ finish_1 "float"
+ finish_1 "double"
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+set timeout 30
+finish_tests
diff --git a/gdb/testsuite/gdb.base/return2.c b/gdb/testsuite/gdb.base/return2.c
new file mode 100644
index 0000000..cddbb97
--- /dev/null
+++ b/gdb/testsuite/gdb.base/return2.c
@@ -0,0 +1,91 @@
+/* Test gdb's "return" command. */
+
+int void_test = 0;
+int main_test = 0;
+
+char char_returnval = '1';
+short short_returnval = 1;
+int int_returnval = 1;
+long long_returnval = 1;
+long long long_long_returnval = 1;
+float float_returnval = 1;
+double double_returnval = 1;
+
+union {
+ char char_testval;
+ short short_testval;
+ int int_testval;
+ long long_testval;
+ long long long_long_testval;
+ float float_testval;
+ double double_testval;
+ char ffff[80];
+} testval;
+
+void void_func ()
+{
+ void_test = 1;
+}
+
+char char_func ()
+{
+ return char_returnval;
+}
+
+short short_func ()
+{
+ return short_returnval;
+}
+
+int int_func ()
+{
+ return int_returnval;
+}
+
+long long_func ()
+{
+ return long_returnval;
+}
+
+long long long_long_func ()
+{
+ return long_long_returnval;
+}
+
+float float_func ()
+{
+ return float_returnval;
+}
+
+double double_func ()
+{
+ return double_returnval;
+}
+
+int main (int argc, char **argv)
+{
+ char char_resultval;
+ short short_resultval;
+ int int_resultval;
+ long long_resultval;
+ long long long_long_resultval;
+ float float_resultval;
+ double double_resultval;
+ int i;
+
+ /* A "test load" that will insure that the function really returns
+ a ${type} (as opposed to just a truncated or part of a ${type}). */
+ for (i = 0; i < sizeof (testval.ffff); i++)
+ testval.ffff[i] = 0xff;
+
+ void_func (); /* call to void_func */
+ char_resultval = char_func (); /* void_checkpoint */
+ short_resultval = short_func (); /* char_checkpoint */
+ int_resultval = int_func (); /* short_checkpoint */
+ long_resultval = long_func (); /* int_checkpoint */
+ long_long_resultval = long_long_func (); /* long_checkpoint */
+ float_resultval = float_func (); /* long_long_checkpoint */
+ double_resultval = double_func (); /* float_checkpoint */
+ main_test = 1; /* double_checkpoint */
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/return2.exp b/gdb/testsuite/gdb.base/return2.exp
new file mode 100644
index 0000000..6298ccb
--- /dev/null
+++ b/gdb/testsuite/gdb.base/return2.exp
@@ -0,0 +1,125 @@
+# Copyright (C) 2000 Free Software Foundation, Inc.
+
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@redhat.com)
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+set testfile "return2"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+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"
+ send_gdb "return testval.${type}_testval\n"
+ gdb_expect {
+ -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"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "return from ${type}_func"
+ }
+ timeout {
+ fail "return from ${type}_func (timeout)"
+ }
+ }
+ 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"
+ send_gdb "return \n"
+ gdb_expect {
+ -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"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "return from void_func"
+ }
+ timeout {
+ fail "return from void_func (timeout)"
+ }
+ }
+ gdb_test "print void_test == 0" ".* = 1" \
+ "void function returned successfully"
+}
+
+proc return2_tests { } {
+ global gdb_prompt
+
+ if { ! [ runto main ] } then {
+ gdb_suppress_entire_file "Run to main failed, so all tests in this file will automatically fail."
+ }
+
+ return_void
+ return_1 "char"
+ return_1 "short"
+ return_1 "int"
+ return_1 "long"
+ return_1 "long_long"
+ return_1 "float"
+ return_1 "double"
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+set timeout 30
+return2_tests