From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17269 invoked by alias); 18 Mar 2010 22:08:40 -0000 Received: (qmail 17261 invoked by uid 22791); 18 Mar 2010 22:08:39 -0000 X-SWARE-Spam-Status: No, hits=-7.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Mar 2010 22:08:34 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2IM8Ugb031252 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 18 Mar 2010 18:08:31 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2IM8TS7030030; Thu, 18 Mar 2010 18:08:30 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o2IM8S9U005773; Thu, 18 Mar 2010 18:08:29 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 2DC98379848; Thu, 18 Mar 2010 16:08:27 -0600 (MDT) From: Tom Tromey To: "Pierre Muller" Cc: Subject: Re: [RFC] Allow explicit 16 or 32 char in 'x /s' References: <11484.4708740295$1268865815@news.gmane.org> Reply-To: tromey@redhat.com Date: Thu, 18 Mar 2010 22:08:00 -0000 In-Reply-To: <11484.4708740295$1268865815@news.gmane.org> (Pierre Muller's message of "Wed, 17 Mar 2010 23:42:53 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2010-03/txt/msg00702.txt.bz2 >>>>> "Pierre" == Pierre Muller writes: Pierre> The patch below allows to Pierre> print strings that are made of 16 bit or 32 bit char Pierre> using: Pierre> 'x /hs ' or 'x /ws ' commands. It seems like a good idea to me. Pierre> I tried to enable this feature, keeping it to a minimum: Pierre> The size modifier is not remembered for /s format, Pierre> thus any subsequent use of /s alone will still Pierre> print out byte char strings. If the user types 'x/2hs' and then 'x/2', does the second invocation still print wide strings? I think it should. Pierre> - if (!strcmp (name, "char16_t")) Pierre> + /* Also recognize the type used by 'x /hs' command. */ Pierre> + if (!strcmp (name, "char16_t") Pierre> + || (TYPE_CODE (elttype) == TYPE_CODE_INT Pierre> + && TYPE_LENGTH (elttype) == 2)) Pierre> { Pierre> result = C_CHAR_16; Pierre> goto done; Pierre> } I am a little concerned that this code can confuse the user. If sizeof(wchar_t) == 2, then sometimes you could end up printing a wchar_t using UTF-16 -- which may or may not be appropriate. I'm not sure how much this matters in practice. However, it seems like it may be cleaner to override classify_type's decision based directly on the format character, instead of on the implied type. What do you think of that? This would also let us introduce a new format character meaning "wchar_t". I think the documentation should reflect that the user can't choose the encoding used here. Pierre> + The case of strings is handled n decode_format, only explicit Typo, s/n/in/ Finally, please add some test cases. Tom