From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 3/3] [gdb/tui] Add set tui contents-highlight on/off
Date: Tue, 16 May 2023 10:43:52 +0200 [thread overview]
Message-ID: <20230516084352.27225-4-tdevries@suse.de> (raw)
In-Reply-To: <20230516084352.27225-1-tdevries@suse.de>
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.
---
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 <http://www.gnu.org/licenses/>.
+
+# 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}_<reverse:1>$re<reverse:0>"
+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);
}
--
2.35.3
next prev parent reply other threads:[~2023-05-16 8:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 8:43 [PATCH 0/3] [gdb/tui] Allow highlighting in windows contents to be switched off Tom de Vries
2023-05-16 8:43 ` [PATCH 1/3] [gdb/tui] Add set tui status-window-mode <mode> Tom de Vries
2023-05-16 15:01 ` Eli Zaretskii
2023-05-19 19:11 ` Tom Tromey
2023-05-22 12:15 ` Tom de Vries
2023-05-16 8:43 ` [PATCH 2/3] [gdb/tui] Use ">" marker in register window Tom de Vries
2023-05-16 8:43 ` Tom de Vries [this message]
2023-05-16 15:02 ` [PATCH 3/3] [gdb/tui] Add set tui contents-highlight on/off Eli Zaretskii
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=20230516084352.27225-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).