From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52768 invoked by alias); 18 Mar 2016 19:25:35 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 52652 invoked by uid 89); 18 Mar 2016 19:25:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=385, exercises, sk:common, sk:common- X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 18 Mar 2016 19:25:32 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 10AF715555 for ; Fri, 18 Mar 2016 19:18:39 +0000 (UTC) Received: from cascais.lan (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2IJIYk2028091 for ; Fri, 18 Mar 2016 15:18:38 -0400 From: Pedro Alves 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 Message-Id: <1458328714-4938-5-git-send-email-palves@redhat.com> In-Reply-To: <1458328714-4938-1-git-send-email-palves@redhat.com> References: <1458328714-4938-1-git-send-email-palves@redhat.com> X-SW-Source: 2016-03/txt/msg00364.txt.bz2 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 to continue, or q 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 to continue, or q 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 to continue, or q 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 * 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 --- line at the top of the screen. */ -- 2.5.0