From patchwork Mon May 1 07:45:12 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: 68586 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 F24093857700 for ; Mon, 1 May 2023 07:45:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F24093857700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682927118; bh=5GYJhcNvbIvyZHQG6aLixUU5WQk5RJkkUwjHdV+u4iY=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RNDtaaLPG4eGD2htWC7nEKZGnoK3vRXZk89wg0YjEOmgovarr1Ck2G+bO3Gx+Rzvw nhjJGS2f2sWXMFysTCD+ZpYLYWgZgrqJS4Uu7znSgn26GPFj1TPt2zO1EZid74WJ49 KEnj53+7Vqbz+0yR9RrCWE9K2nmfM7GDhUmYgYWs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id DB72E3858D39 for ; Mon, 1 May 2023 07:44:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB72E3858D39 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-out1.suse.de (Postfix) with ESMTPS id 8F5AB22A6D; Mon, 1 May 2023 07:44:51 +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 7B0A413580; Mon, 1 May 2023 07:44:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id pxzwHPNtT2SfcQAAMHmgww (envelope-from ); Mon, 01 May 2023 07:44:51 +0000 Message-ID: Date: Mon, 1 May 2023 09:45:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: [PATCH] [gdb/build] Remove dependency on _rl_term_autowrap Content-Language: en-US To: Tom Tromey , Tom de Vries via Gdb-patches References: <20230430110647.975-1-tdevries@suse.de> <878re9mbb2.fsf@tromey.com> In-Reply-To: <878re9mbb2.fsf@tromey.com> X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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" [ was: Re: [pushed] [gdb/tui] Fix TUI resizing for TERM=ansi ] On 4/30/23 21:15, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries via Gdb-patches writes: > > Tom> As it happens, when TERM is set to ansi, readline decides that the terminal > Tom> cannot auto-wrap lines, and reserves one column to deal with that, and as a > Tom> result reports back one less than the actual screen width: > ... > Tom> This is currently not causing trouble in testing because we have a workaround > Tom> in place in proc Term::resize. If we disable the workaround: > > Thank you for tracking this down. > I never even considered this might be a readline issue. > > Tom> + readline_hidden_cols = _rl_term_autowrap ? 0 : 1; > > I hate to have a new dependency on a readline internal variable. Agreed, it's ugly. > Don't some distros mark these as hidden in libreadline.so? > I feel like there was another bug along these lines. > That's probably PR10723 - "Dependency on readline internal variable" ( https://sourceware.org/bugzilla/show_bug.cgi?id=10723 ). > However, I don't see another way to do it. I had an earlier version of the patch that used the COLUMNS env variable instead. It felt a bit hacky, so I went for _rl_term_autowrap, but patch attached below goes back to the COLUMNS approach. WDYT? > Maybe some official API could be added by the upstream readline. > Would you want to bring it up there? > If we commit the patch below, then this is solved for _rl_term_autowrap, but not for the other instances. I expect bringing it up will will need to be done per instance, with a detailed explanation of why we need it, so that sounds like project I don't have time for atm. > Anyway it seems ok to me. Thanks for the review. - Tom From dbb4a6b592df08d6263af38c4857c55acb540352 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Mon, 1 May 2023 07:19:33 +0200 Subject: [PATCH] [gdb/build] Remove dependency on _rl_term_autowrap Commit deb1ba4e38b ("[gdb/tui] Fix TUI resizing for TERM=ansi") introduced a dependency on readline private variable _rl_term_autowrap. There is precedent for this, but it's something we want to get rid of (PR build/10723). Remove the dependency on _rl_term_autowrap, and instead calculate readline_hidden_cols by comparing the environment variable COLS with cols as returned by rl_get_screen_size. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=10723 --- gdb/utils.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/gdb/utils.c b/gdb/utils.c index e10198accd0..8738d3fc7e4 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1116,10 +1116,6 @@ static bool filter_initialized = false; -/* See readline's rlprivate.h. */ - -EXTERN_C int _rl_term_autowrap; - /* See utils.h. */ int readline_hidden_cols = 0; @@ -1160,10 +1156,17 @@ init_page_info (void) (because rl_change_environment defaults to 1) - may report one less than the detected screen width in rl_get_screen_size (when _rl_term_autowrap == 0). - We could set readline_hidden_cols by comparing COLUMNS to cols as - returned by rl_get_screen_size, but instead simply use - _rl_term_autowrap. */ - readline_hidden_cols = _rl_term_autowrap ? 0 : 1; + We could use _rl_term_autowrap, but we want to avoid introducing + another dependency on readline private variables, so set + readline_hidden_cols by comparing COLUMNS to cols as returned by + rl_get_screen_size. */ + char *columns_env_str = getenv ("COLUMNS"); + gdb_assert (columns_env_str != nullptr); + int columns_env_val = atoi (columns_env_str); + gdb_assert (columns_env_val != 0); + readline_hidden_cols = columns_env_val - cols; + gdb_assert (readline_hidden_cols >= 0); + gdb_assert (readline_hidden_cols <= 1); lines_per_page = rows; chars_per_line = cols; base-commit: 077a1f08485e88f3b234af1dbb8b907b16045e6a -- 2.35.3