Skip to content

Commit

Permalink
Fix for gdb.tui/tui-layout-asm.exp
Browse files Browse the repository at this point in the history
The width of the window is too narrow to display the entire assembly line.
The width of the columns in the window changes as the test walks thru the
terminal window output.  The column change results in the first and second
reads of the same line to differ thus causing the test to fail.  Increasing
the width of the window keeps the column width consistent thru the test.

If the test fails, the added check prints an message to the log file if
the failure may be due to the window being too narrow.

gdb/testsuite/ChangeLog

	* gdb.tui/tui-layout-asm.exp: Replace window width of 80 with the
	tui_asm_window_width variable for the width. Add if
	count_whitespace check.
	(count_whitespace): New proc
  • Loading branch information
carlelove committed Jul 29, 2021
1 parent 91ef1ea commit abdd420
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions gdb/testsuite/gdb.tui/tui-layout-asm.exp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,23 @@ if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
return -1
}

Term::clean_restart 24 80 $testfile
# PPC currently needs a minimum window width of 90 to work correctly.
set tui_asm_window_width 90

Term::clean_restart 24 ${tui_asm_window_width} $testfile
if {![Term::prepare_for_tui]} {
unsupported "TUI not supported"
return
}

# Helper proc, returns a count of the ' ' characters in STRING.
proc count_whitespace { string } {
return [expr {[llength [split $string { }]] - 1}]
}

# This puts us into TUI mode, and should display the ASM window.
Term::command_no_prompt_prefix "layout asm"
Term::check_box_contents "check asm box contents" 0 0 80 15 "<main>"
Term::check_box_contents "check asm box contents" 0 0 ${tui_asm_window_width} 15 "<main>"

# Scroll the ASM window down using the down arrow key. In an ideal
# world we'd like to use PageDown here, but currently our terminal
Expand Down Expand Up @@ -65,6 +73,26 @@ while (1) {
&& [regexp $re_line [Term::get_line 1]]} {
# We scrolled successfully.
} else {
if {[count_whitespace ${line}] != \
[count_whitespace [Term::get_line 1]]} {
# GDB's TUI assembler display will widen columns based on
# the longest item that appears in a column on any line.
# As we have just scrolled, and so revealed a new line, it
# is possible that the width of some columns has changed.
#
# As a result it is possible that part of the line we were
# expected to see in the output is now off the screen. And
# this test will fail.
#
# This is unfortunate, but, right now, there's no easy way
# to "lock" the format of the TUI assembler window. The
# only option appears to be making the window width wider,
# this can be done by adjusting TUI_ASM_WINDOW_WIDTH.
verbose -log "WARNING: The following failure is probably due to the TUI window"
verbose -log " width. See the comments in the test script for more"
verbose -log " details."
}

fail "$testname (scroll failed)"
Term::dump_screen
break
Expand Down

0 comments on commit abdd420

Please sign in to comment.