From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 04/30] Don't set immediate_quit in prompt_for_continue
Date: Fri, 18 Mar 2016 19:25:00 -0000 [thread overview]
Message-ID: <1458328714-4938-5-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1458328714-4938-1-git-send-email-palves@redhat.com>
immediate_quit used to be necessary back when prompt_for_continue used
blocking fread, but nowadays it uses gdb_readline_wrapper, which is
implemented in terms of a nested event loop, which already knows how
to react to SIGINT:
#0 throw_it (reason=RETURN_QUIT, error=GDB_NO_ERROR, fmt=0x9d6d7e "Quit", ap=0x7fffffffcb88)
at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/common/common-exceptions.c:324
#1 0x00000000007bab5d in throw_vquit (fmt=0x9d6d7e "Quit", ap=0x7fffffffcb88) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/common/common-exceptions.c:366
#2 0x00000000007bac9f in throw_quit (fmt=0x9d6d7e "Quit") at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/common/common-exceptions.c:385
#3 0x0000000000773a2d in quit () at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/utils.c:1039
#4 0x000000000065d81b in async_request_quit (arg=0x0) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/event-top.c:893
#5 0x000000000065c27b in invoke_async_signal_handlers () at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/event-loop.c:949
#6 0x000000000065aeef in gdb_do_one_event () at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/event-loop.c:280
#7 0x0000000000770838 in gdb_readline_wrapper (prompt=0x7fffffffcd40 "---Type <return> to continue, or q <return> to quit---")
at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/top.c:873
The need for the QUIT in stdin_event_handler is then exposed by the
gdb.base/double-prompt-target-event-error.exp test, which has:
# 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"
Without that change we'd get:
Continuing.
---Type <return> to continue, or q <return> to quit---PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: continue to pagination
^CpQuit
(gdb) 1
Undefined command: "1". Try "help".
(gdb) PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: first prompt
ERROR: Undefined command "".
UNRESOLVED: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: no double prompt
Vs:
Continuing.
---Type <return> to continue, or q <return> to quit---PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: continue to pagination
^CQuit
(gdb) p 1
$1 = 1
(gdb) PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: first prompt
PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: no double prompt
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* event-top.c (stdin_event_handler): Call QUIT;
(prompt_for_continue): Don't run with immediate_quit set.
---
gdb/event-top.c | 8 ++++++++
gdb/utils.c | 4 ----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/gdb/event-top.c b/gdb/event-top.c
index eb4f0b9..769485f 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -403,6 +403,14 @@ stdin_event_handler (int error, gdb_client_data client_data)
}
else
{
+ /* This makes sure a ^C immediately followed by further input is
+ always processed in that order. E.g,. with input like "^Cprint
+ 1\n", the SIGINT handler runs, marks the async signal handler,
+ and then select/poll may return with stdin ready, instead of
+ -1/EINTR. The gdb.base/double-prompt-target-event-error.exp
+ test exercises this. */
+ QUIT;
+
do
{
call_stdin_event_handler_again_p = 0;
diff --git a/gdb/utils.c b/gdb/utils.c
index 97e5133..a909b38 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1836,9 +1836,6 @@ prompt_for_continue (void)
beyond the end of the screen. */
reinitialize_more_filter ();
- immediate_quit++;
- QUIT;
-
/* We'll need to handle input. */
target_terminal_ours ();
@@ -1866,7 +1863,6 @@ prompt_for_continue (void)
throw_quit ("Quit");
xfree (ignore);
}
- immediate_quit--;
/* Now we have to do this again, so that GDB will know that it doesn't
need to save the ---Type <return>--- line at the top of the screen. */
--
2.5.0
next prev parent reply other threads:[~2016-03-18 19:25 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-18 19:19 [PATCH 00/30] Stop throwing exceptions from signal handlers Pedro Alves
2016-03-18 19:18 ` [PATCH 18/30] Fix inconsistent handling of EINTR in ser-*.c backends Pedro Alves
2016-03-18 19:18 ` [PATCH 01/30] Don't rely on immediate_quit in command_line_input Pedro Alves
2016-03-18 19:19 ` [PATCH 02/30] Inline command_loop in read_command_line Pedro Alves
2016-03-18 19:19 ` [PATCH 29/30] Eliminate immediate_quit Pedro Alves
2016-03-18 19:19 ` [PATCH 22/30] Use target_terminal_ours_for_output in infcmd.c Pedro Alves
2016-03-18 19:19 ` [PATCH 19/30] ada-lang.c: Introduce type_as_string and use it Pedro Alves
2016-03-18 19:19 ` [PATCH 14/30] Don't call clear_quit_flag in captured_main Pedro Alves
2016-03-18 19:19 ` [PATCH 20/30] Use target_terminal_ours_for_output in cp-support.c Pedro Alves
2016-03-18 19:19 ` [PATCH 28/30] target remote: Don't rely on immediate_quit (introduce quit handlers) Pedro Alves
2016-03-18 19:19 ` [PATCH 03/30] TUI: check whether in secondary prompt instead of immediate_quit Pedro Alves
2016-03-18 19:19 ` [PATCH 27/30] TUI: GC tui_target_has_run Pedro Alves
2016-03-18 19:19 ` [PATCH 26/30] Use target_terminal_ours_for_output in MI Pedro Alves
2016-03-18 19:19 ` [PATCH 30/30] Eliminate target_check_pending_interrupt Pedro Alves
2016-03-18 19:24 ` [PATCH 17/30] Pass Ctrl-C to the target in target_terminal_inferior Pedro Alves
2016-03-18 19:24 ` [PATCH 23/30] Use target_terminal_ours_for_output in warning/internal_error Pedro Alves
2016-03-18 19:24 ` [PATCH 25/30] Do target_terminal_ours in query & friends instead of in all callers Pedro Alves
2016-03-18 19:25 ` [PATCH 08/30] Fix signal handler/event-loop races Pedro Alves
2016-03-18 19:25 ` Pedro Alves [this message]
2016-03-18 19:25 ` [PATCH 13/30] Don't call clear_quit_flag in prepare_to_throw_exception Pedro Alves
2016-03-18 19:25 ` [PATCH 12/30] Don't call clear_quit_flag in command_handler Pedro Alves
2016-03-18 19:26 ` [PATCH 24/30] Add missing cleanups to defaulted_query and prompt_for_continue Pedro Alves
2016-03-18 19:26 ` [PATCH 10/30] Make Python use a struct serial event Pedro Alves
2016-03-18 19:26 ` [PATCH 07/30] Introduce a serial interface for select'able events Pedro Alves
2016-03-18 19:27 ` [PATCH 06/30] Remove unused struct serial::name field Pedro Alves
2016-03-18 19:27 ` [PATCH 21/30] Use target_terminal_ours_for_output in exceptions.c Pedro Alves
2016-03-18 19:27 ` [PATCH 15/30] Eliminate clear_quit_flag Pedro Alves
2016-03-18 19:28 ` [PATCH 11/30] Don't call clear_quit_flag after check_quit_flag Pedro Alves
2016-03-18 19:28 ` [PATCH 05/30] Stop remote-fileio.c from throwing from SIGINT handler Pedro Alves
2016-03-18 19:37 ` [PATCH 16/30] Decouple target_interrupt from all-stop/non-stop modes Pedro Alves
2016-03-21 18:21 ` Simon Marchi
2016-03-21 18:24 ` Pedro Alves
2016-03-18 19:37 ` [PATCH 09/30] Introduce interruptible_select Pedro Alves
2016-03-21 17:59 ` Simon Marchi
2016-03-21 18:33 ` Pedro Alves
2016-03-21 19:48 ` Simon Marchi
2016-03-21 19:49 ` Pedro Alves
2016-03-21 19:52 ` [PATCH 00/30] Stop throwing exceptions from signal handlers Simon Marchi
2016-03-31 14:43 ` Pedro Alves
2016-03-31 18:44 ` Pedro Alves
2016-04-12 16:15 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458328714-4938-5-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox