This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Printing of strings with special characters


Hello Tom,

it doesn't work with charset UTF-32:

here is my test code:
-------------------------------------------------------
std::string strTest = "höhöhö";
const char* szTest = "höhöhö";
--------------------------------------------------------

my gdbinit:
---------------------------------------------------------
set target-charset UTF-32
set target-wide-charset UTF-32
set print pretty off
set print sevenbit-strings off
set print object on
---------------------------------------------------------

gdb console input/output:
---------------------------------------------------------------------------------------------------------
show print sevenbit-strings
Printing of 8-bit characters in strings as \nnn is on.  // <----------this is weird

set print sevenbit-strings off
show print sevenbit-strings
Printing of 8-bit characters in strings as \nnn is off.
print strTest
$2 = {static npos = 4294967295, _M_dataplus = {<std::allocator<char>> ={<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No datafields>}, _M_p = 0x935dcd4 "\150\366\150", <incomplete sequence\366\150\366>}}
print szTest
$3 = 0x88db03a "\150\366\150", <incomplete sequence \366\150\366>
---------------------------------------------------------------------------------------------------------

UTF-16 doesn't work too.

best regards




Tom Tromey schrieb:

>>>>>> >>>>>> "Anton" == Anton Kunze <ak@technosis.de> writes:
>>>>>> >>>>>>             
>>>>>>             
> >
> > Anton> i'am using gdb 7.0.1 with python and pretty printing on suse linux. If I
> > Anton> try to print string with german special characters I get only strings as
> > Anton> '\nnn'.
> >
> > Anton> My gdbinit file contains following:
> > Anton> set charset ISO-8859-1
> > Anton> set target-wide-charset ISO-8859-1
> >
> > This is almost certainly wrong.  You probably want `set
> > target-wide-charset UTF-32' -- which is the default on Linux.  At least,
> > that will be what you want if your code is using wchar_t.
> >
> > Also, I recommend against using "set charset"; use target-charset
> > instead.  'set charset' sets the host charset in addition to the target
> > charset, but on systems with a decent locale implementation, you
> > basically will always want to use the result reported by the locale.
> >
> > Anton> sys.path.insert(0, '/home/anton/projects/debug/printers')
> >
> > Without the source to this we can't be completely sure about the
> > problem.
> >
> > Anton> Within my debug session I use the following commonds on gdb console:
> >
> > Anton> set print sevenbit-strings off
> > Anton> print qsHtml
> > Anton> $4 = "h\366h\366h\366"
> >
> > What type is a qsHtml?  Specifically, what is the underlying character
> > type it uses?
> >
> > Tom
> >
> >
> >   
>   




Tom Tromey schrieb:
>>>>>> "Anton" == Anton Kunze <ak@technosis.de> writes:
>>>>>>             
>
> Anton> i'am using gdb 7.0.1 with python and pretty printing on suse linux. If I
> Anton> try to print string with german special characters I get only strings as
> Anton> '\nnn'.
>
> Anton> My gdbinit file contains following:
> Anton> set charset ISO-8859-1
> Anton> set target-wide-charset ISO-8859-1
>
> This is almost certainly wrong.  You probably want `set
> target-wide-charset UTF-32' -- which is the default on Linux.  At least,
> that will be what you want if your code is using wchar_t.
>
> Also, I recommend against using "set charset"; use target-charset
> instead.  'set charset' sets the host charset in addition to the target
> charset, but on systems with a decent locale implementation, you
> basically will always want to use the result reported by the locale.
>
> Anton> sys.path.insert(0, '/home/anton/projects/debug/printers')
>
> Without the source to this we can't be completely sure about the
> problem.
>
> Anton> Within my debug session I use the following commonds on gdb console:
>
> Anton> set print sevenbit-strings off
> Anton> print qsHtml
> Anton> $4 = "h\366h\366h\366"
>
> What type is a qsHtml?  Specifically, what is the underlying character
> type it uses?
>
> Tom
>
>
>   


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]