From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10176 invoked by alias); 14 Apr 2006 06:02:23 -0000 Received: (qmail 10168 invoked by uid 22791); 14 Apr 2006 06:02:22 -0000 X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 14 Apr 2006 06:02:20 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1FUHNi-0006s7-4p for gdb@sources.redhat.com; Fri, 14 Apr 2006 08:02:10 +0200 Received: from zigzag.lvk.cs.msu.su ([158.250.17.23]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Apr 2006 08:02:10 +0200 Received: from ghost by zigzag.lvk.cs.msu.su with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Apr 2006 08:02:10 +0200 To: gdb@sources.redhat.com From: Vladimir Prus Subject: Re: printing wchar_t* Date: Fri, 14 Apr 2006 07:29:00 -0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit User-Agent: KNode/0.8.2 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00167.txt.bz2 Eli Zaretskii wrote: >> From: Vladimir Prus >> Date: Thu, 13 Apr 2006 20:04:32 +0400 >> >> at the moment, gdb seem to provide no support for printing wchar_t* >> values. It prints them like this: >> >> (gdb) print p15 >> print p15 >> $486 = (wchar_t *) 0x80489f8 >> >> Is there any "standard" way to make gdb automatically traverse wchar_t*, >> printing values, and stopping at '0' value. > > What character set is used by the wide characters in the wchar_t > arrays? GDB has some support for a few single-byte character sets, > see the node "Character Sets" in the manual. Relatively safe bet would be to assume it's some zero-terminated character set. I plan to assume it's either UTF-16 or UTF-32 in the GUI (the conversion code is the same for both encodings), but gdb can just print raw values. >> I have a user-defined command that can produce the output I want, but is >> defining a custom command the right approach? > > It's one possibility, the other one being to call a function in the > debuggee to produce the string. And what such a function will return? char* in local 8-bit encoding? In that case, no all wchar_t* variable can be printed. > Yet another possibility is to do the > conversion in your GUI front end. That's what I'm going to do, but first I need to get raw data, preferrably without issing an MI command for every single character. - Volodya