Fully anchor mi_gdb_test expected results.

Bob Rossi bob@brasko.net
Thu Aug 4 20:48:00 GMT 2005


On Thu, Aug 04, 2005 at 04:37:04PM -0400, Bob Rossi wrote:
> On Thu, Aug 04, 2005 at 10:32:38AM -0400, Daniel Jacobowitz wrote:
> > On Thu, Aug 04, 2005 at 10:26:01AM -0400, Bob Rossi wrote:
> > > > >   which simply allows any data at the beggining of the match. So I could
> > > > >   easily modify an MI command to output "HAHAHA, YOU CAN'T TEST ME", as
> > > > >   the first thing it outputs, and it would go unnoticed in the
> > > > >   testsuite. Probably the reason this could not have been done before is
> > > > >   because the MI input command was being echo'd back, and it would be
> > > > >   complicated to match that data.
> > > > 
> > > > I am suggesting anchoring the pattern with a copy of what you expect to
> > > > be echoed.  We already have code to escape a string into a regex.  We
> > > > know what we sent to GDB.
> > > 
> > > I originally tried this, but failed because I did *not* know how to
> > > escape a string into a regex. Is there a function written that does
> > > this? I'll try it. 
> > 
> > # Given an input string, adds backslashes as needed to create a
> > # regexp that will match the string.
> > 
> > proc string_to_regexp {str} {
> >     set result $str
> >     regsub -all {[]*+.|()^$\[]} $str {\\&} result
> >     return $result
> > }
> 
> This doesn't seem to work for the " character. 
> 
> Here's the input to string_to_regexp,
>    555-break-insert -t "\"basics.c\":28"
> 
> Here's the output,
>    555-break-insert -t "\"basics\.c\":28"
> 
> Here is what I need to pass the test (which I hand wrote),
>    -break-insert -t \"\\\\\"basics.c\\\\\":28\"
> 
> It's a little odd. The quote needs to be escaped once, which makes
> perfect sense to me. The \ char needs to be escaped with 3 back slashes,
> to make a total of 4. This is a little odd to me. Is that what
> string_to_regexp does?
> 
> Any ideas?

For instance, a change from 
   regsub -all {[]*+.|()^$\[]} $str {\\&} result
to
   regsub -all {[]*+."|()^$\[]} $str {\\&} result

escapes the quotes. Would a change like this be OK? I'll run the
testsuite.

Thanks,
Bob Rossi



More information about the Gdb-patches mailing list