From patchwork Tue May 16 08:43:52 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: 69447 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 C87E43945C18 for ; Tue, 16 May 2023 08:50:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C87E43945C18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684227057; bh=jdMouL+vuOtlxNvsry2cETeMpor8FV7t9jAjcNYy/KM=; 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=L+ssEVduTXEVIrpnhOCCDSLsf8RZUl/+4dJ3l/dmp1mJqGxGkd8JeMN23ENbddsgj fcg2Gnw69gmiX6HLCkM4Wmn/bU3EmwHbf9113FvK3ck32L81Jo9CuBq8JPVNYP5fXV kKCNw8W5GyxJHxW7uAHrfW6/RUupkaSA75/D1N7I= 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 6A8923898C72 for ; Tue, 16 May 2023 08:43:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A8923898C72 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 1771221B4F; Tue, 16 May 2023 08:43:58 +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 01A6913A12; Tue, 16 May 2023 08:43:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uH/YOk1CY2SiMwAAMHmgww (envelope-from ); Tue, 16 May 2023 08:43:57 +0000 To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/3] [gdb/tui] Add set tui contents-highlight on/off Date: Tue, 16 May 2023 10:43:52 +0200 Message-Id: <20230516084352.27225-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230516084352.27225-1-tdevries@suse.de> References: <20230516084352.27225-1-tdevries@suse.de> MIME-Version: 1.0 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, 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" TUI highlights various parts of TUI windows: - highlighting of the current execution point in the assembly and source windows, - highlighting of changed registers in the register window. Add a new command "set tui contents-highlight on/off" that allows us to disable this. The default is on, so there's no change in behaviour. Note that the highlighting in all three windows is shadowed by the ">" marker, so we're not losing information by switching off the highlighting. Tested on x86_64-linux. Reviewed-By: Eli Zaretskii --- gdb/doc/gdb.texinfo | 7 ++++ gdb/testsuite/gdb.tui/source.exp | 59 ++++++++++++++++++++++++++++++++ gdb/tui/tui-regs.c | 4 +-- gdb/tui/tui-regs.h | 4 +-- gdb/tui/tui-win.c | 39 +++++++++++++++++++++ gdb/tui/tui-win.h | 4 +++ gdb/tui/tui-winsource.c | 4 +-- 7 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 gdb/testsuite/gdb.tui/source.exp diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 77bc4323912..836cf9623ad 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -30322,6 +30322,13 @@ The default display uses more space for line numbers; the compact display uses only as much space as is needed for the line numbers in the current file. +@item set tui contents-highlight @r{[}on@r{|}off@r{]} +@kindex set tui contents-highlight +Determine whether TUI windows contents is highlighted, such as highlighting +of the current execution point in the assembly and source windows, +and highlighting of changed registers in the register window. The +default is @code{on}. + @kindex set debug tui @item set debug tui @r{[}on|off@r{]} Turn on or off display of @value{GDBN} internal debug messages relating diff --git a/gdb/testsuite/gdb.tui/source.exp b/gdb/testsuite/gdb.tui/source.exp new file mode 100644 index 00000000000..d6b231dc43f --- /dev/null +++ b/gdb/testsuite/gdb.tui/source.exp @@ -0,0 +1,59 @@ +# Copyright 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 . + +# Check that "set tui compact-source on" has the intended effect. + +require allow_tui_tests + +tuiterm_env + +standard_testfile main-one-line.c + +if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} { + return -1 +} + +Term::clean_restart 24 80 $binfile + +gdb_test_no_output "maint set tui-left-margin-verbose on" + +if { ![runto_main] } { + return -1 +} + +if {![Term::enter_tui]} { + unsupported "TUI not supported" + return +} + + +set screen_line_with_main 6 +set screen_line [Term::get_line_with_attrs $screen_line_with_main] + +set src_line_with_main [gdb_get_line_number "int main"] + +set re "int main () { return 0; }" +set re "${src_line_with_main}_$re" +set re [string_to_regexp $re] +gdb_assert { [regexp $re $screen_line] == 1} "src line: reverse" + +Term::command "set tui contents-highlight off" +Term::command "set style enabled off" +set screen_line [Term::get_line_with_attrs $screen_line_with_main] + +set re "int main () { return 0; }" +set re "${src_line_with_main}_$re " +set re [string_to_regexp $re] +gdb_assert { [regexp $re $screen_line] == 1} "src line: normal" diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index af3b21b0f9d..43724d9dd14 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -487,7 +487,7 @@ tui_data_window::check_register_values (frame_info_ptr frame) void tui_data_item_window::rerender (WINDOW *handle, int field_width) { - if (highlight) + if (tui_contents_highlight && highlight) /* We ignore the return value, casting it to void in order to avoid a compiler warning. The warning itself was introduced by a patch to ncurses 5.7 dated 2009-08-29, changing this macro to expand @@ -540,7 +540,7 @@ tui_data_item_window::rerender (WINDOW *handle, int field_width) if (content.size () < field_width) waddstr (handle, n_spaces (field_width - content.size ())); - if (highlight) + if (tui_contents_highlight && highlight) /* We ignore the return value, casting it to void in order to avoid a compiler warning. The warning itself was introduced by a patch to ncurses 5.7 dated 2009-08-29, changing this macro to expand diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index 5adff6300aa..e0f299d4410 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -68,6 +68,8 @@ struct tui_data_window : public tui_win_info return m_current_group; } + void rerender () override; + protected: void do_scroll_vertical (int num_to_scroll) override; @@ -75,8 +77,6 @@ struct tui_data_window : public tui_win_info { } - void rerender () override; - private: /* Display the registers in the content from 'start_element_no' diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 7926e2d7a18..e0ad6551c59 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -916,6 +916,33 @@ tui_show_tab_width (struct ui_file *file, int from_tty, /* See tui-win.h. */ +bool tui_contents_highlight = true; + +static void +show_tui_contents_highlight (ui_file *file, + int from_tty, + cmd_list_element *c, + const char *value) +{ + gdb_printf (file, _("\ +Highlighting TUI windows content is %s.\n"), + value); +} + +static void +set_tui_contents_highlight (const char *ignore, int from_tty, + cmd_list_element *c) +{ + if (TUI_SRC_WIN != nullptr) + TUI_SRC_WIN->refill (); + if (TUI_DISASM_WIN != nullptr) + TUI_DISASM_WIN->refill (); + if (TUI_DATA_WIN != nullptr) + TUI_DATA_WIN->rerender (); +} + +/* See tui-win.h. */ + bool compact_source = false; /* Callback for "set tui compact-source". */ @@ -1330,6 +1357,18 @@ in a compact form. The compact form uses less horizontal space."), tui_set_compact_source, tui_show_compact_source, &tui_setlist, &tui_showlist); + add_setshow_boolean_cmd ("contents-highlight", class_tui, + &tui_contents_highlight, _("\ +Set whether TUI windows contents is highlighted."), _("\ +Show whether TUI windows contents is highlighted."), _("\ +Determine whether TUI windows contents is highlighted, such as highlighting\n\ +of the current execution point in the assembly and source windows,\n\ +highlighting of the status window, and highlighting of changed registers in\n\ +the register window."), + set_tui_contents_highlight, + show_tui_contents_highlight, + &tui_setlist, &tui_showlist); + add_setshow_boolean_cmd ("tui-current-position", class_maintenance, &style_tui_current_position, _("\ Set whether to style text highlighted by the TUI's current position indicator."), diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h index 5ace83a742a..ab1a4e177a9 100644 --- a/gdb/tui/tui-win.h +++ b/gdb/tui/tui-win.h @@ -61,4 +61,8 @@ extern bool style_tui_current_position; /* Whether to replace the spaces in the left margin with '_' and '0'. */ extern bool tui_left_margin_verbose; +/* Whether to highlight various parts of the windows content using standout + and reverse. */ +extern bool tui_contents_highlight; + #endif /* TUI_TUI_WIN_H */ diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 3c4ce501e5e..f245eecc965 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -301,13 +301,13 @@ tui_source_window_base::show_source_line (int lineno) struct tui_source_element *line; line = &m_content[lineno]; - if (line->is_exec_point) + if (tui_contents_highlight && line->is_exec_point) tui_set_reverse_mode (m_pad.get (), true); wmove (m_pad.get (), lineno, 0); puts_to_pad_with_skip (line->line.c_str (), m_pad_offset); - if (line->is_exec_point) + if (tui_contents_highlight && line->is_exec_point) tui_set_reverse_mode (m_pad.get (), false); }