From patchwork Tue May 30 10:53:24 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: 70309 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 F37A83856DFB for ; Tue, 30 May 2023 10:54:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F37A83856DFB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685444062; bh=IOsYpkFrB6KYYiQ+3GAGGr2zYFlEydOPMEzLiVV5T8s=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=nzbZV7Qhy0dbTXOzrrUwBSKXpaaA0IoWXJsN93wUGTtGbP20aE1fq64MPXirHi4LQ xDXHb1KtM2HrJcFpIJ5AeIBoAmWDu9eTCbpHsDgkBiejE6QGnR652PUZ4QmiHXoRKg 5c/gp0wdgY1/Vqq5IsgAA4y3PfBch2pQcmmKrXqo= 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 4D2F73858C00 for ; Tue, 30 May 2023 10:53:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4D2F73858C00 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 800941FD68; Tue, 30 May 2023 10:53:26 +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 69EE213A21; Tue, 30 May 2023 10:53:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EBDWGKbVdWTNZgAAMHmgww (envelope-from ); Tue, 30 May 2023 10:53:26 +0000 To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/3] [gdb/tui] Refresh on target_terminal_state::is_ours Date: Tue, 30 May 2023 12:53:24 +0200 Message-Id: <20230530105324.23089-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230530105324.23089-1-tdevries@suse.de> References: <20230530105324.23089-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, 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 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" 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. Reviewed-By: Bruno Larsen --- 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. */