mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-14 08:43:27 +08:00
[gdb/testsuite] Fix gdb.tui/scroll.exp with read1
When running test-case gdb.tui/scroll.exp, I get: ... Box Dump (80 x 8) @ (0, 0): 0 $17 = 16 1 (gdb) p 17 2 $18 = 17 3 (gdb) p 18 4 $19 = 18 5 (gdb) p 19 6 $20 = 19 7 (gdb) PASS: gdb.tui/scroll.exp: check cmd window in flip layout ... but with check-read1 I get instead: ... Box Dump (80 x 8) @ (0, 0): 0 (gdb) 15 1 (gdb) p 16 2 $17 = 16 3 (gdb) p 17 4 $18 = 17 5 (gdb) p 18 6 $19 = 18 7 (gdb) p 19 FAIL: gdb.tui/scroll.exp: check cmd window in flip layout ... The "p 19" command is handled by Term::command, which sends the command and then does Term::wait_for "^$gdb_prompt [string_to_regexp $cmd]", which: - matches the line with "(gdb) p 19", and - tries to match the following prompt "(gdb) " The problem is that scrolling results in reissuing output before the "(gdb) p 19", and the second matching triggers on that. Consequently, wait_for no longer translates gdb output into screen actions, and the screen does not reflect the result of "p 19". Fix this by using a new proc wait_for_region_contents, which in contrast to wait_for can handle a multi-line regexp. Tested on x86_64-linux with make targets check and check-read1.
This commit is contained in:
@ -60,7 +60,13 @@ Term::command "winheight cmd 8"
|
|||||||
Term::check_box "src window after resize" 0 8 80 16
|
Term::check_box "src window after resize" 0 8 80 16
|
||||||
|
|
||||||
for {set i 10} {$i < 20} {incr i 1} {
|
for {set i 10} {$i < 20} {incr i 1} {
|
||||||
Term::command "p $i"
|
set cmd "p $i"
|
||||||
|
send_gdb "$cmd\n"
|
||||||
|
Term::wait_for_region_contents 0 0 80 8 \
|
||||||
|
[multi_line \
|
||||||
|
"$gdb_prompt [string_to_regexp $cmd]\\s+" \
|
||||||
|
"\\\$\\d+ = $i\\s+" \
|
||||||
|
"$gdb_prompt "]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Now check that the contents of the command window are as expected.
|
# Now check that the contents of the command window are as expected.
|
||||||
|
@ -663,18 +663,10 @@ namespace eval Term {
|
|||||||
_clear_lines 0 $_rows
|
_clear_lines 0 $_rows
|
||||||
}
|
}
|
||||||
|
|
||||||
# Accept some output from gdb and update the screen. WAIT_FOR is
|
# Accept some output from gdb and update the screen.
|
||||||
# a regexp matching the line to wait for. Return 0 on timeout, 1
|
# Return 1 if successful, or 0 if a timeout occurred.
|
||||||
# on success.
|
proc accept_gdb_output { } {
|
||||||
proc wait_for {wait_for} {
|
|
||||||
global expect_out
|
global expect_out
|
||||||
global gdb_prompt
|
|
||||||
variable _cur_col
|
|
||||||
variable _cur_row
|
|
||||||
|
|
||||||
set prompt_wait_for "$gdb_prompt \$"
|
|
||||||
|
|
||||||
while 1 {
|
|
||||||
gdb_expect {
|
gdb_expect {
|
||||||
-re "^\[\x07\x08\x0a\x0d\]" {
|
-re "^\[\x07\x08\x0a\x0d\]" {
|
||||||
scan $expect_out(0,string) %c val
|
scan $expect_out(0,string) %c val
|
||||||
@ -705,6 +697,24 @@ namespace eval Term {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Accept some output from gdb and update the screen. WAIT_FOR is
|
||||||
|
# a regexp matching the line to wait for. Return 0 on timeout, 1
|
||||||
|
# on success.
|
||||||
|
proc wait_for {wait_for} {
|
||||||
|
global gdb_prompt
|
||||||
|
variable _cur_col
|
||||||
|
variable _cur_row
|
||||||
|
|
||||||
|
set prompt_wait_for "$gdb_prompt \$"
|
||||||
|
|
||||||
|
while 1 {
|
||||||
|
if { [accept_gdb_output] == 0 } {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# If the cursor appears just after the prompt, return. It
|
# If the cursor appears just after the prompt, return. It
|
||||||
# isn't reliable to check this only after an insertion,
|
# isn't reliable to check this only after an insertion,
|
||||||
# because curses may make "unusual" redrawing decisions.
|
# because curses may make "unusual" redrawing decisions.
|
||||||
@ -724,6 +734,23 @@ namespace eval Term {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Accept some output from gdb and update the screen. Wait for the screen
|
||||||
|
# region X/Y/WIDTH/HEIGTH to matches REGEXP. Return 0 on timeout, 1 on
|
||||||
|
# success.
|
||||||
|
proc wait_for_region_contents {x y width height regexp} {
|
||||||
|
while 1 {
|
||||||
|
if { [accept_gdb_output] == 0 } {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [check_region_contents_p $x $y $width $height $regexp] } {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Like ::clean_restart, but ensures that gdb starts in an
|
# Like ::clean_restart, but ensures that gdb starts in an
|
||||||
# environment where the TUI can work. ROWS and COLS are the size
|
# environment where the TUI can work. ROWS and COLS are the size
|
||||||
# of the terminal. EXECUTABLE, if given, is passed to
|
# of the terminal. EXECUTABLE, if given, is passed to
|
||||||
@ -940,15 +967,23 @@ namespace eval Term {
|
|||||||
# and HEIGHT match REGEXP. This is like check_contents except
|
# and HEIGHT match REGEXP. This is like check_contents except
|
||||||
# only part of the screen is checked. This can be used to check
|
# only part of the screen is checked. This can be used to check
|
||||||
# the contents within a box (though check_box_contents is a better
|
# the contents within a box (though check_box_contents is a better
|
||||||
# choice for boxes with a border).
|
# choice for boxes with a border). Return 1 if check succeeded.
|
||||||
proc check_region_contents { test_name x y width height regexp } {
|
proc check_region_contents_p { x y width height regexp } {
|
||||||
variable _chars
|
variable _chars
|
||||||
dump_box $x $y $width $height
|
dump_box $x $y $width $height
|
||||||
|
|
||||||
# Now grab the contents of the box, join each line together
|
# Now grab the contents of the box, join each line together
|
||||||
# with a '\r\n' sequence and match against REGEXP.
|
# with a '\r\n' sequence and match against REGEXP.
|
||||||
set result [get_region $x $y $width $height "\r\n"]
|
set result [get_region $x $y $width $height "\r\n"]
|
||||||
gdb_assert {[regexp -- $regexp $result]} $test_name
|
return [regexp -- $regexp $result]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check that the region of the screen described by X, Y, WIDTH,
|
||||||
|
# and HEIGHT match REGEXP. As check_region_contents_p, but produce
|
||||||
|
# a pass/fail message.
|
||||||
|
proc check_region_contents { test_name x y width height regexp } {
|
||||||
|
set ok [check_region_contents_p $x $y $width $height $regexp]
|
||||||
|
gdb_assert {$ok} $test_name
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check the contents of a box on the screen. This is a little
|
# Check the contents of a box on the screen. This is a little
|
||||||
|
Reference in New Issue
Block a user