summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@specifix.com>2008-09-02 01:36:19 +0000
committerMichael Snyder <msnyder@specifix.com>2008-09-02 01:36:19 +0000
commitb06160b03ce98807391e1115b5a979edd1ecf14d (patch)
treef939ba756f631655f82a6608a6c3fe858314a698
parentf231ea7fcd9fcccc2d41995bedee3dcfc316d1e9 (diff)
downloadgdb-b06160b03ce98807391e1115b5a979edd1ecf14d.tar.gz
2008-09-01 Michael Snyder <msnyder@vmware.com>
* gdb.twreverse/step-reverse.exp: New file. * gdb.twreverse/step-reverse.c: New file.
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.twreverse/step-reverse.c61
-rw-r--r--gdb/testsuite/gdb.twreverse/step-reverse.exp68
3 files changed, 134 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 206920b96ef..30e6b713842 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2008-09-01 Michael Snyder <msnyder@vmware.com>
+ * gdb.twreverse/step-reverse.exp: New file.
+ * gdb.twreverse/step-reverse.c: New file.
+
+2008-09-01 Michael Snyder <msnyder@vmware.com>
+
* gdb.twreverse: New directory (may be renamed later).
* gdb.twreverse/Makefile.in: New file.
* gdb.twreverse/break-reverse.exp: New file.
diff --git a/gdb/testsuite/gdb.twreverse/step-reverse.c b/gdb/testsuite/gdb.twreverse/step-reverse.c
new file mode 100644
index 00000000000..056df7f1d38
--- /dev/null
+++ b/gdb/testsuite/gdb.twreverse/step-reverse.c
@@ -0,0 +1,61 @@
+#include <stdlib.h>
+#include <string.h>
+
+/* Test various kinds of stepping.
+*/
+int myglob = 0;
+
+int callee() {
+ myglob++; return 0;
+}
+
+/* A structure which, we hope, will need to be passed using memcpy. */
+struct rhomboidal {
+ int rather_large[100];
+};
+
+void
+large_struct_by_value (struct rhomboidal r)
+{
+ myglob += r.rather_large[42]; /* step-test.exp: arrive here 1 */
+}
+
+int main () {
+ int w,x,y,z;
+ int a[10], b[10];
+
+ /* Test "next" and "step" */
+ w = 0; /* BREAK AT MAIN */
+ x = 1; /* NEXT TEST 1 */
+ y = 2; /* STEP TEST 1 */
+ z = 3; /* REVERSE NEXT TEST 1 */
+ w = w + 2; /* NEXT TEST 2 */
+ x = x + 3; /* REVERSE STEP TEST 1 */
+ y = y + 4;
+ z = z + 5; /* STEP TEST 2 */
+
+ /* Test that "next" goes over a call */
+ callee(); /* OVER */
+
+ /* Test that "step" doesn't */
+ callee(); /* INTO */
+
+ /* Test "stepi" */
+ a[5] = a[3] - a[4];
+ callee(); /* STEPI */
+
+ /* Test "nexti" */
+ callee(); /* NEXTI */
+
+ y = w + z;
+
+ {
+ struct rhomboidal r;
+ memset (r.rather_large, 0, sizeof (r.rather_large));
+ r.rather_large[42] = 10;
+ large_struct_by_value (r); /* step-test.exp: large struct by value */
+ }
+
+ exit (0);
+}
+
diff --git a/gdb/testsuite/gdb.twreverse/step-reverse.exp b/gdb/testsuite/gdb.twreverse/step-reverse.exp
new file mode 100644
index 00000000000..e76c7c251a1
--- /dev/null
+++ b/gdb/testsuite/gdb.twreverse/step-reverse.exp
@@ -0,0 +1,68 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 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/>. */
+# step-reverse.exp -- Expect script to test reverse stepping in gdb.
+# Lots of code borrowed from "step-test.exp".
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+if { [prepare_for_testing step-reverse.exp step-reverse step-reverse.c] } {
+ return -1
+}
+
+runto main
+
+# Activate record/replay
+# FIXME: command needs to acknowledge, so we can test if it succeeded.
+
+gdb_test "record" "" "Turn on recording"
+
+# plain vanilla step/next (no count)
+
+gdb_test "next" ".*NEXT TEST 1.*" "next test 1"
+gdb_test "step" ".*STEP TEST 1.*" "step test 1"
+
+# step/next with count
+
+gdb_test "next 2" ".*NEXT TEST 2.*" "next test 2"
+gdb_test "step 3" ".*STEP TEST 2.*" "step test 2"
+
+# 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"
+
+# step/next backward with count
+
+gdb_test "step 2" ".*REVERSE STEP TEST 1.*" "reverse step test 1"
+gdb_test "next 2" ".*REVERSE NEXT TEST 1.*" "reverse next test 1"
+
+# step/next backward without count
+
+gdb_test "step" ".*STEP TEST 1.*" "reverse step test 2"
+gdb_test "next" ".*NEXT TEST 1.*" "reverse next step 2"
+
+
+
+# Finish test by running forward to the end.
+# FIXME return to this later...
+# gdb_test "set exec-dir forward" "" "set forward execution"
+# gdb_continue_to_end "step-reverse.exp"
+
+return 0
+