From patchwork Wed Feb 10 17:47:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zachary T Welch X-Patchwork-Id: 10800 Received: (qmail 84806 invoked by alias); 10 Feb 2016 17:47:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 84790 invoked by uid 89); 10 Feb 2016 17:47:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 Feb 2016 17:47:56 +0000 Received: from svr-orw-fem-03.mgc.mentorg.com ([147.34.97.39]) by relay1.mentorg.com with esmtp id 1aTYrp-0004P9-Hk from Zach_Welch@mentor.com ; Wed, 10 Feb 2016 09:47:53 -0800 Received: from build4-lucid-cs (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.3.224.2; Wed, 10 Feb 2016 09:47:53 -0800 Received: by build4-lucid-cs (Postfix, from userid 49860) id 05709412B1; Wed, 10 Feb 2016 09:47:52 -0800 (PST) From: Zachary T Welch To: Pedro Alves , CC: Zachary T Welch Subject: [PATCH v2] Escape paths used in regular expressions Date: Wed, 10 Feb 2016 09:47:41 -0800 Message-ID: <1455126461-9616-1-git-send-email-zwelch@codesourcery.com> In-Reply-To: <56BB6967.4070503@redhat.com> References: <56BB6967.4070503@redhat.com> MIME-Version: 1.0 On 02/10/2016 08:46 AM, Pedro Alves wrote: ... >> * gdb.exp (escape_regex_chars): New. > > Seems like you reinvented string_to_regexp. How does this version look? *gdb.base/maint.exp: Escape paths used in regular expressions. * gdb.stabs/weird.exp: Likewise. Signed-off-by: Zachary T Welch --- gdb/testsuite/gdb.base/maint.exp | 15 +++++++++------ gdb/testsuite/gdb.stabs/weird.exp | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp index f444018..b33ae26 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_regex $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_regex $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_regex $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 73f8b52..4f1f117 100644 --- a/gdb/testsuite/gdb.stabs/weird.exp +++ b/gdb/testsuite/gdb.stabs/weird.exp @@ -294,6 +294,7 @@ gdb_reinitialize_dir $srcdir/$subdir set binfile [gdb_remote_download host ${binfile} \ [standard_output_file object.o]] +set binfile_re [string_to_regex $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 @@ -310,7 +311,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 $" {