public inbox for gdb-patches@sourceware.org
 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: [RFC 1/6 -V2] Fix display of tabulation character for mingw hosts.
Date: Tue, 01 Oct 2013 08:02:00 -0000	[thread overview]
Message-ID: <001501cebe7c$990fba50$cb2f2ef0$@muller@ics-cnrs.unistra.fr> (raw)
In-Reply-To: <524A230B.5020304@redhat.com>

  Hi Keith,

  Thanks a lot for this review.

> -----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 1/6] Fix display of tabulation character for mingw hosts.
> 
> On 09/26/2013 12:56 PM, Pierre Muller wrote:
> > 2013-09-26  Pierre Muller  <muller@sourceware.org>
> >
> > 	Fix display of tabulation character for mingw hosts.
>                                                  ^^^^^
> Probably want to keep this a little formal and use "MinGW".

  
 
> >   	* gdb_wchar.h (gdb_iswprint): Declare as external function
> >   	if __MINGW32__ macro is set.
> > 	* mingw-hdep.c (gdb_iswprint): New function.
> 
> I think this is a reasonable approach, but it will break builds that
> don't have a working/good iconv (amongst other reasons). I noticed this
> attempting to build --build=i686-unknown-linux
> --target=--host=i686-pc-mingw32:
> 
> ../../gdb/gdb/mingw-hdep.c:88:5: error: 'isprint' redeclared without
> dllimport attribute: previous dllimport ignored [-Werror=attributes]

  Yes, I also noticed this, but too late.
I checked and the msvcvrt DLL function isprint does not return 1 for
tabulation...
So the fix is only needed for the wide char version.

 
> This happens because we end up in the very last section of gdb_wchar.h
> ("If we got here and have wchar_t support, we might be on a system with
> some problem.  So, we just disable everything.") and that does:
> 
> #define gdb_iswprint isprint
> 
>  > +/* Mingw specific version of iswprint to correct
> 
> "MinGW-specific"
  Whoops, I hadn't noticed that this was always capitalized like that...
 
>  > +   difference concerning the tabulation character:
>  > +   msvcrt dll iswprint returns 1 for '\t' while
>  > +   UNIX uiswprint function returns 0 for '\t'.  */
>  > +
>  > +int gdb_iswprint (gdb_wint_t wc)
>     ^^^^^^^^^^^^^^^^^
>  > +{
>  > +  return wc == LCST ('\t') ? 0 : iswprint (wc);
>  > +}
> 
> The return type should be on a line by itself and the function name
> should start in column zero. Also please double-check that there is a
> newline between the closing brace of safe_strerror and the comment for
> this new function. [Maybe your patch got munged a bit?]

  Yes, I must confess that I broke more coding style rules
than I usually do here, sorry about that...

 
> Does this fix the output of many tests in the test suite already? If
> not, it would be really, really nice to have a test to check (and
> demonstrate) this quirk.

It does fix 2 failures inside printcmds.exp

288-p ctable1[9]
289:$50 = 9 '\t'
290-(gdb) PASS: gdb.base/printcmds.exp: p ctable1[9]
291-p ctable1[10]
292-$51 = 10 '\n'
--
1869-$560 = (unsigned char *) <ctable1+1> "\001\002\003\004\005\006\a\b"...
1870-(gdb) PASS: gdb.base/printcmds.exp: p &ctable1[1]
1871-p &ctable1[1*8]
1872:$561 = (unsigned char *) <ctable1+8> "\b\t\n\v\f\r\016\017"...
1873-(gdb) PASS: gdb.base/printcmds.exp: p &ctable1[1*8]
1874-p &ctable1[2*8]
1875-$562 = (unsigned char *) <ctable1+16>
"\020\021\022\023\024\025\026\027"...

Is this enough?

  Here is a new patch version.
To avoid the very complicated preprocessor checks that decides if we
use wide chars inside gdb_wchar.h, I added a new macro
HAVE_MINGW_GDB_ISWPRINT.
  While the idea seems good to me, I am unsure about the choice
of this macro name, are there similar examples already inside the code?



Pierre

ChangeLog entry:

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

 	Fix display of tabulation character for MinGW hosts.
 	* gdb_wchar.h (gdb_iswprint): Declare as external function
 	if __MINGW32__ macro is set.
	(HAVE_MINGW_GDB_ISWPRINT): New macro, declared only for
 	MinGW hosts using wide characters.
 	* mingw-hdep.c (gdb_iswprint): New function.
	Implemented only if HAVE_MINGW_GDB_ISWPRINT macro is defined.

---
 gdb/gdb_wchar.h  |    5 +++++
 gdb/mingw-hdep.c |   13 +++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/gdb/gdb_wchar.h b/gdb/gdb_wchar.h
index 0e785e8..9a07da2 100644
--- a/gdb/gdb_wchar.h
+++ b/gdb/gdb_wchar.h
@@ -65,7 +65,12 @@ typedef wchar_t gdb_wchar_t;
 typedef wint_t gdb_wint_t;
 
 #define gdb_wcslen wcslen
+#ifdef __MINGW32__
+#define HAVE_MINGW_GDB_ISWPRINT
+extern int gdb_iswprint (gdb_wint_t);
+#else
 #define gdb_iswprint iswprint
+#endif
 #define gdb_iswdigit iswdigit
 #define gdb_btowc btowc
 #define gdb_WEOF WEOF
diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c
index efc9848..86d0023 100644
--- a/gdb/mingw-hdep.c
+++ b/gdb/mingw-hdep.c
@@ -81,6 +81,19 @@ safe_strerror (int errnum)
   return buffer;
 }
 
+#ifdef HAVE_MINGW_GDB_ISWPRINT
+/* MinGW-specific version of iswprint to correct
+   difference concerning the tabulation character:
+   msvcrt dll iswprint returns 1 for '\t' while
+   UNIX uiswprint function returns 0 for '\t'.  */
+
+int
+gdb_iswprint (gdb_wint_t wc)
+{
+  return wc == LCST ('\t') ? 0 : iswprint (wc);
+}
+#endif
+
 /* Return an absolute file name of the running GDB, if possible, or
    ARGV0 if not.  The return value is in malloc'ed storage.  */
 
-- 
1.7.9

  reply	other threads:[~2013-10-01  8:02 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 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
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 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     ` Pierre Muller [this message]
2013-10-22 18:24       ` [RFC 1/6 -V2] " 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 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='001501cebe7c$990fba50$cb2f2ef0$@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).