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]

Re: [RFA/testsuite] Regexp-escape command in capture_command_output


On Tuesday, May 19 2015, Keith Seitz wrote:

> Hi,
>
> I think this qualifies as obvious, but I thought I'd give others a
> chance to comment...
>
> Our library procedure capture_command_output will fail if the given
> command contains any regexp characters, such as "+" or "*". I noticed
> this while writing a test which attempts to call:
>
>    set xyz [capture_command_output "list +,-" ""]

Ouch :-/.  I've seen that before...

> Because COMMAND is not escaped, gdb_test_multiple will generate a false
> FAIL. This simple fix corrects that oversight.
>
> testsuite/ChangeLog
>
> 	* lib/gdb.exp (capture_command_output): Regexp-escape `command'
> 	before using in the matching pattern.
>
> On 05/19/2015 03:14 PM, Keith Seitz wrote:
>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>> index 73e55e3..fe7dd60 100644
>> --- a/gdb/testsuite/lib/gdb.exp
>> +++ b/gdb/testsuite/lib/gdb.exp
>> @@ -5185,7 +5185,7 @@ proc capture_command_output { command prefix } {
>>  
>>      set output_string ""
>>      gdb_test_multiple "$command" "capture_command_output for $command" {
>> -	-re "${command}\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" {
>> +	-re "[string_to_regexp ${command}]\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" {
>>  	    set output_string $expect_out(1,string)

The patch looks correct, but shouldn't we convert ${prefix} to regexp as
well?

Otherwise, looks good to me.

Thanks,

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


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