diff options
-rw-r--r-- | gdb/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/testsuite/gdb.perf/disassemble.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 31 |
3 files changed, 38 insertions, 3 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index a296aa4..c53fae4 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2014-09-13 Doug Evans <xdje42@gmail.com> + + * lib/gdb.exp (gdb_prompt): Add comment and change initial value to + be consistent with what default_gdb_init uses. + (with_gdb_prompt): Change form of PROMPT argument from a regexp to + the plain text of the prompt. Add some logging printfs. + * gdb.perf/disassemble.exp: Update call to with_gdb_prompt. + 2014-09-12 Pedro Alves <palves@redhat.com> * gdb.arch/gdb1558.exp: Replace uses of gdb_expect after diff --git a/gdb/testsuite/gdb.perf/disassemble.exp b/gdb/testsuite/gdb.perf/disassemble.exp index 07c9766..54a5bd8 100644 --- a/gdb/testsuite/gdb.perf/disassemble.exp +++ b/gdb/testsuite/gdb.perf/disassemble.exp @@ -41,7 +41,7 @@ PerfTest::assemble { # When GDB is debugging GDB, the prompt is changed to "(top-gdb) ". # In order to avoid the confusion of pattern matching, set the # gdb_prompt to '(top-gdb)' temporarily. - with_gdb_prompt "\\(top-gdb\\)" { + with_gdb_prompt "(top-gdb)" { gdb_load ${binfile} } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 937a949..b33a702 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -64,10 +64,12 @@ if ![info exists INTERNAL_GDBFLAGS] { } # The variable gdb_prompt is a regexp which matches the gdb prompt. -# Set it if it is not already set. +# Set it if it is not already set. This is also set by default_gdb_init +# but it's not clear what removing one of them will break. +# See with_gdb_prompt for more details on prompt handling. global gdb_prompt if ![info exists gdb_prompt] then { - set gdb_prompt "\[(\]gdb\[)\]" + set gdb_prompt "\\(gdb\\)" } # A regexp that matches the pagination prompt. @@ -1738,17 +1740,42 @@ proc with_test_prefix { prefix body } { # PROMPT. When BODY is finished, restore GDB prompt and variable # $gdb_prompt. # Returns the result of BODY. +# +# Notes: +# +# 1) If you want to use, for example, "(foo)" as the prompt you must pass it +# as "(foo)", and not the regexp form "\(foo\)" (expressed as "\\(foo\\)" in +# TCL). PROMPT is internally converted to a suitable regexp for matching. +# We do the conversion from "(foo)" to "\(foo\)" here for a few reasons: +# a) It's more intuitive for callers to pass the plain text form. +# b) We need two forms of the prompt: +# - a regexp to use in output matching, +# - a value to pass to the "set prompt" command. +# c) It's easier to convert the plain text form to its regexp form. +# +# 2) Don't add a trailing space, we do that here. proc with_gdb_prompt { prompt body } { global gdb_prompt + # Convert "(foo)" to "\(foo\)". + # We don't use string_to_regexp because while it works today it's not + # clear it will work tomorrow: the value we need must work as both a + # regexp *and* as the argument to the "set prompt" command, at least until + # we start recording both forms separately instead of just $gdb_prompt. + # The testsuite is pretty-much hardwired to interpret $gdb_prompt as the + # regexp form. + regsub -all {[]*+.|()^$\[\\]} $prompt {\\&} prompt + set saved $gdb_prompt + verbose -log "Setting gdb prompt to \"$prompt \"." set gdb_prompt $prompt gdb_test_no_output "set prompt $prompt " "" set code [catch {uplevel 1 $body} result] + verbose -log "Restoring gdb prompt to \"$saved \"." set gdb_prompt $saved gdb_test_no_output "set prompt $saved " "" |