aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/infrun.c6
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.base/double-prompt-target-event-error.c25
-rw-r--r--gdb/testsuite/gdb.base/double-prompt-target-event-error.exp122
-rw-r--r--gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp25
-rw-r--r--gdb/testsuite/gdb.base/paginate-bg-execution.exp77
-rw-r--r--gdb/testsuite/gdb.base/paginate-inferior-exit.exp36
8 files changed, 40 insertions, 264 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d2df843..1433cf9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2020-10-30 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ * infrun.c (fetch_inferior_event): Temporarily disable pagination.
+
2020-10-30 Pedro Alves <pedro@palves.net>
* thread.c (lookup_selected_frame): Move ...
diff --git a/gdb/infrun.c b/gdb/infrun.c
index b007af0..19031a0 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3866,6 +3866,12 @@ fetch_inferior_event ()
the main console. */
scoped_restore save_ui = make_scoped_restore (&current_ui, main_ui);
+ /* Temporarily disable pagination. Otherwise, the user would be
+ given an option to press 'q' to quit, which would cause an early
+ exit and could leave GDB in a half-baked state. */
+ scoped_restore save_pagination
+ = make_scoped_restore (&pagination_enabled, false);
+
/* End up with readline processing input, if necessary. */
{
SCOPE_EXIT { reinstall_readline_callback_handler_cleanup (); };
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 0c162bc..6c28c59 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2020-10-30 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ * gdb.base/paginate-after-ctrl-c-running.exp: Update with no pagination
+ behavior.
+ * gdb.base/paginate-bg-execution.exp: Ditto.
+ * gdb.base/paginate-inferior-exit.exp: Ditto.
+ * gdb.base/double-prompt-target-event-error.c: Remove.
+ * gdb.base/double-prompt-target-event-error.exp: Remove.
+
2020-10-29 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.base/kill-detach-inferiors-cmd.exp: Check that 'kill
diff --git a/gdb/testsuite/gdb.base/double-prompt-target-event-error.c b/gdb/testsuite/gdb.base/double-prompt-target-event-error.c
deleted file mode 100644
index 469f91d..0000000
--- a/gdb/testsuite/gdb.base/double-prompt-target-event-error.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* This testcase is part of GDB, the GNU debugger.
-
- Copyright 2014-2020 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>
-
-int
-main (void)
-{
- sleep (3);
- return 0; /* after sleep */
-}
diff --git a/gdb/testsuite/gdb.base/double-prompt-target-event-error.exp b/gdb/testsuite/gdb.base/double-prompt-target-event-error.exp
deleted file mode 100644
index 459d186..0000000
--- a/gdb/testsuite/gdb.base/double-prompt-target-event-error.exp
+++ /dev/null
@@ -1,122 +0,0 @@
-# Copyright (C) 2014-2020 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/>.
-
-if [target_info exists gdb,nointerrupts] {
- verbose "Skipping double-prompt-target-event-error.exp because of nointerrupts."
- return
-}
-
-standard_testfile
-
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug] == -1} {
- return -1
-}
-
-# Test throwing an error while GDB is handling a target event. We use
-# a ctrl-c/quit in a pagination prompt to emulate an error. COMMAND
-# is either "continue" or "wrapcont". The latter is a continue issued
-# from a user-defined command. That exercises the case of the
-# interpreter forced sync, which was the case that originally had a
-# bug.
-
-proc cancel_pagination_in_target_event { command } {
- global binfile srcfile
- global gdb_prompt pagination_prompt
-
- set testline [gdb_get_line_number "after sleep"]
-
- with_test_prefix "ctrlc target event: $command" {
- clean_restart $binfile
-
- if ![runto_main] then {
- fail "can't run to main"
- return 0
- }
-
- gdb_test "b $srcfile:$testline" \
- "Breakpoint .*$srcfile, line $testline.*" \
- "set breakpoint"
-
- gdb_test_no_output "set height 2"
-
- if { $command == "wrapcont" } {
- gdb_test_multiple "define wrapcont" "define user command: wrapcont" {
- -re "Type commands for definition of \"wrapcont\".\r\nEnd with a line saying just \"end\".\r\n>$" {
- # Note that "Continuing." is ommitted when
- # "continue" is issued from a user-defined
- # command. Issue it ourselves.
- gdb_test "echo Continuing\.\ncontinue\nend" "" \
- "define user command: wrapcont"
- }
- }
- }
-
- # Wait for pagination prompt after the "Continuing" line,
- # indicating the program was running and then stopped.
- set saw_continuing 0
- set test "continue to pagination"
- gdb_test_multiple "$command" $test {
- -re "$pagination_prompt$" {
- if {$saw_continuing} {
- pass $test
- } else {
- send_gdb "\n"
- exp_continue
- }
- }
- -re "Continuing" {
- set saw_continuing 1
- exp_continue
- }
- }
-
- # We're now stopped in a pagination query while handling a
- # target event (printing where the program stopped). Quitting
- # the pagination should result in only one prompt being
- # output.
- send_gdb "\003p 1\n"
-
- # Note gdb_test_multiple has a default match for the prompt,
- # which issues a FAIL. Consume the first prompt.
- set test "first prompt"
- gdb_test_multiple "" $test {
- -re "$gdb_prompt" {
- pass "first prompt"
- }
- }
-
- # We should only see one prompt more, and it should be
- # preceeded by print's output.
- set test "no double prompt"
- gdb_test_multiple "" $test {
- -re "$gdb_prompt.*$gdb_prompt $" {
- # The bug is present, and expect managed to read
- # enough characters into the buffer to fill it with
- # both prompts.
- fail $test
- }
- -re " = 1\r\n$gdb_prompt $" {
- pass $test
- }
- }
-
- # In case the board file wants to send further commands.
- gdb_test_no_output "set height unlimited"
- }
-}
-
-foreach variant { "continue" "wrapcont" } {
- cancel_pagination_in_target_event $variant
-}
diff --git a/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp b/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp
index 09f6fbf..f904912 100644
--- a/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp
+++ b/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp
@@ -24,12 +24,12 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} {
return -1
}
-# Send a ctrl-c while the target is running and the next output causes
-# a pagination prompt.
+# Send a ctrl-c while the target is running and check that the output
+# does not cause a pagination prompt.
-proc test_ctrlc_while_target_running_paginates {} {
+proc test_ctrlc_while_target_running_does_not_paginate {} {
global binfile srcfile
- global gdb_prompt pagination_prompt
+ global gdb_prompt
set testline [gdb_get_line_number "after sleep"]
@@ -62,18 +62,11 @@ proc test_ctrlc_while_target_running_paginates {} {
send_gdb "\003"
# GDB now intercepts the SIGINT and tries to let the user know
- # about the spurious signal, but that paginates. Make sure
- # the user can respond to the pagination query.
- set test "got prompt"
- set saw_pagination_prompt 0
- gdb_test_multiple "" $test {
- -re "$pagination_prompt$" {
- set saw_pagination_prompt 1
- send_gdb "\n"
- exp_continue
- }
+ # about the spurious signal. Make sure that this does not
+ # trigger pagination.
+ gdb_test_multiple "" "no pagination" {
-re "$gdb_prompt $" {
- gdb_assert $saw_pagination_prompt $test
+ pass $gdb_test_name
}
}
@@ -85,4 +78,4 @@ proc test_ctrlc_while_target_running_paginates {} {
}
}
-test_ctrlc_while_target_running_paginates
+test_ctrlc_while_target_running_does_not_paginate
diff --git a/gdb/testsuite/gdb.base/paginate-bg-execution.exp b/gdb/testsuite/gdb.base/paginate-bg-execution.exp
index 541362f..388dd52 100644
--- a/gdb/testsuite/gdb.base/paginate-bg-execution.exp
+++ b/gdb/testsuite/gdb.base/paginate-bg-execution.exp
@@ -13,8 +13,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# A collection of tests related to running execution commands directly
-# from the command line, with "-ex".
+# Test that a breakpoint hit event coming from background execution
+# does not trigger pagination.
standard_testfile
@@ -22,12 +22,12 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} {
return -1
}
-# Check that we handle pagination correctly when it triggers due to an
-# background execution command entered directly on the command line.
+# Check that we handle a stop event coming from a background execution
+# command without getting caught in pagination.
proc test_bg_execution_pagination_return {} {
global binfile
- global pagination_prompt
+ global decimal
with_test_prefix "paginate" {
clean_restart $binfile
@@ -43,66 +43,9 @@ proc test_bg_execution_pagination_return {} {
gdb_test "continue&" "Continuing\."
- set test "pagination handled, breakpoint hit"
- set saw_pagination_prompt 0
- gdb_test_multiple "" $test {
- -re "$pagination_prompt$" {
- set saw_pagination_prompt 1
- send_gdb "\n"
- exp_continue
- }
- -re "after sleep\[^\r\n\]+\r\n$" {
- gdb_assert $saw_pagination_prompt $test
- }
- }
-
- # GDB used to crash here.
- gdb_test "p 1" " = 1" "GDB accepts further input"
-
- # In case the board file wants to send further commands.
- gdb_test_no_output "set height unlimited"
- }
-}
-
-# Check that we handle canceling pagination correctly when it triggers
-# due to a background execution command entered directly on the
-# command line.
-
-proc test_bg_execution_pagination_cancel { how } {
- global binfile
- global gdb_prompt pagination_prompt
-
- with_test_prefix "cancel with $how" {
- clean_restart $binfile
-
- if ![runto_main] then {
- fail "can't run to main"
- return 0
- }
-
- gdb_test "b after_sleep"
-
- gdb_test_no_output "set height 2"
-
- gdb_test "continue&" "Continuing\."
-
- set test "continue& paginates"
- gdb_test_multiple "" $test {
- -re "$pagination_prompt$" {
- pass $test
- }
- }
-
- set test "cancel pagination"
- if { $how == "ctrl-c" } {
- send_gdb "\003"
- } else {
- send_gdb "q\n"
-
- }
- gdb_test_multiple "" $test {
- -re "Quit\r\n$gdb_prompt $" {
- pass $test
+ gdb_test_multiple "" "no pagination, breakpoint hit" {
+ -re "Breakpoint $decimal, after_sleep\[^\r\n\]+\r\n\[^\r\n\]+\r\n" {
+ pass $gdb_test_name
}
}
@@ -114,7 +57,3 @@ proc test_bg_execution_pagination_cancel { how } {
}
test_bg_execution_pagination_return
-if ![target_info exists gdb,nointerrupts] {
- test_bg_execution_pagination_cancel "ctrl-c"
-}
-test_bg_execution_pagination_cancel "quit"
diff --git a/gdb/testsuite/gdb.base/paginate-inferior-exit.exp b/gdb/testsuite/gdb.base/paginate-inferior-exit.exp
index 8e2d15c..0952763 100644
--- a/gdb/testsuite/gdb.base/paginate-inferior-exit.exp
+++ b/gdb/testsuite/gdb.base/paginate-inferior-exit.exp
@@ -13,8 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# A collection of tests related to running execution commands directly
-# from the command line, with "-ex".
+# Test that an inferior exit event does not trigger pagination.
standard_testfile
@@ -40,36 +39,9 @@ proc test_paginate_inferior_exited {} {
# Force pagination.
gdb_test_no_output "set height 2"
- set test "continue to pagination"
-
- # Wait for the "Starting program" line, indicating the program
- # is running.
- set saw_starting 0
- gdb_test_multiple "continue" $test {
- -re "$pagination_prompt" {
- if {$saw_starting} {
- pass $test
- } else {
- send_gdb "\n"
- exp_continue
- }
- }
- -re "Continuing" {
- set saw_starting 1
- exp_continue
- }
- }
-
- # We're now stopped in a pagination output while handling a
- # target event, trying to print about the program exiting.
- set test "inferior exits normally"
-
- send_gdb "\n"
- gdb_test_multiple "" $test {
- -re "$inferior_exited_re normally.*$gdb_prompt $" {
- pass $test
- }
- }
+ # The program continues until termination, without pagination
+ # being triggered.
+ gdb_continue_to_end
gdb_test "p 1" " = 1" "GDB accepts further input"