From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1191 invoked by alias); 13 Oct 2008 08:56:32 -0000 Received: (qmail 1183 invoked by uid 22791); 13 Oct 2008 08:56:31 -0000 X-Spam-Check-By: sourceware.org Received: from rv-out-0708.google.com (HELO rv-out-0708.google.com) (209.85.198.247) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 13 Oct 2008 08:55:54 +0000 Received: by rv-out-0708.google.com with SMTP id b17so1502892rvf.48 for ; Mon, 13 Oct 2008 01:55:52 -0700 (PDT) Received: by 10.140.226.13 with SMTP id y13mr3544726rvg.2.1223888152412; Mon, 13 Oct 2008 01:55:52 -0700 (PDT) Received: by 10.140.174.17 with HTTP; Mon, 13 Oct 2008 01:55:52 -0700 (PDT) Message-ID: Date: Mon, 13 Oct 2008 08:56:00 -0000 From: "Yifan Wang" To: tromey@redhat.com Subject: Re: gdb support for wide char Cc: gdb@sourceware.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-10/txt/msg00054.txt.bz2 Thanks Tom. I already have wrote a patch to make c/c++ support fixed length characters(u8, u16, u32). and now i am working on utf8 which is not fixed length character. The solution rely on the glibc functions, eg.mbstowcs(), iconv(), to support wide character. I dont know whether this solution is good enough, because it does not support other programming language and it rely on the glibc functions. Regards Yifan 2008/10/1 Tom Tromey : >>>>>> "Yifan" == Yifan Wang writes: > > Yifan> in gdb, i usually use "p" or "x /s" to print strings in my > Yifan> program. But the problem is, when i write some program for > Yifan> non-english user, i usually use utf-8 or utf-16 strings. gdb > Yifan> can not print those string properly. so i want to write a > Yifan> patch to gdb so that gdb can support printing utf strings. > > Yifan> I am not familar with the gdb source files, can someone give > Yifan> some ideas about where i should start and which part of the > Yifan> source files cover the topic? Any hints or ideas are great > > gdb has an idea about the host and target charsets. Unfortunately it > does not understand very many encodings. > > You could start by looking at charset.c. I think it needs an API > overhaul to work with "more complicated" character set encodings, > though offhand I don't recall whether UTF-8 fits into that category. > > If you are on a system with a nice iconv (anything using glibc at > least), you could make charset.c handle just about anything. This > would let you do: > > set target-charset UTF-8 > print str > > If your host isn't using glibc, I would suggest investigating the use > of libiconv, rather than continuing down the current path of > charset.c. > > There are actually a few other missing features in this area. I think > gdb should probably also have a "wide target charset", for programs > using wchar_t. And, with the new UTF strings stuff in GCC, perhaps a > "/u" format to "p" would be appropriate. > > Tom >