summaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorElena Zannoni <ezannoni@kwikemart.cygnus.com>2003-01-15 14:25:11 +0000
committerElena Zannoni <ezannoni@kwikemart.cygnus.com>2003-01-15 14:25:11 +0000
commit42ff4f974e32c6561c61d66f55c7005de1305506 (patch)
tree09c338a4ace31e520ed96ee7c627b9602d0bf564 /gdb/testsuite
parent04fe94284bd633e4b0483e46838a1848b64d2b60 (diff)
downloadgdb-42ff4f974e32c6561c61d66f55c7005de1305506.tar.gz
2003-01-15 Elena Zannoni <ezannoni@redhat.com>
* gdb.base/break.exp: Move the tests of until command from here... * gdb.base/until.exp: ... to here. New file. Add other tests. * gdb.base/advance.c: New file. * gdb.base/advance.exp: New file.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.base/advance.c45
-rw-r--r--gdb/testsuite/gdb.base/advance.exp91
-rw-r--r--gdb/testsuite/gdb.base/break.exp27
-rw-r--r--gdb/testsuite/gdb.base/until.exp81
5 files changed, 226 insertions, 25 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 409d9bdc13d..9fd8c3625b8 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2003-01-15 Elena Zannoni <ezannoni@redhat.com>
+
+ * gdb.base/break.exp: Move the tests of until command from here...
+ * gdb.base/until.exp: ... to here. New file. Add other tests.
+ * gdb.base/advance.c: New file.
+ * gdb.base/advance.exp: New file.
+
2003-01-14 Elena Zannoni <ezannoni@redhat.com>
* gdb.base/args.c: New file.
diff --git a/gdb/testsuite/gdb.base/advance.c b/gdb/testsuite/gdb.base/advance.c
new file mode 100644
index 00000000000..2ae3cc50c4a
--- /dev/null
+++ b/gdb/testsuite/gdb.base/advance.c
@@ -0,0 +1,45 @@
+
+static int x;
+
+int foo (int a)
+{
+ int b = a + 10;
+ return b;
+}
+
+int bar (int y)
+{
+ int z = y + 20;
+ return z;
+}
+
+void func()
+{
+ x = x + 5;
+ func2 ();
+}
+
+int func2 ()
+{
+ x = 6;
+}
+
+int func3 ()
+{
+ x = 4;
+}
+
+int
+main ()
+{
+ int result;
+ int b, c;
+ c = 5;
+ b = 3; /* advance this location */
+
+ func (c); /* stop here after leaving current frame */
+ func3 (); /* break here */
+ result = bar (b + foo (c));
+ return 0; /* advance malformed */
+}
+
diff --git a/gdb/testsuite/gdb.base/advance.exp b/gdb/testsuite/gdb.base/advance.exp
new file mode 100644
index 00000000000..ae79d184d71
--- /dev/null
+++ b/gdb/testsuite/gdb.base/advance.exp
@@ -0,0 +1,91 @@
+# Copyright 2003 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
+
+# advance.exp -- Expect script to test 'advance' in gdb
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set testfile advance
+set srcfile ${srcdir}/${subdir}/${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+remote_exec build "rm -f ${binfile}"
+if { [gdb_compile "${srcfile}" "${binfile}" executable {debug}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if ![runto_main] then {
+ fail "Can't run to main"
+ return 0
+}
+
+# Verify that "advance <location>" works. (This is really just syntactic
+# sugar for "tbreak <location>; continue".)
+#
+gdb_test "advance [gdb_get_line_number "advance this location"]" \
+ "main .* at .*:.*b = 3.*advance this location.*" \
+ "advance line number"
+
+# Verify that a malformed "advance" is gracefully caught.
+#
+gdb_test "advance [gdb_get_line_number "advance malformed"] then stop" \
+ "Junk at end of arguments." "malformed advance"
+
+# Verify that "advance <funcname>" works.
+#
+gdb_test "advance func" \
+ "func.*at.*x = x \\+ 5." \
+ "advance func"
+
+# Verify that "advance <funcname>" when funcname is NOT called by the current
+# frame, stops at the end of the current frame.
+#
+gdb_test "advance func3" \
+ "in main.*func \\(c\\).*stop here after leaving current frame..."\
+ "advance function not called by current frame"
+
+# break at main again
+#
+gdb_test "break [gdb_get_line_number "break here"]" \
+ ".*Breakpoint.* at .*" \
+ "set breakpoint at call to func3"
+gdb_test "continue" \
+ ".*Breakpoint ${decimal}, main.*func3.*break here.*" \
+ "continue to call to func3 in main"
+
+# Verify that "advance <funcname>" when funcname is called as parameter to
+# another function works.
+#
+gdb_test "advance foo" \
+ "foo \\(a=5\\).*int b = a \\+ 10;"\
+ "advance function called as param"
+
+# Verify that we get an error if we use 'advance' w/o argument
+#
+gdb_test "advance" \
+ "Argument required \\(a location\\)."\
+ "advance with no argument"
+
diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index e3aa922bc50..6e393e614d6 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -1,5 +1,5 @@
# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2002
+# 2000, 2002, 2003
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
@@ -154,6 +154,7 @@ if {$hp_aCC_compiler} {
} else {
set proto ""
}
+
gdb_test "info break" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.*
@@ -166,7 +167,6 @@ gdb_test "info break" \
\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:124" \
"breakpoint info"
-
# FIXME: The rest of this test doesn't work with anything that can't
# handle arguments.
# Huh? There doesn't *appear* to be anything that passes arguments
@@ -363,29 +363,6 @@ gdb_expect {
timeout {fail "(timeout) $name"}
}
-# Verify that "until <location>" works. (This is really just syntactic
-# sugar for "tbreak <location>; continue".)
-#
-send_gdb "until 79\n"
-gdb_expect {
- -re "main .* at .*:79.*$gdb_prompt $"\
- {pass "until 79"}
- -re "$gdb_prompt $"\
- {fail "until 79"}
- timeout {fail "(timeout) until 79"}
-}
-
-# Verify that a malformed "until" is gracefully caught.
-#
-send_gdb "until 80 then stop\n"
-gdb_expect {
- -re "Junk at end of arguments..*$gdb_prompt $"\
- {pass "malformed until"}
- -re "$gdb_prompt $"\
- {fail "malformed until"}
- timeout {fail "(timeout) malformed until"}
-}
-
# Verify that GDB responds gracefully when asked to set a breakpoint
# on a nonexistent source line.
#
diff --git a/gdb/testsuite/gdb.base/until.exp b/gdb/testsuite/gdb.base/until.exp
new file mode 100644
index 00000000000..b9b8b2d9c10
--- /dev/null
+++ b/gdb/testsuite/gdb.base/until.exp
@@ -0,0 +1,81 @@
+# Copyright 2003 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
+
+# until.exp -- Expect script to test 'until' in gdb
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set testfile break
+set srcfile ${srcdir}/${subdir}/${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+remote_exec build "rm -f ${binfile}"
+if { [gdb_compile "${srcfile}" "${binfile}" executable {debug}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if ![runto_main] then {
+ fail "Can't run to main"
+ return 0
+}
+
+# Verify that "until <location>" works. (This is really just syntactic
+# sugar for "tbreak <location>; continue".)
+#
+gdb_test "until 79" \
+ "main .* at .*:79.*" \
+ "until line number"
+
+# Verify that a malformed "advance" is gracefully caught.
+#
+gdb_test "until 80 then stop" \
+ "Junk at end of arguments." "malformed until"
+
+# Rerun up to factorial, outer invocation
+if { ![runto factorial] } then { gdb_suppress_tests; }
+delete_breakpoints
+
+# At this point, 'until' should continue the inferior up to when all the
+# inner invocations of factorial() are completed and we are back at this
+# frame.
+#
+gdb_test "until 99" \
+ "factorial.*value=720.*at ${srcfile}:99.*return \\(value\\)." \
+ "until factorial, recursive function"
+
+# Run to a function called by main
+#
+if { ![runto marker2] } then { gdb_suppress_tests; }
+delete_breakpoints
+
+# Now issue an until with another function, not called by the current
+# frame, as argument. This should not work, i.e. the program should
+# stop at main, the caller, where we put the 'guard' breakpoint.
+#
+gdb_test "until marker3" \
+ "$hex in main.*argc.*argv.*envp.*at ${srcfile}:82.*marker2 \\(43\\)." \
+ "until func, not called by current frame"
+