From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19005 invoked by alias); 1 Oct 2008 15:28:02 -0000 Received: (qmail 18992 invoked by uid 22791); 1 Oct 2008 15:28:01 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 01 Oct 2008 15:27:26 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id m91FRLQQ011598; Wed, 1 Oct 2008 11:27:21 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m91FRKVJ024634; Wed, 1 Oct 2008 11:27:20 -0400 Received: from opsy.redhat.com (vpn-10-132.bos.redhat.com [10.16.10.132]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id m91FRJMQ019637; Wed, 1 Oct 2008 11:27:20 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 36BE53785CF; Wed, 1 Oct 2008 09:25:58 -0600 (MDT) To: "Yifan Wang" Cc: gdb@sourceware.org Subject: Re: gdb support for wide char References: From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom Date: Wed, 01 Oct 2008 15:28:00 -0000 In-Reply-To: (Yifan Wang's message of "Wed\, 1 Oct 2008 12\:28\:36 +0200") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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/msg00006.txt.bz2 >>>>> "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