diff mbox

Escape backslash in windows path

Message ID 1396058002-13704-1-git-send-email-yao@codesourcery.com
State Committed
Headers show

Commit Message

Yao Qi March 29, 2014, 1:53 a.m. UTC
Hi,
On windows host, we see the following ERROR,

(gdb) PASS: gdb.base/setshow.exp: set history filename ~/foobar.baz
ERROR OCCURED: couldn't compile regular expression pattern: invalid escape \ sequence
    while executing
"expect -nobrace -i exp13 -timeout 10 -re {.*A problem internal to GDB has been
detected} {
	    fail "$message (GDB internal error)"
	    gdb_internal..."
    invoked from within
"expect {
-i exp13 -timeout 10
	-re ".*A problem internal to GDB has been detected" {
	    fail "$message (GDB internal error)"
	    gdb_internal_erro..."
    ("uplevel" body line 1)
    invoked from within
"uplevel $body" REGEXP REG_EESCAPE {invalid escape \ sequence} couldn't compile
regular expression pattern: invalid escape \ sequenceERROR: Process no longer exists

which leads to
UNRESOLVED: gdb.base/setshow.exp: show history filename (~/foobar.baz)

and this error is thrown from this test below:

gdb_test "show history filename" \
    "The filename in which to record the command history is \"$HOME/foobar.baz\"..*" \
    "show history filename (~/foobar.baz)"

HOME is a windows path, like C:\foo\bar.  When it is used in gdb_test to match
output, the error is thrown because backslash is a special character in
regular expression.  This patch is to escape backslash to fix this error.

This patch is obvious to me, and I'll commit it in a few days.

gdb/testsuite:

2014-03-29  Yao Qi  <yao@codesourcery.com>

	* gdb.base/setshow.exp: Escape backslash in HOME and PWD.
---
 gdb/testsuite/gdb.base/setshow.exp |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Comments

Keith Seitz March 29, 2014, 6:04 a.m. UTC | #1
On 03/28/2014 06:53 PM, Yao Qi wrote:
> diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp
> index 13da410..0feb729 100644
> --- a/gdb/testsuite/gdb.base/setshow.exp
> +++ b/gdb/testsuite/gdb.base/setshow.exp
> @@ -171,6 +171,8 @@ set test "show environment HOME"
>   gdb_test_multiple $test $test {
>       -re "\nHOME = (\[^\r\n\]*)\[\r\n\]+$gdb_prompt $" {
>           set HOME $expect_out(1,string)
> +	# Escape backslash in case HOME is a windows path.
> +	regsub -all {\\} $HOME {\\\\} HOME
>           pass $test
>       }
>   }

Does string_to_regexp work for this?

Keith
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp
index 13da410..0feb729 100644
--- a/gdb/testsuite/gdb.base/setshow.exp
+++ b/gdb/testsuite/gdb.base/setshow.exp
@@ -171,6 +171,8 @@  set test "show environment HOME"
 gdb_test_multiple $test $test {
     -re "\nHOME = (\[^\r\n\]*)\[\r\n\]+$gdb_prompt $" {
         set HOME $expect_out(1,string)
+	# Escape backslash in case HOME is a windows path.
+	regsub -all {\\} $HOME {\\\\} HOME
         pass $test
     }
 }
@@ -187,6 +189,8 @@  set test "show working directory"
 gdb_test_multiple "pwd" $test {
     -re "\nWorking directory (\[^\r\n\]*)\\.\[\r\n\]+$gdb_prompt $" {
         set PWD $expect_out(1,string)
+	# Escape backslash in case PWD is a windows path.
+	regsub -all {\\} $PWD {\\\\} PWD
         pass $test
     }
 }