[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.