public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 4/6] [gdb/testsuite] Make ansi-for-tui available in with_tuiterm
Date: Mon, 22 May 2023 15:15:43 +0200	[thread overview]
Message-ID: <20230522131545.12291-6-tdevries@suse.de> (raw)
In-Reply-To: <20230522131545.12291-1-tdevries@suse.de>

Use contrib/ansi-for-tui.sh to create a ansi-for-tui terminfo entry in cached
dir build/gdb/testsuite/cache/terminfo, and make it available in proc
with_tuiterm using TERMINFO.

Tested on x86_64-linux.
---
 gdb/testsuite/lib/gdb.exp     | 16 ++++++++++++++++
 gdb/testsuite/lib/tuiterm.exp | 11 ++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 133d914aff8..950a1073f74 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -6578,6 +6578,22 @@ proc cached_file { filename txt {executable 0}} {
     return $filename
 }
 
+# Create a dir with name DIRNAME in the cache directory.  Return a list of:
+# - the full directory name, and
+# - 1 if a new dir was created, otherwise 0.
+
+proc cached_dir { dirname } {
+    set dirname [make_gdb_parallel_path cache $dirname]
+
+    if { [file exists $dirname] } {
+	return [list $dirname 0]
+    }
+
+    file mkdir $dirname
+
+    return [list $dirname 1]
+}
+
 # Return a wrapper around gdb that prevents generating a core file.
 
 proc gdb_no_core { } {
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index e52cb3e5b6d..4c0fdc9b6df 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -801,7 +801,16 @@ namespace eval Term {
     # BODY.
     proc with_tuiterm {rows cols body} {
 	global env stty_init
-	save_vars {env(TERM) stty_init} {
+
+	set res [cached_dir terminfo]
+	set terminfo [lindex $res 0]
+	set dir_created [lindex $res 1]
+	if { $dir_created } {
+	    exec $::srcdir/../contrib/ansi-for-tui.sh -o $terminfo
+	}
+
+	save_vars {env(TERM) env(TERMINFO) stty_init} {
+	    setenv TERMINFO $terminfo
 	    setenv TERM ansi
 	    _setup $rows $cols
 
-- 
2.35.3


  parent reply	other threads:[~2023-05-22 13:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22 13:15 [PATCH 0/6] [gdb/tui] Introduce ansi-for-tui Tom de Vries
2023-05-22 13:15 ` [PATCH 1/6] [gdb/testsuite] Use TERM=dummy in gdb.tui/tuiterm.exp Tom de Vries
2023-05-22 13:15 ` [PATCH] [gdb/tui] Add set style tui-status-window Tom de Vries
2023-05-22 13:47   ` Eli Zaretskii
2023-05-22 14:22     ` Tom de Vries
2023-05-22 15:50       ` Eli Zaretskii
2023-05-22 13:15 ` [PATCH 2/6] [gdb/testsuite] Factor out Term::_wrap_cursor Tom de Vries
2023-05-22 13:15 ` [PATCH 3/6] [gdb/contrib] Add ansi-for-tui.sh Tom de Vries
2023-05-22 13:15 ` Tom de Vries [this message]
2023-05-22 13:15 ` [PATCH 5/6] [gdb/testsuite] Implement the newline glitch in tuiterm Tom de Vries
2023-05-22 13:15 ` [PATCH 6/6] [gdb/testsuite] Use ansi-for-tui " Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230522131545.12291-6-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).