mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-24 18:44:20 +08:00
Pass plain-text prompt to with_gdb_prompt.
I had occasion to use with_gdb_prompt in a test for the patch for PR 17314 and was passing the plain text prompt as the value, "(top-gdb)", instead of a regexp, "\(top-gdb\)" (expressed as "\\(top-gdb\\)" in TCL). I then discovered that in order to restore the prompt gdb passes the original value of $gdb_prompt to "set prompt", which works because "set prompt \(gdb\) " is equivalent to "set prompt (gdb) ". Perhaps I'm being overly cautious but this feels a bit subtle, but at any rate as an API choice I'd much rather pass the plain text form to with_gdb_prompt. I also discovered that the initial value of gdb_prompt is set in two places to two different values. At the global level gdb.exp sets it to "\[(\]gdb\[)\]" and default_gdb_init sets it to "\\(gdb\\)". The former form is undesirable as an argument to "set prompt", but it's not clear to me that just deleting this code won't break anything. Thus I just changed the value to be consistent and added a comment. gdb/testsuite/ChangeLog: * 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.
This commit is contained in:
parent
1a8bdf69e7
commit
3714cea7d4
@ -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
|
||||
|
@ -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}
|
||||
}
|
||||
|
||||
|
@ -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 " ""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user