summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-07-29 22:39:03 +0100
committerPedro Alves <palves@redhat.com>2016-07-29 22:39:16 +0100
commit738759602279044115b57a26d91277b778439306 (patch)
treeb38fec6ce84af543015545828ce256c30d7b1f26
parent6af0d0efab35ec382f01a0e0b9bc3bebfd60d78c (diff)
downloadbinutils-gdb-users/palves/PR18077-new-ui-sync-commands.tar.gz
-rw-r--r--gdb/testsuite/gdb.mi/mi-exec-run-sync.c25
-rw-r--r--gdb/testsuite/gdb.mi/mi-exec-run-sync.exp117
2 files changed, 142 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.mi/mi-exec-run-sync.c b/gdb/testsuite/gdb.mi/mi-exec-run-sync.c
new file mode 100644
index 00000000000..a0d9f92e506
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-exec-run-sync.c
@@ -0,0 +1,25 @@
+/* Copyright 2016 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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>
+
+int
+main (void)
+{
+ sleep (180);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.mi/mi-exec-run-sync.exp b/gdb/testsuite/gdb.mi/mi-exec-run-sync.exp
new file mode 100644
index 00000000000..1608624e350
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-exec-run-sync.exp
@@ -0,0 +1,117 @@
+# 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/>.
+
+# Test that after executing synchronous commands on an separate MI
+# channel, MI doesn't process further commands until the inferior
+# stops again. See PR gdb/20418.
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi"
+
+standard_testfile
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ untested "could not build mi-exec-run-sync"
+ return -1
+}
+
+# The test driver.
+
+proc test {} {
+ global srcdir subdir binfile srcfile
+ global gdb_spawn_id gdb_main_spawn_id mi_spawn_id inferior_spawn_id
+ global decimal
+ global gdb_prompt mi_gdb_prompt
+
+ mi_gdb_exit
+
+ if [eval mi_gdb_start "separate-mi-tty"] {
+ return
+ }
+
+ mi_delete_breakpoints
+ mi_gdb_reinitialize_dir $srcdir/$subdir
+ mi_gdb_reinitialize_dir $srcdir/$subdir
+ mi_gdb_load $binfile
+
+ # Useful for debugging:
+ verbose -log "Channels:"
+ verbose -log " inferior_spawn_id=$inferior_spawn_id"
+ verbose -log " gdb_spawn_id=$gdb_spawn_id"
+ verbose -log " gdb_main_spawn_id=$gdb_main_spawn_id"
+ verbose -log " mi_spawn_id=$mi_spawn_id"
+
+ mi_run_cmd
+
+ # Since we requested a synchronous -exec-run, MI should _not_
+ # process further commands yet. Any command will do.
+ send_gdb "help\n"
+
+ # Sleep a bit in order to make sure that a buggy GDB would have a
+ # chance to process the command.
+ sleep 1
+
+ # Switch to the main UI/CLI and interrupt the program.
+ switch_gdb_spawn_id $gdb_main_spawn_id
+
+ set test "interrupt"
+ gdb_test_multiple "$test" "$test" {
+ -re "$gdb_prompt " {
+ gdb_test_multiple "" "$test" {
+ -re "received signal SIGINT" {
+ pass $test
+ }
+ }
+ }
+ }
+
+ # Back on the MI channel, we should see the interrupt output
+ # _before_ the help output. If MI incorrectly processes the
+ # "help" command before the inferior stops, then the first test
+ # below consumes the help output, and the second test fails with a
+ # timeout.
+ switch_gdb_spawn_id $mi_spawn_id
+
+ set test "got interrupt output"
+ gdb_expect {
+ -re "received signal SIGINT, Interrupt" {
+ pass $test
+ }
+ timeout {
+ fail "$test (timeout)"
+ }
+ default {
+ fail $test
+ }
+ }
+
+ set test "got help output"
+ gdb_expect {
+ -re "List of classes of commands.*$mi_gdb_prompt" {
+ pass $test
+ }
+ -re "$mi_gdb_prompt" {
+ fail $test
+ }
+ timeout {
+ fail "$test (timeout)"
+ }
+ default {
+ fail $test
+ }
+ }
+}
+
+test