aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2023-06-21 15:31:37 +0200
committerTom de Vries <tdevries@suse.de>2023-06-21 15:31:37 +0200
commit9f889c4856f38db1eade7efa2d12eb7994f2c55e (patch)
tree76402ddd26f7d9cfd47bf53f1629fbc62b1e6ccc /gdb
parentc9966f7a8e71f182734e97a7d149237f2eb89c23 (diff)
downloadfsf-binutils-gdb-9f889c4856f38db1eade7efa2d12eb7994f2c55e.zip
fsf-binutils-gdb-9f889c4856f38db1eade7efa2d12eb7994f2c55e.tar.gz
fsf-binutils-gdb-9f889c4856f38db1eade7efa2d12eb7994f2c55e.tar.bz2
[gdb/testsuite] Reimplement Term::command_no_prompt_prefix
Say we run test-case gdb.tui/basic.exp. It calls Term::enter_tui, which does: ... command_no_prompt_prefix "tui enable" ... The proc command_no_prompt_prefix is documented as: ... # As proc command, but don't wait for an initial prompt. This is used for # initial terminal commands, where there's no prompt yet. ... Indeed, before the "tui enable" command, the tuiterm is empty, so there is no prompt and just before switching to TUI we have in the tuiterm: ... tui enable ... The reason that there is no prompt, is that: - in order for tuiterm to show something, its input processing procs need to be called, and - the initial gdb prompt, and subsequent prompts generated by gdb_test-style procs, are all consumed by those procs instead. This is in principle not a problem, but the absence of a prompt makes a tuiterm session look less like a session on an actual xterm. Add a new proc gen_prompt, that: - generates a prompt using echo - consumes the response before the prompt using gdb_expect - consumes the prompt using Term::wait_for "". This allows us to reimplement Term::command_no_prompt_prefix using Term::command, and just before switching to TUI we have in the tuiterm: ... (gdb) tui enable ... Tested on x86_64-linux.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/lib/tuiterm.exp20
1 files changed, 17 insertions, 3 deletions
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 41fa554..598c1f8 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -875,6 +875,21 @@ namespace eval Term {
}
}
+ # Generate prompt on TUIterm.
+ proc gen_prompt {} {
+ # Generate a prompt.
+ send_gdb "echo\n"
+
+ # Drain the output before the prompt.
+ gdb_expect {
+ -re "echo\r\n" {
+ }
+ }
+
+ # Interpret prompt using TUIterm.
+ wait_for ""
+ }
+
# Setup ready for starting the tui, but don't actually start it.
# Returns 1 on success, 0 if TUI tests should be skipped.
proc prepare_for_tui {} {
@@ -920,9 +935,8 @@ namespace eval Term {
# As proc command, but don't wait for an initial prompt. This is used for
# initial terminal commands, where there's no prompt yet.
proc command_no_prompt_prefix {cmd} {
- send_gdb "$cmd\n"
- set str [string_to_regexp $cmd]
- wait_for "^$str"
+ gen_prompt
+ command $cmd
}
# Apply the attribute list in ATTRS to attributes array UPVAR_NAME.