This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [PATCH] printcmds.exp: escape curly braces in array print pattern match
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: Re: [PATCH] printcmds.exp: escape curly braces in array print pattern match
- From: Orjan Friberg <orjan dot friberg at axis dot com>
- Date: Mon, 02 Oct 2000 15:51:07 +0200
- Organization: Axis Communications AB
- References: <39D45529.7E67D55E@axis.com> <39D4DCBE.18DC@redhat.com> <39D4E6A9.B8402198@cygnus.com>
Fernando Nasser wrote:
>
> Michael Snyder wrote:
> >
> > Orjan Friberg wrote:
> > >
> > > The following patch fixes a problem with matching output from printing
> > > arrays in printcmds.exp. A left curly brace '{' followed by a number
> > > must be escaped, to avoid it being interpreted as the beginning of a
> > > bound. I escape it with \\. A right curly brace '}' does not seem to
> > > have any special meaning unless preceded by '{', but for consistency I
> > > escaped those as well (to indicate that it's not part of a bound).
> > > However, it does clutter the exp-file, so it might not be the best way
> > > to do it. I'm awaiting comments before submitting the corresponding
> > > patch for setvar.exp.
> >
> > Verified that it does not cause any additional fails on Solaris.
> > I would recommend accepting the patch (though I don't know if
> > there is a preferable way of doing it).
> >
> > Stan? Fernando?
> >
>
> Writing a little wrapper proc will do the trick, i.e. let the test pattern clear
> and yet fixing the matching problem.
>
> proc gdb_test_escape_braces {pattern args} {
> <escape the braces in pattern yelding esc_pattern>
> <call gdb_test with the esc_pattern created above>
> }
Here is a revised patch that I believe follows Fernando's suggestion. It
may not be optimal, being my first attempt at TCL scripting. Only left
curly braces followed by a number are escaped this time. I tried using
gdb_test_exact which calls string_to_regexp, but that does not work
since string_to_regexp does not escape braces. I will make a
corresponding patch for setvar.exp if this patch is accepted.
2000-10-01 Orjan Friberg <orjanf@axis.com>
* gdb.base/printcmds.exp: Escape curly braces followed by a number
in array print pattern match.
***
/home/orjanf/gdb-5.0-latest/src/gdb/testsuite/gdb.base/printcmds.exp
Tue Mar 14 18:01:05 2000
--- printcmds.exp Mon Oct 2 15:31:21 2000
*************** proc test_print_int_arrays {} {
*** 542,554 ****
gdb_test "set print elements 24" ""
! gdb_test "p int1dim" \
" = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}"
! gdb_test "p int2dim" \
" = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}}"
! gdb_test "p int3dim" \
" = {{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}"
! gdb_test "p int4dim" \
" = {{{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}}"
}
--- 542,554 ----
gdb_test "set print elements 24" ""
! gdb_test_escape_braces "p int1dim" \
" = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}"
! gdb_test_escape_braces "p int2dim" \
" = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}}"
! gdb_test_escape_braces "p int3dim" \
" = {{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}"
! gdb_test_escape_braces "p int4dim" \
" = {{{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}}"
}
*************** proc test_print_typedef_arrays {} {
*** 557,563 ****
gdb_test "set print elements 24" ""
! gdb_test "p a1" \
" = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}"
gdb_test "p a1\[0\]" " = 2"
gdb_test "p a1\[9\]" " = 20"
--- 557,563 ----
gdb_test "set print elements 24" ""
! gdb_test_escape_braces "p a1" \
" = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}"
gdb_test "p a1\[0\]" " = 2"
gdb_test "p a1\[9\]" " = 20"
*************** proc test_print_typedef_arrays {} {
*** 570,580 ****
proc test_artificial_arrays {} {
# Send \026@ instead of just @ in case the kill character is @.
! gdb_test "p int1dim\[0\]\026@2" " = {0, 1}" {p int1dim[0]@2}
! gdb_test "p int1dim\[0\]\026@2\026@3" \
"({{0, 1}, {2, 3}, {4, 5}}|\[Cc\]annot.*)" \
{p int1dim[0]@2@3}
! gdb_test {p/x (short [])0x12345678} \
" = ({0x1234, 0x5678}|{0x5678, 0x1234})"
}
--- 570,580 ----
proc test_artificial_arrays {} {
# Send \026@ instead of just @ in case the kill character is @.
! gdb_test_escape_braces "p int1dim\[0\]\026@2" " = {0, 1}" {p
int1dim[0]@2}
! gdb_test_escape_braces "p int1dim\[0\]\026@2\026@3" \
"({{0, 1}, {2, 3}, {4, 5}}|\[Cc\]annot.*)" \
{p int1dim[0]@2@3}
! gdb_test_escape_braces {p/x (short [])0x12345678} \
" = ({0x1234, 0x5678}|{0x5678, 0x1234})"
}
*************** proc test_print_array_constants {} {
*** 655,665 ****
setup_xfail "a29k-*-udi" 2416
gdb_test "print {'a','b','c'}" " = \"abc\""
setup_xfail "a29k-*-udi" 2416
! gdb_test "print {0,1,2}" " = {0, 1, 2}"
setup_xfail "a29k-*-udi" 2416
! gdb_test "print {(long)0,(long)1,(long)2}" " = {0, 1, 2}"
setup_xfail "a29k-*-udi" 2416
! gdb_test "print {{0,1,2},{3,4,5}}" " = {{0, 1, 2}, {3, 4, 5}}"
setup_xfail "a29k-*-udi" 2416
gdb_test "print {4,5,6}\[2\]" " = 6"
setup_xfail "a29k-*-udi" 2416
--- 655,665 ----
setup_xfail "a29k-*-udi" 2416
gdb_test "print {'a','b','c'}" " = \"abc\""
setup_xfail "a29k-*-udi" 2416
! gdb_test_escape_braces "print {0,1,2}" " = {0, 1, 2}"
setup_xfail "a29k-*-udi" 2416
! gdb_test_escape_braces "print {(long)0,(long)1,(long)2}" " = {0,
1, 2}"
setup_xfail "a29k-*-udi" 2416
! gdb_test_escape_braces "print {{0,1,2},{3,4,5}}" " = {{0, 1, 2},
{3, 4, 5
}}"
setup_xfail "a29k-*-udi" 2416
gdb_test "print {4,5,6}\[2\]" " = 6"
setup_xfail "a29k-*-udi" 2416
*************** proc test_printf {} {
*** 678,683 ****
--- 678,692 ----
gdb_test "printf \"x=%d,y=%f,z=%d\\n\", 5, 6.0, 7"
"x=5,y=6\.0+,z=7"
gdb_test "printf \"%x %f, %c %x, %x, %f\\n\", 0xbad, -99.541,
'z',\
0xfeedface, 0xdeadbeef, 5.0" "bad -99.54\[0-9\]+, z feedface,
deadbeef, 5.0+"
+ }
+
+ # Escape a left curly brace 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]
}
# Start with a fresh gdb.
--
Orjan Friberg E-mail: orjan.friberg@axis.com
Axis Communications AB Phone: +46 46 272 17 68