This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [ping] [PATCH] Different outputs affected by locale
- From: Yao Qi <yao at codesourcery dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Tom Tromey <tromey at redhat dot com>, Joel Brobecker <brobecker at adacore dot com>, <gdb-patches at sourceware dot org>
- Date: Mon, 9 Jun 2014 16:35:18 +0800
- Subject: Re: [ping] [PATCH] Different outputs affected by locale
- Authentication-results: sourceware.org; auth=none
- References: <1401192650-29688-1-git-send-email-yao at codesourcery dot com> <538EAEE5 dot 2080708 at codesourcery dot com> <20140604124708 dot GR4289 at adacore dot com> <538F1CC3 dot 9090605 at codesourcery dot com> <87oay8a0t6 dot fsf at fleche dot redhat dot com> <538F803A dot 9020007 at redhat dot com> <538FE412 dot 1050806 at codesourcery dot com> <53903119 dot 6000204 at redhat dot com> <53903EE5 dot 8090107 at codesourcery dot com> <539042A2 dot 4050409 at redhat dot com>
On 06/05/2014 06:12 PM, Pedro Alves wrote:
> On 06/05/2014 10:56 AM, Yao Qi wrote:
>> On 06/05/2014 04:58 PM, Pedro Alves wrote:
>
>>>>>>> Does testing GDB manually directly on a Windows console show the same
>>>>>>> issue?
>>>>>
>>>>> Yes, here is the output I got on Windows 7 (running gdb.exe in Windows console).
>>>>> However, I didn't investigate why 'Ã' is printed.
>>> But was that with LC_CTYPE set to C?
>>
>> I don't know how check LC_CTYPE on Windows. :(
>
> Try "set", and "set /?".
>
LC_CTYPE isn't set on the Windows machine I am using. set LC_CTYPE=C,
but the output is unchanged.
I dive into locale stuff, and find something more, in
main.c:captured_main, gdb does
#if defined (HAVE_SETLOCALE)
setlocale (LC_CTYPE, "");
#endif
the man page of setlocale says
If locale is "", each part of the locale that should be modified is set
according to the environment variables.
That is why we can pass env var to change gdb's locale.
However, looks setlocale on Windows behaves differently when locale is
"". The msdn about setlocale
<http://msdn.microsoft.com/en-us/library/x99tb11d.aspx> says "If locale
points to an empty string, the locale is the implementation-defined
native environment.", but it doesn't say much on the
"implementation-defined native environment". The following example
in the same page gives me some hints,
setlocale( LC_ALL, "" );
Sets the locale to the default, which is the user-default ANSI code page
obtained from the operating system.
As far as I can see, windows doesn't consider any env var with
setlocale(FOO, ""). If I am correct, we can't set gdb's locale by means
of setting env var, instead, we have to match all the possibilities in
the testcase. WDYT?
--
Yao (éå)