This is the mail archive of the gdb-cvs@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]

[binutils-gdb] GDB testsuite: Escape paths used in regular expressions


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=37539ebee2ea9fc0daceaae1074a79de88d563fb

commit 37539ebee2ea9fc0daceaae1074a79de88d563fb
Author: Don Breazeal <donb@codesourcery.com>
Date:   Fri Jul 15 11:19:19 2016 -0700

    GDB testsuite: Escape paths used in regular expressions
    
    This patch fixes problems with a few GDB testsuites when executing in a
    path that contains special characters (e.g. "++").  When such paths are
    used as a regular expression, the regular expression parser will choke
    and cause the tests to fail.  This patch uses string_to_regexp to
    escape strings that will be used as regular expressions, in order to
    sanitize path names used in expect scripts.
    
    2016-07-15  Zachary Welch  <zwelch@codesourcery.com>
    	    Don Breazeal <donb@codesourcery.com>
    
    	gdb/testsuite/ChangeLog:
    	* gdb.base/maint.exp: Escape paths used in regular expressions.
    	* gdb.stabs/weird.exp: Likewise.

Diff:
---
 gdb/testsuite/ChangeLog           |  6 ++++++
 gdb/testsuite/gdb.base/maint.exp  | 15 +++++++++------
 gdb/testsuite/gdb.stabs/weird.exp |  3 ++-
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 5269e0e..aaa1c9e 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2016-07-15  Zachary Welch  <zwelch@codesourcery.com>
+	    Don Breazeal <donb@codesourcery.com>
+
+	* gdb.base/maint.exp: Escape paths used in regular expressions.
+	* gdb.stabs/weird.exp: Likewise.
+
 2016-07-13  Tom Tromey  <tom@tromey.com>
 
 	PR python/15620, PR python/18620:
diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index f926c8b..e66f566 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -213,12 +213,13 @@ gdb_test "maint print psymbols" \
 
 if { ! $have_gdb_index } {
     set psymbols_output [standard_output_file psymbols_output]
+    set psymbols_output_re [string_to_regexp $psymbols_output]
     send_gdb "maint print psymbols $psymbols_output ${srcdir}/${subdir}/${srcfile}\n"
     gdb_expect  {
-	-re "^maint print psymbols $psymbols_output \[^\n\]*\r\n$gdb_prompt $" {
+	-re "^maint print psymbols $psymbols_output_re \[^\n\]*\r\n$gdb_prompt $" {
 	    send_gdb "shell ls $psymbols_output\n"
 	    gdb_expect {
-		-re "$psymbols_output\r\n$gdb_prompt $" {
+		-re "$psymbols_output_re\r\n$gdb_prompt $" {
 		    # We want this grep to be as specific as possible,
 		    # so it's less likely to match symbol file names in
 		    # psymbols_output.  Yes, this actually happened;
@@ -253,12 +254,13 @@ gdb_test "maint print msymbols" \
 
 
 set msymbols_output [standard_output_file msymbols_output]
+set msymbols_output_re [string_to_regexp $msymbols_output]
 send_gdb "maint print msymbols $msymbols_output ${binfile}\n"
 gdb_expect  {
-    -re "^maint print msymbols $msymbols_output \[^\n\]*\r\n$gdb_prompt $" {
+    -re "^maint print msymbols $msymbols_output_re \[^\n\]*\r\n$gdb_prompt $" {
 	send_gdb "shell ls $msymbols_output\n"
 	gdb_expect {
-	    -re "$msymbols_output\r\n$gdb_prompt $" {
+	    -re "$msymbols_output_re\r\n$gdb_prompt $" {
 		send_gdb "shell grep factorial $msymbols_output\n"
 		gdb_expect {
 		    -re "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*$gdb_prompt $" {
@@ -331,12 +333,13 @@ gdb_test "maint print symbols" \
 # for GNU libc.
 
 set symbols_output [standard_output_file symbols_output]
+set symbols_output_re [string_to_regexp $symbols_output]
 send_gdb "maint print symbols $symbols_output ${srcdir}/${subdir}/${srcfile}\n"
 gdb_expect  {
-    -re "^maint print symbols $symbols_output \[^\n\]*\r\n$gdb_prompt $" {
+    -re "^maint print symbols $symbols_output_re \[^\n\]*\r\n$gdb_prompt $" {
 	send_gdb "shell ls $symbols_output\n"
 	gdb_expect {
-	    -re "$symbols_output\r\n$gdb_prompt $" {
+	    -re "$symbols_output_re\r\n$gdb_prompt $" {
 		# See comments for `maint print psymbols'.
 		send_gdb "shell grep 'main(.*block' $symbols_output\n"
 		gdb_expect {
diff --git a/gdb/testsuite/gdb.stabs/weird.exp b/gdb/testsuite/gdb.stabs/weird.exp
index fa418ed..2a8ef3e 100644
--- a/gdb/testsuite/gdb.stabs/weird.exp
+++ b/gdb/testsuite/gdb.stabs/weird.exp
@@ -284,6 +284,7 @@ gdb_reinitialize_dir $srcdir/$subdir
 
 set binfile [gdb_remote_download host ${binfile} \
 		 [standard_output_file object.o]]
+set binfile_re [string_to_regexp $binfile]
 send_gdb "file $binfile\n"
 # If $binfile is very long, a \r (but not a \n) will echo in the
 # middle of the echo of the command.  So to match the echo, we
@@ -300,7 +301,7 @@ gdb_expect 60 {
 	send_gdb "y\n"
 	exp_continue
     }
-    -re "^Reading symbols from .*$binfile\\.\\.\\.done\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)\r\n$gdb_prompt $" {
+    -re "^Reading symbols from .*$binfile_re\\.\\.\\.done\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)\r\n$gdb_prompt $" {
 	pass "weirdx.o read without error"
     }
     -re ".*$gdb_prompt $" {


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