This is the mail archive of the gdb-patches@sources.redhat.com 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]

Re: [PATCH] setvar.exp: Escape left curly braces.


Orjan Friberg wrote:
> 
> Following Fernando's approval of the corresponding patch for
> printcmds.exp, I'd like to submit this patch for setvar.exp. It fixes
> the same problem with matching output from printing arrays. (A left
> curly brace followed by a number must be escaped, to avoid it being
> interpreted as the beginning of a bound.)
> 
> A wrapper proc for gdb_test does the escaping, and I replaced calls to
> gdb_test with it where it was necessary. (A lot of the calls to
> gdb_test_escape_braces inside test_set are redundant since only a few of
> the patterns actually contain braces that need to be escaped, but I
> couldn't think of a cleaner way to do it.)
> 

Neither do I.  The way this test script is designed we have no other choice.

By the way, if we happen to need gdb_test_escape_braces in yet another file 
we may consider moving it into gdb.exp

I am approving this one and I will try to be faster in the check in this time ;-)

Fernando

> On a native gdb, i686-pc-linux-gnu, before the patch:
> 
> # of expected passes            98
> # of unexpected failures        20
> # of unresolved testcases       22
> 
> After the patch:
> 
> # of expected passes            128
> 
> 2000-11-14  Orjan Friberg  <orjanf@axis.com>
> 
>         * gdb.base/printcmds.exp: Escape left curly braces followed by a
> number
>         in array print pattern match.
> 
> -- ***
> /home/orjanf/gdb-2000-10-27/gdb/gdb/testsuite/gdb.base/setvar.exp   Wed
> Nov
>  1 13:53:44 2000
> --- setvar.exp  Tue Nov 14 10:24:15 2000
> *************** proc test_set { args } {
> *** 121,127 ****
>                 set match ""
>             }
>             verbose "doing $arg $match"
> !           if [gdb_test "$arg" "$match" "$mess"] {
>                 fail "$message -- $match";
>                 return 1;
>             }
> --- 121,127 ----
>                 set match ""
>             }
>             verbose "doing $arg $match"
> !           if [gdb_test_escape_braces "$arg" "$match" "$mess"] {
>                 fail "$message -- $match";
>                 return 1;
>             }
> *************** proc test_set { args } {
> *** 130,135 ****
> --- 130,144 ----
>       return 0;
>   }
> 
> + # Escape a left curly brace followed by a number to prevent it from
> being
> + # interpreted as the beginning of a bound.
> + proc gdb_test_escape_braces { args } {
> +
> +     set pattern [lindex $args 1]
> +     regsub -all {\{[0-9]} $pattern {\\&} esc_pattern
> +     gdb_test [lindex $args 0] $esc_pattern [lindex $args 2]
> + }
> +
>   #
>   # test "set variable" for type "char"
>   #
> *************** test_set "set v_short_pointer=v_short_ar
> *** 320,326 ****
>   gdb_test "set v_signed_short_pointer=v_signed_short_array" ""
>   gdb_test "set variable *(v_signed_short_pointer)=123" ""
>   gdb_test "set variable *(v_signed_short_pointer+1)=-456" ""
> ! gdb_test "print v_signed_short_array" ".\[0-9\]* =.*\{123,.*-456\}" \
>       "set variable signed short pointer"
>   gdb_test "print *(v_signed_short_pointer+1)" ".\[0-9\]*.*=.*-456"
>   #
> --- 329,335 ----
>   gdb_test "set v_signed_short_pointer=v_signed_short_array" ""
>   gdb_test "set variable *(v_signed_short_pointer)=123" ""
>   gdb_test "set variable *(v_signed_short_pointer+1)=-456" ""
> ! gdb_test_escape_braces "print v_signed_short_array" ".\[0-9\]*
> =.*\{123,.*-456
> \}" \
>       "set variable signed short pointer"
>   gdb_test "print *(v_signed_short_pointer+1)" ".\[0-9\]*.*=.*-456"
>   #
> *************** gdb_test "set variable *(v_unsigned_shor
> *** 331,337 ****
>   gdb_test "set variable *(v_unsigned_short_pointer+1)=-456" ""
>   # DTS 10060CLLbs - bad type info from cc
>   if {$hp_cc_compiler} {setup_xfail hppa*-*-*11* 10060CLLbs}
> ! gdb_test "print v_unsigned_short_array" ".\[0-9\]* =.*\{123,.*65080\}"
> \
>       "set variable unsigned short pointer"
>   # DTS 10060CLLbs - bad type info from cc
>   if {$hp_cc_compiler} {setup_xfail hppa*-*-*11* 10060CLLbs}
> --- 340,346 ----
>   gdb_test "set variable *(v_unsigned_short_pointer+1)=-456" ""
>   # DTS 10060CLLbs - bad type info from cc
>   if {$hp_cc_compiler} {setup_xfail hppa*-*-*11* 10060CLLbs}
> ! gdb_test_escape_braces "print v_unsigned_short_array" ".\[0-9\]*
> =.*\{123,.*65
> 080\}" \
>       "set variable unsigned short pointer"
>   # DTS 10060CLLbs - bad type info from cc
>   if {$hp_cc_compiler} {setup_xfail hppa*-*-*11* 10060CLLbs}
> 
> --
> Orjan Friberg              E-mail: orjan.friberg@axis.com
> Axis Communications AB     Phone:  +46 46 272 17 68

-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

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