From patchwork Mon Nov 6 23:27:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 24127 Received: (qmail 122076 invoked by alias); 6 Nov 2017 23:27:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 122024 invoked by uid 89); 6 Nov 2017 23:27:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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 ESMTP; Mon, 06 Nov 2017 23:27:20 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B420BB5BB for ; Mon, 6 Nov 2017 23:27:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B420BB5BB Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43A2160C8D for ; Mon, 6 Nov 2017 23:27:19 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 2/5] Fix stdin ending up not registered after a Quit Date: Mon, 6 Nov 2017 23:27:13 +0000 Message-Id: <1510010836-15287-3-git-send-email-palves@redhat.com> In-Reply-To: <1510010836-15287-1-git-send-email-palves@redhat.com> References: <1510010836-15287-1-git-send-email-palves@redhat.com> If you press Ctrl-C while GDB is processing breakpoint commands the TRY/CATCH in inferior_event_handler catches the Quit exception and prints it, and then if the interpreter was running a foreground execution command, nothing re-adds stdin back in the event loop, meaning the debug session ends up busted, because the user can't type anything... This was exposed by the new gdb.base/bp-cmds-continue-ctrl-c.exp testcase added later in the series. gdb/ChangeLog: 2017-11-03 Pedro Alves * inf-loop.c (inferior_event_handler): Don't swallow the exception if the prompt is blocked. --- gdb/inf-loop.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c index bb9fa01..1d573b9 100644 --- a/gdb/inf-loop.c +++ b/gdb/inf-loop.c @@ -73,7 +73,15 @@ inferior_event_handler (enum inferior_event_type event_type, } CATCH (e, RETURN_MASK_ALL) { - exception_print (gdb_stderr, e); + /* If the user was running a foreground execution + command, then propagate the error so that the prompt + can be reenabled. Otherwise, the user already has + the prompt and is typing some unrelated command, so + just inform the user and swallow the exception. */ + if (current_ui->prompt_state == PROMPT_BLOCKED) + throw_exception (e); + else + exception_print (gdb_stderr, e); } END_CATCH }