Skip to content

Commit bd447ab

Browse files
committed
Make gdb.base/corefile.exp work on terminals with few rows
When creating a pty to spawn a subprocess (such as gdb), Expect copies the settings of its own controlling terminal, including the number of rows and columns. If you "make check" on a terminal with just a few rows (e.g. 4), GDB will paginate before reaching the initial prompt. In default_gdb_start, used by most tests, this is already handled: if we see the pagination prompt, we sent \n to continue. Philippe reported that gdb.base/corefile.exp didn't work in terminals with just a few rows. This test spawns GDB by hand, because it needs to check things before the initial prompt, which it couldn't do if it used default_gdb_start. In this case I think it's not safe to use the same technique as in default_gdb_start. Even if we could send a \n if we see a pagination prompt, we match some multiline regexes in there. So if a pagination slips in there, it might make the regexes not match and fail the test. It's also not possible to use -ex "set height 0" or -iex "set height 0", it is handled after the introduction text is shown. The simplest way I found to avoid showing the pagination completely is to set stty_init (documented in expect's man page) to initialize gdb's pty with a fixed number of rows. And actually, if we set stty_init in gdb_init, it works nicely as a general solution applicable to all tests. We can therefore remove the solution introduced in e882ef3 ("testsuite: expect possible pagination when starting gdb") where we matched the pagination prompt during startup. gdb/testsuite/ChangeLog: * lib/gdb.exp (default_gdb_start): Don't match pagination prompt. (gdb_init): Set stty_init.
1 parent 46e3ed7 commit bd447ab

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

gdb/testsuite/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2019-02-07 Simon Marchi <[email protected]>
2+
3+
* lib/gdb.exp (default_gdb_start): Don't match pagination
4+
prompt.
5+
(gdb_init): Set stty_init.
6+
17
2019-01-27 Tom Tromey <[email protected]>
28

39
* gdb.python/py-finish-breakpoint.exp: Remove duplicate call to

gdb/testsuite/lib/gdb.exp

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ proc default_gdb_spawn { } {
16381638
# Default gdb_start procedure.
16391639

16401640
proc default_gdb_start { } {
1641-
global gdb_prompt pagination_prompt
1641+
global gdb_prompt
16421642
global gdb_spawn_id
16431643
global inferior_spawn_id
16441644

@@ -1659,29 +1659,20 @@ proc default_gdb_start { } {
16591659
# When running over NFS, particularly if running many simultaneous
16601660
# tests on different hosts all using the same server, things can
16611661
# get really slow. Give gdb at least 3 minutes to start up.
1662-
set loop_again 1
1663-
while { $loop_again } {
1664-
set loop_again 0
1665-
gdb_expect 360 {
1666-
-re "$pagination_prompt" {
1667-
verbose "Hit pagination during startup. Pressing enter to continue."
1668-
send_gdb "\n"
1669-
set loop_again 1
1670-
}
1671-
-re "\[\r\n\]$gdb_prompt $" {
1672-
verbose "GDB initialized."
1673-
}
1674-
-re "$gdb_prompt $" {
1675-
perror "GDB never initialized."
1676-
unset gdb_spawn_id
1677-
return -1
1678-
}
1679-
timeout {
1680-
perror "(timeout) GDB never initialized after 10 seconds."
1681-
remote_close host
1682-
unset gdb_spawn_id
1683-
return -1
1684-
}
1662+
gdb_expect 360 {
1663+
-re "\[\r\n\]$gdb_prompt $" {
1664+
verbose "GDB initialized."
1665+
}
1666+
-re "$gdb_prompt $" {
1667+
perror "GDB never initialized."
1668+
unset gdb_spawn_id
1669+
return -1
1670+
}
1671+
timeout {
1672+
perror "(timeout) GDB never initialized after 10 seconds."
1673+
remote_close host
1674+
unset gdb_spawn_id
1675+
return -1
16851676
}
16861677
}
16871678

@@ -4752,6 +4743,11 @@ proc gdb_init { test_file_name } {
47524743
# tests.
47534744
setenv TERM "dumb"
47544745

4746+
# Initialize GDB's pty with a fixed size, to make sure we avoid pagination
4747+
# during startup. See "man expect" for details about stty_init.
4748+
global stty_init
4749+
set stty_init "rows 25 cols 80"
4750+
47554751
# Some tests (for example gdb.base/maint.exp) shell out from gdb to use
47564752
# grep. Clear GREP_OPTIONS to make the behavior predictable,
47574753
# especially having color output turned on can cause tests to fail.

0 commit comments

Comments
 (0)