Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: "'Keith Seitz'" <keiths@redhat.com>
Cc: "'gdb-patches'" <gdb-patches@sourceware.org>
Subject: RE: [RFC 2/6] Avoid missing char before incomplete sequence in wchar_iterate.
Date: Tue, 01 Oct 2013 12:48:00 -0000	[thread overview]
Message-ID: <001201cebea4$700a4bc0$501ee340$@muller@ics-cnrs.unistra.fr> (raw)
In-Reply-To: <524A2316.8020607@redhat.com>



> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Keith Seitz
> Envoyé : mardi 1 octobre 2013 03:19
> À : Pierre Muller
> Cc : 'gdb-patches'
> Objet : Re: [RFC 2/6] Avoid missing char before incomplete sequence in
> wchar_iterate.
> 
> On 09/26/2013 12:57 PM, Pierre Muller wrote:
> >      If charset is set to UTF-8
> > p "ABCD\340"
> > will output
> >    "ABC" <incomplete sequence \340>
> >
> >    Note the missing character 'D'.
> >
> >    This patch solves the issue by checking also for EINVAL
> > if character have been converted.
> 
> This looks okay to me, but it needs a test (and a maintainer to approve).
> 
> 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 <incomplete sequence is printed out..
Nevertheless, incomplete_LSE, incomplete_RSE and incomplete_SSE
do show one missing char.

FAIL: gdb.base/printcmds.exp: print incomplete_LLE
FAIL: gdb.base/printcmds.exp: print incomplete_RLE
FAIL: gdb.base/printcmds.exp: print incomplete_SLE
FAIL: gdb.base/printcmds.exp: print incomplete_LRE
FAIL: gdb.base/printcmds.exp: print incomplete_RRE
FAIL: gdb.base/printcmds.exp: print incomplete_SRE
FAIL: gdb.base/printcmds.exp: print incomplete_LSE
FAIL: gdb.base/printcmds.exp: print incomplete_RSE
FAIL: gdb.base/printcmds.exp: print incomplete_SSE


Pierre Muller

PS: One missing thing is the re-indentation of the exp
file for the additional foreach loop...
But using vim in visual mode and '>' command 
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  <muller@sourceware.org>

	charset.c (wchar_iterate): Also handle converted characters
 	when EINVAL is returned by iconv call.

testsuite Changelog entry:

2013-10-01  Pierre Muller  <muller@sourceware.org>

	* gdb.base/printcmds.c: Add strings with incomplete sequence.
	* gdb.base/printcmds.exp (test_repeat_bytes): Check output of 
	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;
-	      
+
 	      /* Otherwise skip the first invalid character, and let
 		 the caller know about it.  */
 	      *out_result = wchar_iterate_invalid;
@@ -687,7 +687,10 @@ wchar_iterate (struct wchar_iterator *iter,
 
 	    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 = wchar_iterate_incomplete;
 	      *ptr = iter->input;
 	      *len = 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[] = "aaaaaaaaaaaaaaaaaaaa"
   "\240\240\240\240\240\240\240\240\240\240"
   "\240\240\240\240\240\240\240\240\240\240cccccccccccccccccccc";
 
+/* Same with incomplete \340 prefix.  */
+char incomplete_ESE[] = "\340";
+char incomplete_SSE[] = "a\340";
+char incomplete_LSE[] = "abaabbaaabbb\340";
+char incomplete_RSE[] = "aaaaaaaaaaaaaaaaaaaa\340";
+char incomplete_ESS[] = "\340c";
+char incomplete_SSS[] = "a\340c";
+char incomplete_LSS[] = "abaabbaaabbb\340c";
+char incomplete_RSS[] = "aaaaaaaaaaaaaaaaaaaa\340c";
+char incomplete_ESL[] = "\340cdccddcccddd";
+char incomplete_SSL[] = "a\340cdccddcccddd";
+char incomplete_LSL[] = "abaabbaaabbb\340cdccddcccddd";
+char incomplete_RSL[] = "aaaaaaaaaaaaaaaaaaaa\340cdccddcccddd";
+char incomplete_ESR[] = "\340cccccccccccccccccccc";
+char incomplete_SSR[] = "a\340cccccccccccccccccccc";
+char incomplete_LSR[] = "abaabbaaabbb\340cccccccccccccccccccc";
+char incomplete_RSR[] = "aaaaaaaaaaaaaaaaaaaa\340cccccccccccccccccccc";
+char incomplete_ELE[] = "\340\340\340\340";
+char incomplete_SLE[] = "a\340\340\340\340";
+char incomplete_LLE[] = "abaabbaaabbb\340\340\340\340";
+char incomplete_RLE[] = "aaaaaaaaaaaaaaaaaaaa\340\340\340\340";
+char incomplete_ELS[] = "\340\340\340\340c";
+char incomplete_SLS[] = "a\340\340\340\340c";
+char incomplete_LLS[] = "abaabbaaabbb\340\340\340\340c";
+char incomplete_RLS[] = "aaaaaaaaaaaaaaaaaaaa\340\340\340\340c";
+char incomplete_ELL[] = "\340\340\340\340cdccddcccddd";
+char incomplete_SLL[] = "a\340\340\340\340cdccddcccddd";
+char incomplete_LLL[] = "abaabbaaabbb\340\340\340\340cdccddcccddd";
+char incomplete_RLL[] = "aaaaaaaaaaaaaaaaaaaa\340\340\340\340cdccddcccddd";
+char incomplete_ELR[] = "\340\340\340\340cccccccccccccccccccc";
+char incomplete_SLR[] = "a\340\340\340\340cccccccccccccccccccc";
+char incomplete_LLR[] = "abaabbaaabbb\340\340\340\340cccccccccccccccccccc";
+char incomplete_RLR[] =
"aaaaaaaaaaaaaaaaaaaa\340\340\340\340cccccccccccccccccccc";
+char incomplete_ERE[] = ""
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340";
+char incomplete_LRE[] = "abaabbaaabbb"
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340";
+char incomplete_RRE[] = "aaaaaaaaaaaaaaaaaaaa"
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340";
+char incomplete_ERS[] = ""
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340c";
+char incomplete_ERL[] = ""
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340cdccddcccddd";
+char incomplete_ERR[] = ""
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340cccccccccccccccccccc";
+char incomplete_SRE[] = "a"
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340";
+char incomplete_SRS[] = "a"
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340c";
+char incomplete_SRL[] = "a"
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340cdccddcccddd";
+char incomplete_SRR[] = "a"
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340cccccccccccccccccccc";
+char incomplete_LRS[] = "abaabbaaabbb"
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340c";
+char incomplete_LRL[] = "abaabbaaabbb"
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340cdccddcccddd";
+char incomplete_LRR[] = "abaabbaaabbb"
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340cccccccccccccccccccc";
+char incomplete_RRS[] = "aaaaaaaaaaaaaaaaaaaa"
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340c";
+char incomplete_RRL[] = "aaaaaaaaaaaaaaaaaaaa"
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340cdccddcccddd";
+char incomplete_RRR[] = "aaaaaaaaaaaaaaaaaaaa"
+  "\340\340\340\340\340\340\340\340\340\340"
+  "\340\340\340\340\340\340\340\340\340\340cccccccccccccccccccc";
+
 /* -- */
 
 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' <repeats 20 times>}
+    set incomplete(S) {\\340}
+    set incomplete(L) {\\340\\340\\340\\340}
+    set incomplete(R) {'\\340' <repeats 20 times>}
+
 
     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\""
 
     # Test the various permutations of invalid characters
-    foreach i [array names invalid] {
+    foreach prefix { invalid incomplete } {
+    foreach i [array names $prefix] {
 	set I $i
 
 	if {$i == "L"} {
 	    set i "S"
 	}
+	set prefname "${prefix}($I)"
+	set pref [subst "$$prefname"]
+	verbose "prefname=$prefname, pref=$pref"
 
 	foreach s [array names start] {
 	    set S $s
@@ -870,19 +878,20 @@ proc test_repeat_bytes {} {
 
 		# Special cases...
 		if {$s == "E"} {
-		    set result [format $fmt($i$e) $invalid($I) $end($E)]
+		    set result [format $fmt($i$e) $pref $end($E)]
 		} elseif {$e == "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)]
 		}
 
 		send_log "expecting: = $result\n"
-		gdb_test "print invalid_$S$I$E" "= $result"
+		gdb_test "print ${prefix}_$S$I$E" "= $result"
 	    }
 	}
     }
+    }
 }
 
 # Start with a fresh gdb.
-- 
1.7.9


  reply	other threads:[~2013-10-01 12:48 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-26 19:54 [RFC 0/6] Handle several character priniting problems (mainly related to mingw hosts) Pierre Muller
2013-09-26 19:57 ` [RFC 1/6] Fix display of tabulation character for mingw hosts Pierre Muller
2013-10-01  1:19   ` Keith Seitz
2013-10-01  8:02     ` [RFC 1/6 -V2] " Pierre Muller
2013-10-22 18:24       ` Keith Seitz
     [not found]     ` <10182.1932978512$1380614580@news.gmane.org>
2013-11-06 21:24       ` Tom Tromey
2013-11-08 10:26         ` Pierre Muller
2013-09-26 19:57 ` [RFC 2/6] Avoid missing char before incomplete sequence in wchar_iterate Pierre Muller
2013-10-01  1:19   ` Keith Seitz
2013-10-01 12:48     ` Pierre Muller [this message]
2013-10-22 18:25       ` Keith Seitz
     [not found]     ` <33559.6669152894$1380631692@news.gmane.org>
2013-11-06 21:38       ` Tom Tromey
2013-11-08 11:21         ` Pierre Muller
     [not found]         ` <"007201cedc72$46a78810$d3f69830$@muller"@ics-cnrs.unistra.fr>
2013-11-08 11:43           ` Eli Zaretskii
2013-09-26 20:01 ` [RFC 3/6] mingw-hdep: Add "maint set testuite-mode on/off" command Pierre Muller
2013-09-26 20:03 ` [RFC 4/6] Always set testsuite mode and interactive mode for mingw hosts Pierre Muller
2013-09-26 20:04 ` [RFC 5/6] Handle "set print sevenbit-strings on" in print_wchar Pierre Muller
2013-10-01  1:19   ` Keith Seitz
2013-10-01 13:23     ` Pierre Muller
2013-10-22 18:25       ` Keith Seitz
2013-11-06 21:43         ` Tom Tromey
2013-09-26 20:05 ` [RFC 6/6] Fix remaining failures in gdb.base/printcmds.exp for mingw hosts Pierre Muller
2013-10-01  1:19   ` Keith Seitz
2013-10-01 13:39     ` Pierre Muller
2013-10-22 18:26       ` Keith Seitz
2013-11-06 21:53         ` Tom Tromey
     [not found] ` <33207.6293569573$1380225714@news.gmane.org>
2013-09-27  8:07   ` [RFC 3/6] mingw-hdep: Add "maint set testuite-mode on/off" command asmwarrior
2013-09-27  8:11     ` asmwarrior
2013-09-27 12:12       ` Pierre Muller
2013-09-27 15:07   ` Tom Tromey
2013-09-27 17:42     ` Pierre Muller
     [not found]     ` <5245c3a0.a3e2440a.4b98.ffffd279SMTPIN_ADDED_BROKEN@mx.google.com>
2013-09-27 19:36       ` Pedro Alves
2013-09-27 19:40         ` Pedro Alves
2013-09-27 21:12           ` Pierre Muller
2013-09-29 13:45         ` Yao Qi
2013-09-29 18:51           ` Pedro Alves
2013-09-29 23:00             ` Pierre Muller
2013-09-30  9:38               ` Pedro Alves
2013-09-30 12:33               ` Yao Qi
2013-10-01 19:42               ` Keith Seitz
     [not found]             ` <10148.9390749068$1380495630@news.gmane.org>
2013-09-29 23:54               ` asmwarrior
2013-09-30 19:23               ` Tom Tromey
2013-09-30 19:34                 ` Eli Zaretskii
2013-09-30 19:45                   ` Pedro Alves
2013-09-30 22:41                     ` Pierre Muller
     [not found] ` <11813.6176527061$1380225854@news.gmane.org>
2013-09-27 15:13   ` [RFC 5/6] Handle "set print sevenbit-strings on" in print_wchar Tom Tromey
2013-09-27 15:23     ` Pierre Muller
     [not found] ` <9177.88728042996$1380225912@news.gmane.org>
2013-11-06 21:50   ` [RFC 6/6] Fix remaining failures in gdb.base/printcmds.exp for mingw hosts Tom Tromey
     [not found] <"002901cebaf2$35ec65a0$a1c530e0$@muller"@ics-cnrs.unistra.fr>
     [not found] ` <"003201cebaf3$338a8b60$9a9fa220$@muller"@ics-cnrs.unistra.fr>
2013-09-26 20:08   ` [RFC 3/6] mingw-hdep: Add "maint set testuite-mode on/off" command Eli Zaretskii
2013-09-26 20:13     ` Pierre Muller
     [not found]     ` <"003e01cebaf4$e97923e0$bc6b6ba0$@muller"@ics-cnrs.unistra.fr>
2013-09-27  5:52       ` Eli Zaretskii
2013-09-27  6:53         ` Pierre Muller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001201cebea4$700a4bc0$501ee340$@muller@ics-cnrs.unistra.fr' \
    --to=pierre.muller@ics-cnrs.unistra.fr \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox