summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@specifix.com>2008-09-11 01:20:31 +0000
committerMichael Snyder <msnyder@specifix.com>2008-09-11 01:20:31 +0000
commit194392a89ee4979356b2be77e3f937fa5b8c9f76 (patch)
treeafbed986139cc79d9d73a3234a8c6cb249fd72c7
parent89396f0a8fba4879a379b61b550a1d02d7b9dbed (diff)
downloadgdb-194392a89ee4979356b2be77e3f937fa5b8c9f76.tar.gz
2008-09-10 Michael Snyder <msnyder@vmware.com>
* gdb.twreverse/until-reverse.exp: New file. * gdb.twreverse/until-reverse.c: New file. * gdb.twreverse/until-reverse1.c: New file.
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.twreverse/until-reverse.c149
-rw-r--r--gdb/testsuite/gdb.twreverse/until-reverse.exp147
-rw-r--r--gdb/testsuite/gdb.twreverse/until-reverse1.c52
-rw-r--r--gdb/testsuite/gdb.twreverse/watch-reverse.exp2
5 files changed, 355 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 13dcd99ae2b..d9edf7f4654 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2008-09-10 Michael Snyder <msnyder@vmware.com>
+
+ * gdb.twreverse/until-reverse.exp: New file.
+ * gdb.twreverse/until-reverse.c: New file.
+ * gdb.twreverse/until-reverse1.c: New file.
+
2008-09-09 Michael Snyder <msnyder@vmware.com>
* gdb.twreverse/return2-reverse.c: Rename to:
diff --git a/gdb/testsuite/gdb.twreverse/until-reverse.c b/gdb/testsuite/gdb.twreverse/until-reverse.c
new file mode 100644
index 00000000000..f8546747ec1
--- /dev/null
+++ b/gdb/testsuite/gdb.twreverse/until-reverse.c
@@ -0,0 +1,149 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003, 2007, 2008
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+
+ Please email any bugs, comments, and/or additions to this file to:
+ bug-gdb@prep.ai.mit.edu */
+
+#ifdef vxworks
+
+# include <stdio.h>
+
+/* VxWorks does not supply atoi. */
+static int
+atoi (z)
+ char *z;
+{
+ int i = 0;
+
+ while (*z >= '0' && *z <= '9')
+ i = i * 10 + (*z++ - '0');
+ return i;
+}
+
+/* I don't know of any way to pass an array to VxWorks. This function
+ can be called directly from gdb. */
+
+vxmain (arg)
+char *arg;
+{
+ char *argv[2];
+
+ argv[0] = "";
+ argv[1] = arg;
+ main (2, argv, (char **) 0);
+}
+
+#else /* ! vxworks */
+# include <stdio.h>
+# include <stdlib.h>
+#endif /* ! vxworks */
+
+#ifdef PROTOTYPES
+extern int marker1 (void);
+extern int marker2 (int a);
+extern void marker3 (char *a, char *b);
+extern void marker4 (long d);
+#else
+extern int marker1 ();
+extern int marker2 ();
+extern void marker3 ();
+extern void marker4 ();
+#endif
+
+/*
+ * This simple classical example of recursion is useful for
+ * testing stack backtraces and such.
+ */
+
+#ifdef PROTOTYPES
+int factorial(int);
+
+int
+main (int argc, char **argv, char **envp)
+#else
+int
+main (argc, argv, envp)
+int argc;
+char *argv[], **envp;
+#endif
+{
+#ifdef usestubs
+ set_debug_traps(); /* set breakpoint 5 here */
+ breakpoint();
+#endif
+ if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */
+ fprintf (stderr, "usage: factorial <number>\n");
+ return 1;
+ }
+ printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */
+ /* set breakpoint 12 here */
+ marker1 (); /* set breakpoint 11 here */
+ marker2 (43); /* set breakpoint 20 here */
+ marker3 ("stack", "trace"); /* set breakpoint 21 here */
+ marker4 (177601976L);
+ /* We're used by a test that requires malloc, so make sure it is
+ in the executable. */
+ (void)malloc (1);
+
+ argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */
+ return argc; /* set breakpoint 10 here */
+} /* set breakpoint 10a here */
+
+#ifdef PROTOTYPES
+int factorial (int value)
+#else
+int factorial (value)
+int value;
+#endif
+{
+ if (value > 1) { /* set breakpoint 7 here */
+ value *= factorial (value - 1);
+ }
+ return (value); /* set breakpoint 19 here */
+}
+
+#ifdef PROTOTYPES
+int multi_line_if_conditional (int a, int b, int c)
+#else
+int multi_line_if_conditional (a, b, c)
+ int a, b, c;
+#endif
+{
+ if (a /* set breakpoint 3 here */
+ && b
+ && c)
+ return 0;
+ else
+ return 1;
+}
+
+#ifdef PROTOTYPES
+int multi_line_while_conditional (int a, int b, int c)
+#else
+int multi_line_while_conditional (a, b, c)
+ int a, b, c;
+#endif
+{
+ while (a /* set breakpoint 4 here */
+ && b
+ && c)
+ {
+ a--, b--, c--;
+ }
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.twreverse/until-reverse.exp b/gdb/testsuite/gdb.twreverse/until-reverse.exp
new file mode 100644
index 00000000000..0faf0ac9c67
--- /dev/null
+++ b/gdb/testsuite/gdb.twreverse/until-reverse.exp
@@ -0,0 +1,147 @@
+# Copyright 2003, 2007, 2008 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 3 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, see <http://www.gnu.org/licenses/>. */
+
+# 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
+
+set testfile "until-reverse"
+set srcfile ${testfile}.c
+set srcfile1 ${testfile}1.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
+ untested until-reverse.exp
+ return -1
+}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
+ untested until-reverse.exp
+ return -1
+}
+
+if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
+ untested until-reverse.exp
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
+set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
+set bp_location9 [gdb_get_line_number "set breakpoint 9 here" "$srcfile1"]
+set bp_location19 [gdb_get_line_number "set breakpoint 19 here"]
+set bp_location20 [gdb_get_line_number "set breakpoint 20 here"]
+set bp_location21 [gdb_get_line_number "set breakpoint 21 here"]
+
+if ![runto_main] then {
+ fail "Can't run to main"
+ untested "until-reverse.exp"
+ return 0
+}
+
+# Activate record/replay
+# FIXME: command needs to acknowledge, so we can test if it succeeded.
+
+gdb_test "record" "" "Turn on recording"
+
+# Verify that plain vanilla2 "until <location>" works.
+#
+gdb_test "until $bp_location1" \
+ "main .* at .*:$bp_location1.*" \
+ "until line number"
+
+# Advance up to factorial, outer invocation
+#
+gdb_test "advance factorial" \
+ "factorial .value=6..*$srcfile:$bp_location7.*" \
+ "advance to factorial"
+
+# 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 $bp_location19" \
+ "factorial .value=720.*${srcfile}:$bp_location19.*" \
+ "until factorial, recursive function"
+
+# Finish out to main scope
+#
+gdb_test "finish" \
+ " in main .*$srcfile:$bp_location1.*" \
+ "finish to main"
+
+# Advance to a function called by main (marker2)
+#
+gdb_test "advance marker2" \
+ "marker2 .a=43.*$srcfile1:$bp_location9.*" \
+ "advance to marker2"
+
+# 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.
+#
+set test_msg "until func, not called by current frame"
+gdb_test_multiple "until marker3" "$test_msg" {
+ -re "main .*at .*${srcfile}:$bp_location20.*$gdb_prompt $" {
+ pass "$test_msg"
+ }
+ -re "main .*at .*${srcfile}:$bp_location21.*$gdb_prompt $" {
+ pass "$test_msg"
+ }
+}
+
+###
+###
+###
+
+# Set reverse execution direction
+# FIXME: command needs to acknowledge, so we can test if it succeeded.
+
+gdb_test "set exec-dir reverse" "" "set reverse execution"
+
+#
+# We should now be at main, after the return from marker2.
+# "Advance" backward into marker2.
+#
+
+gdb_test "advance marker2" \
+ "marker2 .a=43.*$srcfile1:$bp_location9.*" \
+ "reverse-advance to marker2"
+
+# Finish out to main scope (backward)
+
+gdb_test "finish" \
+ " in main .*$srcfile:$bp_location20.*" \
+ "reverse-finish from marker2"
+
+# Advance backward to last line of factorial (outer invocation)
+
+gdb_test "advance $bp_location19" \
+ "factorial .value=720.*${srcfile}:$bp_location19.*" \
+ "reverse-advance to final return of factorial"
+
+# Now do "until" across the recursive calls,
+# ending up in the same frame where we are now.
+
+gdb_test "until $bp_location7" \
+ "factorial .value=6..*$srcfile:$bp_location7.*" \
+ "reverse-until to entry of factorial"
+
+
diff --git a/gdb/testsuite/gdb.twreverse/until-reverse1.c b/gdb/testsuite/gdb.twreverse/until-reverse1.c
new file mode 100644
index 00000000000..9cbcd3036e8
--- /dev/null
+++ b/gdb/testsuite/gdb.twreverse/until-reverse1.c
@@ -0,0 +1,52 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003, 2007, 2008
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+
+ Please email any bugs, comments, and/or additions to this file to:
+ bug-gdb@prep.ai.mit.edu */
+
+/* The code for this file was extracted from the gdb testsuite
+ testcase "break.c". */
+
+/* The following functions do nothing useful. They are included
+ simply as places to try setting breakpoints at. They are
+ explicitly "one-line functions" to verify that this case works
+ (some versions of gcc have or have had problems with this).
+
+ These functions are in a separate source file to prevent an
+ optimizing compiler from inlining them and optimizing them away. */
+
+#ifdef PROTOTYPES
+int marker1 (void) { return (0); } /* set breakpoint 15 here */
+int marker2 (int a) { return (1); } /* set breakpoint 8 here */
+void marker3 (char *a, char *b) {} /* set breakpoint 17 here */
+void marker4 (long d) {} /* set breakpoint 14 here */
+#else
+int marker1 () { return (0); } /* set breakpoint 16 here */
+int marker2 (a) int a; { return (1); } /* set breakpoint 9 here */
+void marker3 (a, b) char *a, *b; {} /* set breakpoint 18 here */
+void marker4 (d) long d; {} /* set breakpoint 13 here */
+#endif
+
+/* A structure we use for field name completion tests. */
+struct some_struct
+{
+ int a_field;
+ int b_field;
+};
+
+struct some_struct values[50];
diff --git a/gdb/testsuite/gdb.twreverse/watch-reverse.exp b/gdb/testsuite/gdb.twreverse/watch-reverse.exp
index 0711db75dcd..25843e068ff 100644
--- a/gdb/testsuite/gdb.twreverse/watch-reverse.exp
+++ b/gdb/testsuite/gdb.twreverse/watch-reverse.exp
@@ -51,7 +51,7 @@ gdb_continue_to_breakpoint "marker1" ".*/$srcfile:.*"
gdb_test "watch ival3" \
".*\[Ww\]atchpoint $decimal: ival3.*" \
- "set watchpoknt on ival3"
+ "set watchpoint on ival3"
# Continue until first change, from -1 to 0