From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 300 invoked by alias); 13 Feb 2009 16:36:25 -0000 Received: (qmail 32759 invoked by uid 22791); 13 Feb 2009 16:36:24 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.154) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 13 Feb 2009 16:36:13 +0000 Received: from baal.u-strasbg.fr (baal.u-strasbg.fr [IPv6:2001:660:2402::41]) by mailhost.u-strasbg.fr (8.14.2/jtpda-5.5pre1) with ESMTP id n1DGZnjw034836 ; Fri, 13 Feb 2009 17:35:50 +0100 (CET) Received: from mailserver.u-strasbg.fr (ms1.u-strasbg.fr [IPv6:2001:660:2402:d::10]) by baal.u-strasbg.fr (8.14.0/jtpda-5.5pre1) with ESMTP id n1DGZn3E036867 ; Fri, 13 Feb 2009 17:35:49 +0100 (CET) (envelope-from muller@ics.u-strasbg.fr) Received: from d620muller (www-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id n1DGZnep015485 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) ; Fri, 13 Feb 2009 17:35:49 +0100 (CET) (envelope-from muller@ics.u-strasbg.fr) From: "Pierre Muller" To: , References: In-Reply-To: Subject: RE: small test suite cleanup Date: Fri, 13 Feb 2009 16:57:00 -0000 Message-ID: <005701c98df9$25262600$6f727200$@u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-02/txt/msg00306.txt.bz2 I am just surprised by the regular expression used for the matching of the result... =20 This only accepts digits, but if you use "/x" for the format, you would get an hexadecimal printout, shouldn't that be also accepted? Given the very general name of the proc: "get_valueof" I would have expected it to support any format and accept any output, even complicated ones. But then we could run into problems of the correct regexp to delimit the return value (especially because the final newline before=20 gdb_prompt needs to be rejected, and this one is quite system dependent...) Another option would be to rename you proc to get_numeric_valueof and accepted only number in binary, octal, decimal and hexadecimal forms... But I don't like the idea of having a procedure that would issue FAIL if used for instance as [get_valueof "/s" "*args.argv" "0"] in gdb main function. By the way, the third argument should probably be optional with a default "0", no? Pierre Muller Pascal language support maintainer for GDB =20 > -----Message d'origine----- > De=A0: gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Tom Tromey > Envoy=E9=A0: Friday, February 13, 2009 5:13 PM > =C0=A0: gdb-patches@sourceware.org > Objet=A0: FYI: small test suite cleanup >=20 > I needed get_sizeof for the charset patch, and while looking I found > multiple copies of this in the testsuite. >=20 > This patch consolidates most of them -- I left a get_valueofx in > pc-fp.exp. >=20 > Built and regtested on x86-64 (compile farm). >=20 > Tom >=20 > 2009-02-13 Tom Tromey >=20 > * gdb.base/remote.exp (get_sizeof): Remove. > * gdb.base/long_long.exp (get_valueof, get_sizeof): Remove. > * gdb.base/dfp-test.exp (get_valueof, get_sizeof): Remove. > * gdb.base/sizeof.exp (get_valueof, get_sizeof): Remove. > * lib/gdb.exp (get_valueof): Move from long_long.exp. > (get_sizeof): Likewise. >=20 > diff --git a/gdb/testsuite/gdb.base/dfp-test.exp > b/gdb/testsuite/gdb.base/dfp-test.exp > index 32f36a9..94fcb41 100644 > --- a/gdb/testsuite/gdb.base/dfp-test.exp > +++ b/gdb/testsuite/gdb.base/dfp-test.exp > @@ -43,26 +43,6 @@ if ![runto_main] then { > continue > } >=20 > -# Detect the size of the target's basic types (from > gdb.base/long_long.exp). > - > -proc get_valueof { fmt exp default } { > - global gdb_prompt > - send_gdb "print${fmt} ${exp}\n" > - gdb_expect { > - -re "\\$\[0-9\]* =3D (\[-\]*\[0-9\]*).*$gdb_prompt $" { > - set val $expect_out(1,string) > - } > - timeout { > - set val ${default} > - } > - } > - return ${val} > -} > - > -proc get_sizeof { type default } { > - return [get_valueof "/d" "sizeof (${type})" $default] > -} > - > set sizeof_long [get_sizeof "long" 4] >=20 > proc d32_set_tests {} { > diff --git a/gdb/testsuite/gdb.base/long_long.exp > b/gdb/testsuite/gdb.base/long_long.exp > index e585396..d0ad5ba 100644 > --- a/gdb/testsuite/gdb.base/long_long.exp > +++ b/gdb/testsuite/gdb.base/long_long.exp > @@ -74,26 +74,6 @@ gdb_expect { >=20 > # Detect the size of the target's basic types. >=20 > -proc get_valueof { fmt exp default } { > - global gdb_prompt > - send_gdb "print${fmt} ${exp}\n" > - gdb_expect { > - -re "\\$\[0-9\]* =3D (\[-\]*\[0-9\]*).*$gdb_prompt $" { > - set val $expect_out(1,string) > - pass "get value of ${exp} ($val)" > - } > - timeout { > - set size ${default} > - fail "get value of ${exp} (timeout)" > - } > - } > - return ${val} > -} > - > -proc get_sizeof { type default } { > - return [get_valueof "/d" "sizeof (${type})" $default] > -} > - > set sizeof_char [get_sizeof "char" 1] > set sizeof_short [get_sizeof "short" 2] > set sizeof_int [get_sizeof "int" 4] > diff --git a/gdb/testsuite/gdb.base/remote.exp > b/gdb/testsuite/gdb.base/remote.exp > index 0dee13a..113c56b 100644 > --- a/gdb/testsuite/gdb.base/remote.exp > +++ b/gdb/testsuite/gdb.base/remote.exp > @@ -125,22 +125,6 @@ gdb_load_timed $binfile "limit" 0 > # Query GDB for the size of various types > # >=20 > -proc get_sizeof { type default } { > - global gdb_prompt > - send_gdb "print/d sizeof (${type})\n" > - gdb_expect { > - -re "\\$\[0-9\]* =3D (\[0-9\]*).*$gdb_prompt $" { > - set size $expect_out(1,string) > - pass "get sizeof ${type} ($size)" > - } > - timeout { > - set size ${default} > - fail "get sizeof ${type} (timeout)" > - } > - } > - return ${size} > -} > - > # Get the size of random_data table (defaults to 48K). > set sizeof_random_data [get_sizeof "random_data" 48*1024] >=20 > diff --git a/gdb/testsuite/gdb.base/sizeof.exp > b/gdb/testsuite/gdb.base/sizeof.exp > index 61a6be3..82f0da2 100644 > --- a/gdb/testsuite/gdb.base/sizeof.exp > +++ b/gdb/testsuite/gdb.base/sizeof.exp > @@ -61,24 +61,6 @@ if ![runto_main] then { > # Query GDB for the size of various types > # >=20 > -proc get_valueof { fmt exp default } { > - global gdb_prompt > - > - set test "get valueof \"${exp}\"" > - set val ${default} > - gdb_test_multiple "print${fmt} ${exp}" "$test" { > - -re "\\$\[0-9\]* =3D (\[-\]*\[0-9\]*).*$gdb_prompt $" { > - set val $expect_out(1,string) > - pass "$test ($val)" > - } > - } > - return ${val} > -} > - > -proc get_sizeof { type default } { > - return [get_valueof "/d" "sizeof (${type})" $default] > -} > - > gdb_test "next" >=20 > set sizeof_char [get_sizeof "char" 1] > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index b0059b7..e329b96 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -2878,3 +2878,26 @@ proc prepare_for_testing { testname executable > {sources ""} {options {debug}}} { >=20 > return 0 > } > + > +proc get_valueof { fmt exp default } { > + global gdb_prompt > + > + set test "get valueof \"${exp}\"" > + set val ${default} > + gdb_test_multiple "print${fmt} ${exp}" "$test" { > + -re "\\$\[0-9\]* =3D (\[-\]*\[0-9\]*).*$gdb_prompt $" { > + set val $expect_out(1,string) > + pass "$test ($val)" > + } > + timeout { > + set size ${default} > + fail "get value of ${exp} (timeout)" > + } > + } > + return ${val} > +} > + > +proc get_sizeof { type default } { > + return [get_valueof "/d" "sizeof (${type})" $default] > +} > +