aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2023-04-25 08:33:56 +0200
committerTom de Vries <tdevries@suse.de>2023-04-25 08:33:56 +0200
commitc2feffd819867b2d21c5d7e6b3b40377ef692415 (patch)
treedcd792db56881c2ebb4ff6dd8b36ecdf3612ee0a
parent0d00a5f9d429c7cbae87b9d1057fb4f9e4ae18c2 (diff)
downloadgdb-c2feffd819867b2d21c5d7e6b3b40377ef692415.zip
gdb-c2feffd819867b2d21c5d7e6b3b40377ef692415.tar.gz
gdb-c2feffd819867b2d21c5d7e6b3b40377ef692415.tar.bz2
[gdb/testsuite] Add debug prints in Term::wait_for
The semantics of wait_for are non-trivial, and a bit hard to understand sometimes. Add some debug prints in wait_for that make it clear: - what regexps we're trying to match, - what strings we compare to the regexps, and - whether there's a match or mismatch. I've added this ad-hoc a couple of times, and it seems that it's worth having readily available. The debug prints are enabled by adding DEBUG_TUI_MATCHING=1 to the RUNTESTFLAGS: ... $ make check RUNTESTFLAGS="gdb.tui/empty.exp DEBUG_TUI_MATCHING=1" ... Tested on x86_64-linux.
-rw-r--r--gdb/testsuite/lib/tuiterm.exp21
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index ff38af0..bb46291 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -716,6 +716,20 @@ namespace eval Term {
return 1
}
+ # Print arg using "verbose -log" if DEBUG_TUI_MATCHING == 1.
+ proc debug_tui_matching { arg } {
+ set debug 0
+ if { [info exists ::DEBUG_TUI_MATCHING] } {
+ set debug $::DEBUG_TUI_MATCHING
+ }
+
+ if { ! $debug } {
+ return
+ }
+
+ verbose -log "$arg"
+ }
+
# 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.
@@ -724,7 +738,10 @@ namespace eval Term {
variable _cur_col
variable _cur_row
+ set fn "wait_for"
+
set prompt_wait_for "$gdb_prompt \$"
+ debug_tui_matching "$fn: regexp: '$wait_for'"
while 1 {
if { [accept_gdb_output] == 0 } {
@@ -740,10 +757,14 @@ namespace eval Term {
set prev [get_line $_cur_row]
}
if {[regexp -- $wait_for $prev]} {
+ debug_tui_matching "$fn: match: '$prev'"
if {$wait_for == "$prompt_wait_for"} {
break
}
set wait_for $prompt_wait_for
+ debug_tui_matching "$fn: regexp prompt: '$wait_for'"
+ } else {
+ debug_tui_matching "$fn: mismatch: '$prev'"
}
}