+2019-11-12 Tom Tromey <tom@tromey.com>
+
+ * tui/tui-win.c (resize_message): New global.
+ (show_tui_resize_message): New function.
+ (tui_async_resize_screen): Print message if requested.
+ (_initialize_tui_win): Add tui-resize-message setting.
+ * NEWS: Add entry for new commands.
+
2019-11-11 Tom Tromey <tom@tromey.com>
* tui/tui.c (tui_initialize_readline): Add new bindable readline
A set of commands used by the testsuite for exercising the settings
infrastructure.
+maint set tui-resize-message [on|off]
+maint show tui-resize-message
+ Control whether GDB prints a message each time the terminal is
+ resized when in TUI mode. This is primarily useful for testing the
+ TUI.
+
set print frame-info [short-location|location|location-and-address
|source-and-location|source-line|auto]
show print frame-info
+2019-11-12 Tom Tromey <tom@tromey.com>
+
+ * gdb.texinfo (Maintenance Commands): Document new command.
+
2019-11-11 Tom Tromey <tom@tromey.com>
* gdb.texinfo (TUI Keys): Document readline function names.
target supports it.
@end table
+@kindex maint set tui-resize-message
+@kindex maint show tui-resize-message
+@item maint set tui-resize-message
+@item maint show tui-resize-message
+Control whether @value{GDBN} displays a message each time the terminal
+is resized when in TUI mode. The default is @code{off}, which means
+that @value{GDBN} is silent during resizes. When @code{on},
+@value{GDBN} will display a message after a resize is completed; the
+message will include a number indicating how many times the terminal
+has been resized. This setting is intended for use by the test suite,
+where it would otherwise be difficult to determine when a resize and
+refresh has been completed.
+
@kindex maint set per-command
@kindex maint show per-command
@item maint set per-command
+2019-11-12 Tom Tromey <tom@tromey.com>
+
+ * lib/tuiterm.exp (_accept): Add wait_for parameter. Check output
+ after any command. Expect prompt after WAIT_FOR is seen.
+ (enter_tui): Enable resize messages.
+ (command): Expect command in output.
+ (get_line): Avoid error when cursor appears to be off-screen.
+ (dump_screen): Include screen size in title.
+ (_do_resize): New proc, from "resize".
+ (resize): Rewrite. Do resize in two steps.
+ * gdb.tui/empty.exp (layouts): Fix entries.
+ (check_boxes): Remove xfail.
+ (check_text): Dump screen on failure.
+
2019-11-10 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.python/py-symbol.exp: Add test for
set layouts {
{src src {{0 0 80 15}} {{0 0 90 23}}
{{"no source" "No Source Available"}}}
- {regs src-regs {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 13 90 13}}
+ {regs src-regs {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 12 90 13}}
{
{"no source" "No Source Available"}
{"no regs" "Register Values Unavailable"}
}}
{asm asm {{0 0 80 15}} {{0 0 90 23}}
- {"no asm" "No Assembly Available"}}
- {regs asm-regs {{0 0 80 8} {0 7 80 9}} {{0 0 90 13} {0 13 90 14}}
+ {
+ {"no asm" "No Assembly Available"}
+ }}
+ {regs asm-regs {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 12 90 13}}
{
{"no asm" "No Assembly Available"}
{"no regs" "Register Values Unavailable"}
}}
- {split split {{0 0 80 8} {0 7 80 9}} {{0 0 90 13} {0 13 90 14}}
+ {split split {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 12 90 13}}
{
{"no source" "No Source Available"}
{"no asm" "No Assembly Available"}
}}
- {regs split-regs {{0 0 80 8} {0 7 80 9}} {{0 0 90 13} {0 13 90 14}}
+ {regs split-regs {{0 0 80 8} {0 7 80 8}} {{0 0 90 13} {0 12 90 13}}
{
{"no asm" "No Assembly Available"}
{"no regs" "Register Values Unavailable"}
proc check_boxes {boxes} {
set boxno 1
foreach box $boxes {
- if {$boxno > 1} {
- # The upper-left corner of the second box may not render
- # properly, due to overlap.
- setup_xfail *-*-*
- }
eval Term::check_box [list "box $boxno"] $box
incr boxno
}
set text [Term::get_all_lines]
foreach item $text_list {
lassign $item testname check
- gdb_assert {[string first $check $text]} $testname
+ if {![gdb_assert {[regexp -- $check $text]} $testname]} {
+ Term::dump_screen
+ }
}
}
variable _last_char
+ variable _resize_count
+
# If ARG is empty, return DEF: otherwise ARG. This is useful for
# defaulting arguments in CSIs.
proc _default {arg def} {
variable _cur_x
variable _cur_y
variable _attrs
+ variable _resize_count
set _rows $rows
set _cols $cols
set _cur_x 0
set _cur_y 0
+ set _resize_count 0
array set _attrs {
intensity normal
fg default
}
# Accept some output from gdb and update the screen.
- proc _accept {} {
+ proc _accept {wait_for} {
global expect_out
- gdb_expect {
- -re "^\[\x07\x08\x0a\x0d\]" {
- scan $expect_out(0,string) %c val
- set hexval [format "%02x" $val]
- verbose "+++ _ctl_0x${hexval}"
- _ctl_0x${hexval}
- exp_continue
- }
- -re "^\x1b(\[0-9a-zA-Z\])" {
- verbose "+++ unsupported escape"
- error "unsupported escape"
- }
- -re "^\x1b\\\[(\[0-9;\]*)(\[a-zA-Z@\])" {
- set cmd $expect_out(2,string)
- set params [split $expect_out(1,string) ";"]
- verbose "+++ _csi_$cmd <<<$expect_out(1,string)>>>"
- eval _csi_$cmd $params
- exp_continue
+ global gdb_prompt
+ variable _cur_x
+ variable _cur_y
+
+ set prompt_wait_for "$gdb_prompt \$"
+
+ while 1 {
+ gdb_expect {
+ -re "^\[\x07\x08\x0a\x0d\]" {
+ scan $expect_out(0,string) %c val
+ set hexval [format "%02x" $val]
+ verbose "+++ _ctl_0x${hexval}"
+ _ctl_0x${hexval}
+ }
+ -re "^\x1b(\[0-9a-zA-Z\])" {
+ verbose "+++ unsupported escape"
+ error "unsupported escape"
+ }
+ -re "^\x1b\\\[(\[0-9;\]*)(\[a-zA-Z@\])" {
+ set cmd $expect_out(2,string)
+ set params [split $expect_out(1,string) ";"]
+ verbose "+++ _csi_$cmd <<<$expect_out(1,string)>>>"
+ eval _csi_$cmd $params
+ }
+ -re "^\[^\x07\x08\x0a\x0d\x1b\]+" {
+ _insert $expect_out(0,string)
+ variable _last_char
+ set _last_char [string index $expect_out(0,string) end]
+ }
+
+ timeout {
+ # Assume a timeout means we somehow missed the
+ # expected result, and carry on.
+ return
+ }
}
- -re "^\[^\x07\x08\x0a\x0d\x1b\]+" {
- _insert $expect_out(0,string)
- variable _last_char
- set _last_char [string index $expect_out(0,string) end]
- # If the prompt was just inserted, return.
- variable _cur_x
- variable _cur_y
- global gdb_prompt
+
+ # If the cursor appears just after the prompt, return. It
+ # isn't reliable to check this only after an insertion,
+ # because curses may make "unusual" redrawing decisions.
+ if {$wait_for == "$prompt_wait_for"} {
set prev [get_line $_cur_y $_cur_x]
- if {![regexp -- "$gdb_prompt \$" $prev]} {
- exp_continue
+ } else {
+ set prev [get_line $_cur_y]
+ }
+ if {[regexp -- $wait_for $prev]} {
+ if {$wait_for == "$prompt_wait_for"} {
+ break
}
+ set wait_for $prompt_wait_for
}
}
}
}
gdb_test_no_output "set tui border-kind ascii"
+ gdb_test_no_output "maint set tui-resize-message on"
command "tui enable"
return 1
}
# be supplied by this function.
proc command {cmd} {
send_gdb "$cmd\n"
- _accept
+ _accept [string_to_regexp $cmd]
}
# Return the text of screen line N, without attributes. Lines are
# 0-based. If C is given, stop before column C. Columns are also
# zero-based.
proc get_line {n {c ""}} {
+ variable _rows
+ # This can happen during resizing, if the cursor seems to
+ # temporarily be off-screen.
+ if {$n >= $_rows} {
+ return ""
+ }
+
set result ""
variable _cols
variable _chars
# numbers.
proc dump_screen {} {
variable _rows
- verbose "Screen Dump:"
+ variable _cols
+ verbose "Screen Dump ($_cols x $_rows):"
for {set y 0} {$y < $_rows} {incr y} {
set fmt [format %5d $y]
verbose "$fmt [get_line $y]"
}
# Resize the terminal.
- proc resize {rows cols} {
+ proc _do_resize {rows cols} {
variable _chars
variable _rows
variable _cols
set _chars($x,$y) $local_chars($x,$y)
}
}
+ }
+
+ proc resize {rows cols} {
+ variable _rows
+ variable _cols
+ variable _resize_count
global gdb_spawn_name
+ # expect handles each argument to stty separately. This means
+ # that gdb will see SIGWINCH twice. Rather than rely on this
+ # behavior (which, after all, could be changed), we make it
+ # explicit here. This also simplifies waiting for the redraw.
+ _do_resize $rows $_cols
+ stty rows $_rows < $gdb_spawn_name
+ # Due to the strange column resizing behavior, and because we
+ # don't care about this intermediate resize, we don't check
+ # the size here.
+ _accept "@@ resize done $_resize_count"
+ incr _resize_count
# Somehow the number of columns transmitted to gdb is one less
# than what we request from expect. We hide this weird
# details from the caller.
- stty rows $_rows columns [expr {$_cols + 1}] \
- < $gdb_spawn_name
- _accept
+ _do_resize $_rows $cols
+ stty columns [expr {$_cols + 1}] < $gdb_spawn_name
+ _accept "@@ resize done $_resize_count, size = ${_cols}x${rows}"
+ incr _resize_count
}
}
#include "top.h"
#include "source.h"
#include "event-loop.h"
+#include "gdbcmd.h"
#include "tui/tui.h"
#include "tui/tui-io.h"
tui_rehighlight_all ();
}
+\f
+
+/* True if TUI resizes should print a message. This is used by the
+ test suite. */
+
+static bool resize_message;
+
+static void
+show_tui_resize_message (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("TUI resize messaging is %s.\n"), value);
+}
+
+\f
+
/* Generic window name completion function. Complete window name pointed
to by TEXT and WORD. If INCLUDE_NEXT_PREV_P is true then the special
window names 'next' and 'prev' will also be considered as possible
tui_resize_all ();
tui_refresh_all_win ();
tui_update_gdb_sizes ();
+ if (resize_message)
+ {
+ static int count;
+ printf_unfiltered ("@@ resize done %d, size = %dx%d\n", count,
+ tui_term_width (), tui_term_height ());
+ ++count;
+ }
tui_redisplay_readline ();
}
}
This variable controls how many spaces are used to display a tab character."),
tui_set_tab_width, tui_show_tab_width,
&tui_setlist, &tui_showlist);
+
+ add_setshow_boolean_cmd ("tui-resize-message", class_maintenance,
+ &resize_message, _("\
+Set TUI resize messaging."), _("\
+Show TUI resize messaging."), _("\
+When enabled GDB will print a message when the terminal is resized."),
+ nullptr,
+ show_tui_resize_message,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
}