Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* gdb support for wide char
@ 2008-10-01 10:29 Yifan Wang
  2008-10-01 15:28 ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Yifan Wang @ 2008-10-01 10:29 UTC (permalink / raw)
  To: gdb

hi

in gdb, i usually use "p" or "x /s" to print strings in my program.
But the problem is, when i write some program for non-english user,
i usually use utf-8 or utf-16 strings. gdb can not print those string properly.
so i want to write a patch to gdb so that gdb can support printing utf strings.

I am not familar with the gdb source files, can someone give some ideas
about where i should start and which part of the source files cover the topic?
Any hints or ideas are great

Thanks
Yifan


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gdb support for wide char
  2008-10-01 10:29 gdb support for wide char Yifan Wang
@ 2008-10-01 15:28 ` Tom Tromey
  2008-10-13  8:56   ` Yifan Wang
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2008-10-01 15:28 UTC (permalink / raw)
  To: Yifan Wang; +Cc: gdb

>>>>> "Yifan" == Yifan Wang <heavenstar@gmail.com> 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gdb support for wide char
  2008-10-01 15:28 ` Tom Tromey
@ 2008-10-13  8:56   ` Yifan Wang
  2008-10-13 18:48     ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Yifan Wang @ 2008-10-13  8:56 UTC (permalink / raw)
  To: tromey; +Cc: gdb

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 <tromey@redhat.com>:
>>>>>> "Yifan" == Yifan Wang <heavenstar@gmail.com> 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
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gdb support for wide char
  2008-10-13  8:56   ` Yifan Wang
@ 2008-10-13 18:48     ` Tom Tromey
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2008-10-13 18:48 UTC (permalink / raw)
  To: Yifan Wang; +Cc: gdb

>>>>> "Yifan" == Yifan Wang <heavenstar@gmail.com> writes:

Yifan> and now i am working on utf8 which is not fixed length character.
Yifan> The solution rely on the glibc functions, eg.mbstowcs(), iconv(), to
Yifan> support wide character.

Yifan> I dont know whether this solution is good enough, because it
Yifan> does not support other programming language and it rely on the
Yifan> glibc functions.

Is it calling these functions in the inferior?

If so, then I think it would be preferable to use iconv in gdb, and
not call any inferior functions.  This approach has several
advantages: it works with core files, it works with other languages,
and (due to the existence of libiconv) it is more portable.

If not, I think I am not understanding something.

Tom


^ permalink raw reply	[flat|nested] 5+ messages in thread

* re: gdb support for wide char
       [not found] <1224016294.17588.ezmlm@sourceware.org>
@ 2008-10-15  0:14 ` Duane Ellis
  0 siblings, 0 replies; 5+ messages in thread
From: Duane Ellis @ 2008-10-15  0:14 UTC (permalink / raw)
  To: gdb

Yifan> and now i am working on utf8 which is not fixed length character.
Yifan> The solution rely on the glibc functions, eg.mbstowcs(), iconv(), to
Yifan> support wide character.

Yifan> I dont know whether this solution is good enough, because it
Yifan> does not support other programming language and it rely on the
Yifan> glibc functions.

tom> Is it calling these functions in the inferior?

I would hope not - because many inferiors *DO*NOT* have those functions.

Examples:

1)    Embedded systems. There are countless ones out there.

2)   Or - when you are debugging on Host (A) talking to Host (B) which 
is a vastly different operating system.

The solution must be 100% self contained within GDB, requiring ZERO 
target support other then raw memory bytes to display.

-Duane.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-10-15  0:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-01 10:29 gdb support for wide char Yifan Wang
2008-10-01 15:28 ` Tom Tromey
2008-10-13  8:56   ` Yifan Wang
2008-10-13 18:48     ` Tom Tromey
     [not found] <1224016294.17588.ezmlm@sourceware.org>
2008-10-15  0:14 ` Duane Ellis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox