From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3867 invoked by alias); 1 Oct 2013 08:02:50 -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 3854 invoked by uid 89); 1 Oct 2013 08:02:50 -0000 Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.222.214) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Oct 2013 08:02:50 +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 E66231A0E80; Tue, 1 Oct 2013 10:02:44 +0200 (CEST) Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antivirus (Postfix) with ESMTP id D55F01A0EA9; Tue, 1 Oct 2013 10:02:43 +0200 (CEST) Received: from md13.u-strasbg.fr (md13.u-strasbg.fr [130.79.200.248]) by mr4.u-strasbg.fr (Postfix) with ESMTP id AC2FE1A0EBC; Tue, 1 Oct 2013 10:02:41 +0200 (CEST) Received: from ms12.u-strasbg.fr (ms12.u-strasbg.fr [130.79.204.112]) by md13.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id r9182fCS019175 ; Tue, 1 Oct 2013 10:02:41 +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 ms12.u-strasbg.fr (Postfix) with ESMTPSA id E2BC91FD92; Tue, 1 Oct 2013 10:02:39 +0200 (CEST) From: "Pierre Muller" To: "'Keith Seitz'" Cc: "'gdb-patches'" References: <002901cebaf2$35ec65a0$a1c530e0$@muller@ics-cnrs.unistra.fr> <002c01cebaf2$89798ea0$9c6cabe0$@muller@ics-cnrs.unistra.fr> <524A230B.5020304@redhat.com> In-Reply-To: <524A230B.5020304@redhat.com> Subject: [RFC 1/6 -V2] Fix display of tabulation character for mingw hosts. Date: Tue, 01 Oct 2013 08:02:00 -0000 Message-ID: <001501cebe7c$990fba50$cb2f2ef0$@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/msg00011.txt.bz2 Hi Keith, Thanks a lot for this review. > -----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 1/6] Fix display of tabulation character for mingw hos= ts. >=20 > On 09/26/2013 12:56 PM, Pierre Muller wrote: > > 2013-09-26 Pierre Muller > > > > Fix display of tabulation character for mingw hosts. > ^^^^^ > Probably want to keep this a little formal and use "MinGW". =20=20 =20 > > * gdb_wchar.h (gdb_iswprint): Declare as external function > > if __MINGW32__ macro is set. > > * mingw-hdep.c (gdb_iswprint): New function. >=20 > 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=3Di686-unknown-linux > --target=3D--host=3Di686-pc-mingw32: >=20 > ../../gdb/gdb/mingw-hdep.c:88:5: error: 'isprint' redeclared without > dllimport attribute: previous dllimport ignored [-Werror=3Dattributes] 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. =20 > 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: >=20 > #define gdb_iswprint isprint >=20 > > +/* Mingw specific version of iswprint to correct >=20 > "MinGW-specific" Whoops, I hadn't noticed that this was always capitalized like that... =20 > > + 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 =3D=3D LCST ('\t') ? 0 : iswprint (wc); > > +} >=20 > 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... =20 > 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 =3D 9 '\t' 290-(gdb) PASS: gdb.base/printcmds.exp: p ctable1[9] 291-p ctable1[10] 292-$51 =3D 10 '\n' -- 1869-$560 =3D (unsigned char *) "\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 =3D (unsigned char *) "\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 =3D (unsigned char *) "\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 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; =20 #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; } =20 +#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 =3D=3D 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. */ =20 --=20 1.7.9