From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 3/3] [gdb/tui] Refresh on target_terminal_state::is_ours
Date: Tue, 30 May 2023 12:53:24 +0200 [thread overview]
Message-ID: <20230530105324.23089-4-tdevries@suse.de> (raw)
In-Reply-To: <20230530105324.23089-1-tdevries@suse.de>
Consider a hello world compiled with -g into an a.out:
...
int main (void) {
printf ("hello\n");
return 0;
}
...
After starting TUI like this:
...
$ gdb -q a.out -ex start -ex "tui enable"
...
we do "echo \n" and type enter until the prompt is at the bottom of the screen.
After doing next to execute the printf, we have:
...
(gdb) next
hello
(gdb)
...
but the entire screen scrolled, so:
- the src window is missing the top border
- the updates in the src and status window are misaligned with the current
screen.
We can fix this by doing ^L.
Fix this by doing ^L automatically when gdb_tty_state changes to
target_terminal_state::is_ours.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.tui/hello.exp | 3 ---
gdb/tui/tui-hooks.c | 11 +++++++++++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/gdb/testsuite/gdb.tui/hello.exp b/gdb/testsuite/gdb.tui/hello.exp
index 9634d9d8059..641b3b0c48e 100644
--- a/gdb/testsuite/gdb.tui/hello.exp
+++ b/gdb/testsuite/gdb.tui/hello.exp
@@ -47,9 +47,6 @@ Term::check_box "before next: source box" 0 0 80 15
# Make the inferior print "hello".
Term::command "next"
-# Refresh to redraw the screen.
-Term::command "refresh"
-
# Check the source box again.
Term::check_box "after next: source box" 0 0 80 15
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index d67c3d7f353..d1d307cf9ce 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -211,6 +211,15 @@ tui_symtab_changed ()
from_source_symtab = true;
}
+/* Observer for terminal_owner_changed. */
+
+static void
+tui_terminal_owner_changed (target_terminal_state gdb_tty_state, bool active)
+{
+ if (active && gdb_tty_state == target_terminal_state::is_ours)
+ tui_refresh_all_win (false);
+}
+
/* Token associated with observers registered while TUI hooks are
installed. */
static const gdb::observers::token tui_observers_token {};
@@ -250,6 +259,8 @@ tui_attach_detach_observers (bool attach)
tui_context_changed, attach);
attach_or_detach (gdb::observers::current_source_symtab_and_line_changed,
tui_symtab_changed, attach);
+ attach_or_detach (gdb::observers::terminal_owner_changed,
+ tui_terminal_owner_changed, attach);
}
/* Install the TUI specific hooks. */
--
2.35.3
next prev parent reply other threads:[~2023-05-30 10:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 10:53 [PATCH 0/3] [gdb/tui] Improve handling of inferior output Tom de Vries
2023-05-30 10:53 ` [PATCH 1/3] [gdb/tui] Keep inferior output in cmd window with ^L Tom de Vries
2023-05-31 13:35 ` Bruno Larsen
2023-05-31 14:19 ` Tom de Vries
2023-05-31 14:27 ` Bruno Larsen
2023-05-31 15:24 ` Tom de Vries
2023-05-31 15:27 ` Bruno Larsen
2023-05-31 23:37 ` Tom de Vries
2023-05-30 10:53 ` [PATCH 2/3] [gdb] Add observable terminal_owner_changed Tom de Vries
2023-05-30 10:53 ` Tom de Vries [this message]
2023-05-31 14:18 ` [PATCH 3/3] [gdb/tui] Refresh on target_terminal_state::is_ours Bruno Larsen
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=20230530105324.23089-4-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).