From 1d4897a49f7c6befe761a79b373bf9b57bf99784 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 1 Aug 2016 16:18:10 +0100 Subject: merged tests --- gdb/testsuite/gdb.mi/new-ui-mi-sync.c | 25 +++++++ gdb/testsuite/gdb.mi/new-ui-mi-sync.exp | 114 ++++++++++++++++++++++++++++++++ gdb/testsuite/lib/mi-support.exp | 4 +- 3 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 gdb/testsuite/gdb.mi/new-ui-mi-sync.c create mode 100644 gdb/testsuite/gdb.mi/new-ui-mi-sync.exp diff --git a/gdb/testsuite/gdb.mi/new-ui-mi-sync.c b/gdb/testsuite/gdb.mi/new-ui-mi-sync.c new file mode 100644 index 00000000000..9cc8c9067f3 --- /dev/null +++ b/gdb/testsuite/gdb.mi/new-ui-mi-sync.c @@ -0,0 +1,25 @@ +/* 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 . */ + +#include + +int +main (void) +{ + sleep (180); + return 0; +} diff --git a/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp b/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp new file mode 100644 index 00000000000..5165b9e3180 --- /dev/null +++ b/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp @@ -0,0 +1,114 @@ +# 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 . + +# Test that on a separate MI UI (new-ui mi ), the printing of an +# asynchronous event (e.g. =library-loaded) during the synchronous +# execution of a command (e.g. -exec-run or -exec-continue) does not +# prematurely re-enable MI input. After executing synchronous +# commands, MI should not process further commands until the inferior +# stops again. See PR gdb/20418. + +load_lib mi-support.exp + +standard_testfile + +if {[build_executable $testfile.exp $testfile ${srcfile} "debug"] == -1} { + untested "failed to compile $testfile" + return -1 +} + +# The test driver. SYNC_COMMAND specifies which command is used to +# synchronously start the program running. + +proc do_test {sync_command} { + global srcdir subdir binfile srcfile + global gdb_spawn_id gdb_main_spawn_id mi_spawn_id inferior_spawn_id + global gdb_prompt mi_gdb_prompt + + mi_gdb_exit + + if {[mi_gdb_start "separate-mi-tty"] != 0} { + fail "Could not start gdb" + return + } + + mi_delete_breakpoints + mi_gdb_reinitialize_dir $srcdir/$subdir + mi_gdb_reinitialize_dir $srcdir/$subdir + mi_gdb_load $binfile + + # Start a synchronous run/continue on the MI UI. + set test "send synchronous execution command" + if {$sync_command == "run"} { + if {[mi_run_cmd] >= 0} { + pass $test + } else { + return + } + } else { + if {[mi_runto main] < 0} { + return + } + if {[mi_send_resuming_command_raw "123-exec-continue" $test] >= 0} { + pass $test + } else { + return + } + } + + # Send -thread-info immediately after. If everything works + # correctly, this is only serviced by GDB when the execution + # stops. + send_gdb "456-thread-info\n" + pass "send -thread-info" + + # Make sure we trigger an asynchronous event (=thread-group-added) + # in the separate MI UI. Note the "run" variant usually triggers + # =thread-group-started/=thread-created/=library-loaded as well. + with_spawn_id $gdb_main_spawn_id { + gdb_test "add-inferior" "Added inferior 2" + } + + # Interrupt the program. + with_spawn_id $gdb_main_spawn_id { + set test "interrupt on the CLI" + gdb_test_multiple "$test" "$test" { + -re "$gdb_prompt " { + gdb_test_multiple "" "$test" { + -re "received signal SIGINT" { + pass $test + } + } + } + } + } + + # On the MI channel, we should see the interrupt output _before_ + # the -thread-info output. + with_spawn_id $mi_spawn_id { + mi_expect_interrupt "got MI interrupt output" + } + + # Look for the result of our -thread-info. If input were + # re-enabled too soon, the thread would still be running. + with_spawn_id $mi_spawn_id { + mi_gdb_test "" "456\\^.*state=\"stopped\".*" \ + "got -thread-info output and thread is stopped" + } +} + +foreach_with_prefix sync-command {"run" "continue"} { + do_test ${sync-command} +} diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 28af70a8f40..18664c4d56f 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -1272,7 +1272,7 @@ proc mi_expect_interrupt { test } { if {$async} { set prompt_re "" } else { - set prompt_re "$mi_gdb_prompt$" + set prompt_re "$mi_gdb_prompt" } set r_nonstop "reason=\"signal-received\",signal-name=\"0\",signal-meaning=\"Signal 0\"" @@ -1287,7 +1287,7 @@ proc mi_expect_interrupt { test } { pass "$test" return 0 } - -re ".*\r\n$mi_gdb_prompt$" { + -re ".*\r\n$mi_gdb_prompt" { verbose -log "got $expect_out(buffer)" fail "$test (unknown output after running)" return -1 -- cgit v1.2.1