From patchwork Wed May 24 10:41:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 69945 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D5B613858439 for ; Wed, 24 May 2023 10:41:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5B613858439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684924885; bh=m8t3h1S2OVSClL6RV2yfGBdYOFB9+HS6uLda2oFw6GY=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=H7H5soh4z5BmNnSoBoFg2iBnmbgNTAemTYhijTVFZMeqBzruKk/CFy8p4ggrLDSOE jeXgbxrha+nvCFk/DQDPmiRhFwyQmRcmIzei05R1EVFStSluGNvQ93iXbQDlB6iLtW RxpbsoPGmPprVEVnFO8Y6D3Nxnc7RZAG12EtjUsY= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 623DC3858CDB for ; Wed, 24 May 2023 10:41:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 623DC3858CDB Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 954421F749; Wed, 24 May 2023 10:41:02 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7E0D7133E6; Wed, 24 May 2023 10:41:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id o7DJHb7pbWQxKgAAMHmgww (envelope-from ); Wed, 24 May 2023 10:41:02 +0000 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] [gdb/cli] Handle pending ^C after rl_callback_read_char for readline 7 Date: Wed, 24 May 2023 12:41:09 +0200 Message-Id: <20230524104109.19357-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" In commit faf01aee1d0 ("[gdb] Handle pending ^C after rl_callback_read_char") we handled a problem (described in detail in that commit) for readline >= 8 using public readline functions rl_pending_signal and rl_check_signals. For readline 7 (note that we require at least readline 7 so there's no need to worry about readline 6), there was no fix though, because rl_check_signals was not available. Fix this by instead using the private readline function _rl_signal_handler. There is precedent for using private readline variables and functions, but it's something we want to get rid of (PR build/10723). Nevertheless, I think we can allow this specific instance because it's not used when building against readline >= 8. [ In the meanwhile, a fix was committed in the devel branch of the readline repo, contained in commit 8d0c439 ("rollup of changes since readline-8.2"), first proposed here ( https://lists.gnu.org/archive/html/bug-readline/2022-10/msg00008.html ). ] Tested on x86_64-linux, against system readline 7.0 on openSUSE Leap 15.4. PR cli/27813 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27813 --- gdb/event-top.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) base-commit: 014a602b86f08de96fc80ef3f96a87db6cccad56 diff --git a/gdb/event-top.c b/gdb/event-top.c index 193ea5363ff..005ef4b7054 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -137,6 +137,9 @@ static struct async_signal_handler *async_sigterm_token; character is processed. */ void (*after_char_processing_hook) (void); +#if RL_VERSION_MAJOR == 7 +EXTERN_C void _rl_signal_handler (int); +#endif /* Wrapper function for calling into the readline library. This takes care of a couple things: @@ -203,8 +206,14 @@ gdb_rl_callback_read_char_wrapper_noexcept () noexcept pending signal. I'm not sure if that's possible, but it seems better to handle the scenario than to assert. */ rl_check_signals (); +#elif RL_VERSION_MAJOR == 7 + /* Unfortunately, rl_check_signals is not available. Use private + function _rl_signal_handler instead. */ + + while (rl_pending_signal () != 0) + _rl_signal_handler (rl_pending_signal ()); #else - /* Unfortunately, rl_check_signals is not available. */ +#error "Readline major version >= 7 expected" #endif if (after_char_processing_hook) (*after_char_processing_hook) ();