This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 7/7] New test case gdb.base/branch-to-self.exp
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 23 Mar 2016 16:09:44 +0000
- Subject: [PATCH 7/7] New test case gdb.base/branch-to-self.exp
- Authentication-results: sourceware.org; auth=none
- References: <1458749384-19793-1-git-send-email-yao dot qi at linaro dot org>
gdb/testsuite:
2016-03-23 Yao Qi <yao.qi@linaro.org>
* gdb.base/branch-to-self.c: New file.
* gdb.base/branch-to-self.exp: New file.
---
gdb/testsuite/gdb.base/branch-to-self.c | 44 ++++++++++++++++++++
gdb/testsuite/gdb.base/branch-to-self.exp | 67 +++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+)
create mode 100644 gdb/testsuite/gdb.base/branch-to-self.c
create mode 100644 gdb/testsuite/gdb.base/branch-to-self.exp
diff --git a/gdb/testsuite/gdb.base/branch-to-self.c b/gdb/testsuite/gdb.base/branch-to-self.c
new file mode 100644
index 0000000..c2ec564
--- /dev/null
+++ b/gdb/testsuite/gdb.base/branch-to-self.c
@@ -0,0 +1,44 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2016 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/>. */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#if defined(__arm__) || defined(__aarch64__)
+#define BRANCH_INSN "b"
+#elif defined(__x86_64__) || defined(__i386__)
+#define BRANCH_INSN "jmp"
+#else
+#endif
+
+volatile int counter = 0;
+
+static void
+handler (int sig)
+{
+ counter = 5;
+}
+
+int
+main (void)
+{
+ signal (SIGALRM, handler);
+ alarm (5);
+
+ asm (".Lhere: " BRANCH_INSN " .Lhere"); /* loop-line */
+}
diff --git a/gdb/testsuite/gdb.base/branch-to-self.exp b/gdb/testsuite/gdb.base/branch-to-self.exp
new file mode 100644
index 0000000..c4b5458
--- /dev/null
+++ b/gdb/testsuite/gdb.base/branch-to-self.exp
@@ -0,0 +1,67 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2016 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/>.
+
+standard_testfile
+
+if { [build_executable ${testfile}.exp ${testfile} $srcfile {debug}] == -1 } {
+ return -1
+}
+
+with_test_prefix "single-step" {
+ global testfile
+
+ clean_restart ${testfile}
+ if ![runto_main] {
+ return -1
+ }
+ set line_num [gdb_get_line_number "loop-line" ${testfile}.c]
+
+ gdb_test "break ${testfile}.c:${line_num}"
+ gdb_continue_to_breakpoint "hit breakpoint"
+ gdb_test "si" ".*${testfile}.c:${line_num}.*"
+}
+
+with_test_prefix "break-cond" {
+ global testfile
+
+ foreach_with_prefix side {"host" "target"} {
+
+ clean_restart ${testfile}
+
+ if ![runto_main] {
+ return -1
+ }
+
+ set test "set breakpoint condition-evaluation $side"
+ gdb_test_multiple $test $test {
+ -re "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead.\r\n$gdb_prompt $" {
+ # Target doesn't support breakpoint condition
+ # evaluation on its side. Skip the test.
+ continue
+ }
+ -re "^$test\r\n$gdb_prompt $" {
+ }
+ }
+
+ set line_num [gdb_get_line_number "loop-line" ${testfile}.c]
+ gdb_test "break ${testfile}.c:${line_num} if counter > 3"
+
+ gdb_continue_to_breakpoint "continue to break"
+
+ gdb_test "p counter" ".* = 5"
+ }
+}
--
1.9.1