This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Escape backslash in windows path


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(-)

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
     }
 }
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]