From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19766 invoked by alias); 1 Oct 2013 12:48:01 -0000 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 Received: (qmail 19748 invoked by uid 89); 1 Oct 2013 12:48:01 -0000 Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.222.216) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Oct 2013 12:48:01 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,MSGID_MULTIPLE_AT autolearn=no version=3.3.2 X-HELO: mailhost.u-strasbg.fr Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antispam (Postfix) with ESMTP id 98A6D140D84; Tue, 1 Oct 2013 14:47:55 +0200 (CEST) Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antivirus (Postfix) with ESMTP id 87F9A140D6A; Tue, 1 Oct 2013 14:47:55 +0200 (CEST) Received: from md13.u-strasbg.fr (md13.u-strasbg.fr [130.79.200.248]) by mr6.u-strasbg.fr (Postfix) with ESMTP id 61187140DA4; Tue, 1 Oct 2013 14:47:53 +0200 (CEST) Received: from ms18.u-strasbg.fr (ms18.u-strasbg.fr [130.79.204.118]) by md13.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id r91ClqhP025515 ; Tue, 1 Oct 2013 14:47:52 +0200 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (Authenticated sender: mullerp) by ms18.u-strasbg.fr (Postfix) with ESMTPSA id 3E1EC1FD77; Tue, 1 Oct 2013 14:47:51 +0200 (CEST) From: "Pierre Muller" To: "'Keith Seitz'" Cc: "'gdb-patches'" References: <002901cebaf2$35ec65a0$a1c530e0$@muller@ics-cnrs.unistra.fr> <002f01cebaf2$aac80410$00580c30$@muller@ics-cnrs.unistra.fr> <524A2316.8020607@redhat.com> In-Reply-To: <524A2316.8020607@redhat.com> Subject: RE: [RFC 2/6] Avoid missing char before incomplete sequence in wchar_iterate. Date: Tue, 01 Oct 2013 12:48:00 -0000 Message-ID: <001201cebea4$700a4bc0$501ee340$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-SW-Source: 2013-10/txt/msg00040.txt.bz2 > -----Message d'origine----- > De=A0: gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Keith Seitz > Envoy=E9=A0: mardi 1 octobre 2013 03:19 > =C0=A0: Pierre Muller > Cc=A0: 'gdb-patches' > Objet=A0: Re: [RFC 2/6] Avoid missing char before incomplete sequence in > wchar_iterate. >=20 > On 09/26/2013 12:57 PM, Pierre Muller wrote: > > If charset is set to UTF-8 > > p "ABCD\340" > > will output > > "ABC" > > > > Note the missing character 'D'. > > > > This patch solves the issue by checking also for EINVAL > > if character have been converted. >=20 > This looks okay to me, but it needs a test (and a maintainer to approve). >=20 > Keith Here is a test, maybe this is overkill... On a linux machine with charset set to UTF-8, I do get failures, but not all are related to the fix in the patch... Some are due to the fact that ' command=20 added directly 8 spaces, instead of 4... Doing all that by hand is really frustrating... Should .exp files be treated differently from other tcl files? gdb Changelog entry: 2013-10-01 Pierre Muller charset.c (wchar_iterate): Also handle converted characters when EINVAL is returned by iconv call. testsuite Changelog entry: 2013-10-01 Pierre Muller * gdb.base/printcmds.c: Add strings with incomplete sequence. * gdb.base/printcmds.exp (test_repeat_bytes): Check output of=20 strings containing incomplete sequence. --- gdb/charset.c | 7 ++- gdb/testsuite/gdb.base/printcmds.c | 82 ++++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/printcmds.exp | 19 ++++++-- 3 files changed, 101 insertions(+), 7 deletions(-) diff --git a/gdb/charset.c b/gdb/charset.c index 5835fd4..f0e258c 100644 --- a/gdb/charset.c +++ b/gdb/charset.c @@ -659,7 +659,7 @@ wchar_iterate (struct wchar_iterator *iter, converted a character; if so, return it. */ if (out_avail < out_request * sizeof (gdb_wchar_t)) break; -=09=20=20=20=20=20=20 + /* Otherwise skip the first invalid character, and let the caller know about it. */ *out_result =3D wchar_iterate_invalid; @@ -687,7 +687,10 @@ wchar_iterate (struct wchar_iterator *iter, =20 case EINVAL: /* Incomplete input sequence. Let the caller know, and - arrange for future calls to see EOF. */ + arrange for future calls to see EOF. + Here also we might have converted something. */ + if (out_avail < out_request * sizeof (gdb_wchar_t)) + break; *out_result =3D wchar_iterate_incomplete; *ptr =3D iter->input; *len =3D iter->bytes; diff --git a/gdb/testsuite/gdb.base/printcmds.c b/gdb/testsuite/gdb.base/printcmds.c index d80c13d..4a645d1 100644 --- a/gdb/testsuite/gdb.base/printcmds.c +++ b/gdb/testsuite/gdb.base/printcmds.c @@ -214,6 +214,88 @@ char invalid_RRR[] =3D "aaaaaaaaaaaaaaaaaaaa" "\240\240\240\240\240\240\240\240\240\240" "\240\240\240\240\240\240\240\240\240\240cccccccccccccccccccc"; =20 +/* Same with incomplete \340 prefix. */ +char incomplete_ESE[] =3D "\340"; +char incomplete_SSE[] =3D "a\340"; +char incomplete_LSE[] =3D "abaabbaaabbb\340"; +char incomplete_RSE[] =3D "aaaaaaaaaaaaaaaaaaaa\340"; +char incomplete_ESS[] =3D "\340c"; +char incomplete_SSS[] =3D "a\340c"; +char incomplete_LSS[] =3D "abaabbaaabbb\340c"; +char incomplete_RSS[] =3D "aaaaaaaaaaaaaaaaaaaa\340c"; +char incomplete_ESL[] =3D "\340cdccddcccddd"; +char incomplete_SSL[] =3D "a\340cdccddcccddd"; +char incomplete_LSL[] =3D "abaabbaaabbb\340cdccddcccddd"; +char incomplete_RSL[] =3D "aaaaaaaaaaaaaaaaaaaa\340cdccddcccddd"; +char incomplete_ESR[] =3D "\340cccccccccccccccccccc"; +char incomplete_SSR[] =3D "a\340cccccccccccccccccccc"; +char incomplete_LSR[] =3D "abaabbaaabbb\340cccccccccccccccccccc"; +char incomplete_RSR[] =3D "aaaaaaaaaaaaaaaaaaaa\340cccccccccccccccccccc"; +char incomplete_ELE[] =3D "\340\340\340\340"; +char incomplete_SLE[] =3D "a\340\340\340\340"; +char incomplete_LLE[] =3D "abaabbaaabbb\340\340\340\340"; +char incomplete_RLE[] =3D "aaaaaaaaaaaaaaaaaaaa\340\340\340\340"; +char incomplete_ELS[] =3D "\340\340\340\340c"; +char incomplete_SLS[] =3D "a\340\340\340\340c"; +char incomplete_LLS[] =3D "abaabbaaabbb\340\340\340\340c"; +char incomplete_RLS[] =3D "aaaaaaaaaaaaaaaaaaaa\340\340\340\340c"; +char incomplete_ELL[] =3D "\340\340\340\340cdccddcccddd"; +char incomplete_SLL[] =3D "a\340\340\340\340cdccddcccddd"; +char incomplete_LLL[] =3D "abaabbaaabbb\340\340\340\340cdccddcccddd"; +char incomplete_RLL[] =3D "aaaaaaaaaaaaaaaaaaaa\340\340\340\340cdccddcccdd= d"; +char incomplete_ELR[] =3D "\340\340\340\340cccccccccccccccccccc"; +char incomplete_SLR[] =3D "a\340\340\340\340cccccccccccccccccccc"; +char incomplete_LLR[] =3D "abaabbaaabbb\340\340\340\340ccccccccccccccccccc= c"; +char incomplete_RLR[] =3D "aaaaaaaaaaaaaaaaaaaa\340\340\340\340cccccccccccccccccccc"; +char incomplete_ERE[] =3D "" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340"; +char incomplete_LRE[] =3D "abaabbaaabbb" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340"; +char incomplete_RRE[] =3D "aaaaaaaaaaaaaaaaaaaa" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340"; +char incomplete_ERS[] =3D "" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340c"; +char incomplete_ERL[] =3D "" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340cdccddcccddd"; +char incomplete_ERR[] =3D "" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340cccccccccccccccccccc"; +char incomplete_SRE[] =3D "a" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340"; +char incomplete_SRS[] =3D "a" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340c"; +char incomplete_SRL[] =3D "a" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340cdccddcccddd"; +char incomplete_SRR[] =3D "a" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340cccccccccccccccccccc"; +char incomplete_LRS[] =3D "abaabbaaabbb" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340c"; +char incomplete_LRL[] =3D "abaabbaaabbb" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340cdccddcccddd"; +char incomplete_LRR[] =3D "abaabbaaabbb" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340cccccccccccccccccccc"; +char incomplete_RRS[] =3D "aaaaaaaaaaaaaaaaaaaa" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340c"; +char incomplete_RRL[] =3D "aaaaaaaaaaaaaaaaaaaa" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340cdccddcccddd"; +char incomplete_RRR[] =3D "aaaaaaaaaaaaaaaaaaaa" + "\340\340\340\340\340\340\340\340\340\340" + "\340\340\340\340\340\340\340\340\340\340cccccccccccccccccccc"; + /* -- */ =20 int main () diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp index 60e4a7f..36149bc 100644 --- a/gdb/testsuite/gdb.base/printcmds.exp +++ b/gdb/testsuite/gdb.base/printcmds.exp @@ -827,6 +827,10 @@ proc test_repeat_bytes {} { set invalid(S) {\\240} set invalid(L) {\\240\\240\\240\\240} set invalid(R) {'\\240' } + set incomplete(S) {\\340} + set incomplete(L) {\\340\\340\\340\\340} + set incomplete(R) {'\\340' } + =20 set fmt(SSS) "\"%s%s%s\"" set fmt(SSR) "\"%s%s\", %s" @@ -843,12 +847,16 @@ proc test_repeat_bytes {} { set fmt(SS) "\"%s%s\"" =20 # Test the various permutations of invalid characters - foreach i [array names invalid] { + foreach prefix { invalid incomplete } { + foreach i [array names $prefix] { set I $i =20 if {$i =3D=3D "L"} { set i "S" } + set prefname "${prefix}($I)" + set pref [subst "$$prefname"] + verbose "prefname=3D$prefname, pref=3D$pref" =20 foreach s [array names start] { set S $s @@ -870,19 +878,20 @@ proc test_repeat_bytes {} { =20 # Special cases... if {$s =3D=3D "E"} { - set result [format $fmt($i$e) $invalid($I) $end($E)] + set result [format $fmt($i$e) $pref $end($E)] } elseif {$e =3D=3D "E"} { - set result [format $fmt($s$i) $start($S) $invalid($I)] + set result [format $fmt($s$i) $start($S) $pref] } else { set result [format $fmt($s$i$e) \ - $start($S) $invalid($I) $end($E)] + $start($S) $pref $end($E)] } =20 send_log "expecting: =3D $result\n" - gdb_test "print invalid_$S$I$E" "=3D $result" + gdb_test "print ${prefix}_$S$I$E" "=3D $result" } } } + } } =20 # Start with a fresh gdb. --=20 1.7.9