From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 6E6B23858004 for ; Mon, 22 May 2023 13:15:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E6B23858004 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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 859C31FF10; Mon, 22 May 2023 13:15:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1684761344; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/CG+2ipkIaWk5l8r+oyW8gCc7RlFx+yWZUI/TXdgkHY=; b=RBYLFBruSOdOyBQQk8JA3Gna7xF0zdUd+qexVHmbQUF38D0oYiI32bUqjxdiZuQyoAsNvH MGKsjViG1TAmJpF0fdDNHi1iAfYAYqOZdwPsJsQK+4Q5iSaSqccGLjUtVZ4sDszuxuEUSH yvh+lcdvaKO13Uaub4IiNudfU9X2/D4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1684761344; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/CG+2ipkIaWk5l8r+oyW8gCc7RlFx+yWZUI/TXdgkHY=; b=dqDwQzBssmsCxQ84VGATpFnR54mTa7poD2ew7/jF748XEE2a8qjsEgEhV5jC9XfFlRcbQL lfXcBh60oc59IYDA== 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 6D56B13776; Mon, 22 May 2023 13:15:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aPKaGQBra2RvdAAAMHmgww (envelope-from ); Mon, 22 May 2023 13:15:44 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/6] [gdb/contrib] Add ansi-for-tui.sh Date: Mon, 22 May 2023 15:15:42 +0200 Message-Id: <20230522131545.12291-5-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230522131545.12291-1-tdevries@suse.de> References: <20230522131545.12291-1-tdevries@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,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 List-Id: Using TUI with native TERM=xterm on an xterm: ... $ TERM=xterm gdb -q -tui ... works fine: ... ┌──────────────────────────────────────┐ │ │ │ │ │[ No Source Available ] │ │ │ │ │ └──────────────────────────────────────┘ In: L?? PC: ?? (gdb) ... However, in the testsuite we use tuiterm with native TERM=ansi. We'd like to use an xterm to replay scenario's that are exercised in the testsuite, and vice versa create scenario's on an xterm and be able to reproduce those in the testsuite. In order to ensure identical behaviour, we'd need identical TERM settings. So, can we use TERM=ansi on an xterm? Using TERM=ansi is supported on xterm, with two documented caveats [1]: - using the Alternative Character Set is broken, and - you'd occasionally need to repaint the screen to work around the fact that xterm has the newline glitch (xenl capability), but by using TERM=ansi you indicate it hasn't. When using TUI on an xterm with TERM=ansi we immediately run into both problems: ... ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ³ ³ ³ ³[ No Source Available ] ³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ In: L?? PC: ??( gdb) ... The border looks weird due to the problems with the ACS (PR tui/30370), and the first char of the prompt ends up in the status line due the xenl incompatibility (PR tui/30388). As advertised, after doing ^L the latter problem is solved, but not the former one. Add a gdb/contrib script that can be used to generate a terminfo entry that is based on the ansi terminfo entry but works around both of the problems, by: - adding the xenl capability, and - specifying ascii values for the hline, vline and border ACS chars, making tui border-kind acs equivalent to tui border-kind ascii. I first used ansi-for-xterm as name, but found out that besides the capabilities listed in the terminfo entry, ncurses also uses the name of the terminal to decide whether to enable certain features, which consequently requires more support in tuiterm. So I chose ansi-for-tui instead. It's also more precise to use tui in the name because the ACS solution only supports what TUI uses. Tested on x86_64-linux, by checking that both problems are no longer occurring: ... +--------------------------------------+ | | | | |[ No Source Available ] | | | | | +--------------------------------------+ In: L?? PC: ?? (gdb) ... Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30370 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30388 --- gdb/contrib/ansi-for-tui.sh | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 gdb/contrib/ansi-for-tui.sh diff --git a/gdb/contrib/ansi-for-tui.sh b/gdb/contrib/ansi-for-tui.sh new file mode 100755 index 00000000000..570ae3def81 --- /dev/null +++ b/gdb/contrib/ansi-for-tui.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# Copyright (C) 2023 Free Software Foundation, Inc. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Using TERM=ansi is supported on xterm, with two caveats [1]: +# - using the Alternative Character Set is broken, and +# - you'd occasionally need to repaint the screen to work around the fact that +# xterm has the newline glitch, but by using TERM=ansi you indicate it hasn't. +# [1] http://man.he.net/man1/xterm +# +# This scripts addresses these two caveats by generating a new terminfo entry, +# called ansi-for-tui, based on the ansi terminfo entry, with two +# modifications: +# - replace the acsc capability with a string that just uses ascii chars, and +# - add the xenl capability. +# +# By default, it generates an entry in $HOME/.terminfo/a/ansi-for-tui. + +# This allows us to run TUI using "TERM=ansi-for-tui gdb -tui" on an xterm +# and have things work as expected (just that tui border-kind acs and ascii +# look the same). + +set -e + +base=ansi +new=ansi-for-tui + +f=$(mktemp) + +# Copy from $base. +infocmp -1 $base \ + > "$f" + +# Add xenl. +echo -e "\txenl," \ + >> "$f" + +# Rename. +sed -i "s/^$base/$new/" \ + "$f" + +# Erase acsc line. +sed -i "s/^\tacsc=.*$//" \ + "$f" + +# Make acs hline, vline and corners fall back to ascii. +echo -e "\tacsc=q-x|l+k+m+j+," \ + >> "$f" + +# Compile. +tic "$@" \ + "$f" + +rm -f "$f" -- 2.35.3