From: Pedro Alves <palves@redhat.com>
To: Yao Qi <yao@codesourcery.com>
Cc: Tom Tromey <tromey@redhat.com>,
Joel Brobecker <brobecker@adacore.com>,
gdb-patches@sourceware.org
Subject: Re: [ping] [PATCH] Different outputs affected by locale
Date: Thu, 12 Jun 2014 17:23:00 -0000 [thread overview]
Message-ID: <5399E216.1090601@redhat.com> (raw)
In-Reply-To: <5399BB32.5050409@codesourcery.com>
On 06/12/2014 03:37 PM, Yao Qi wrote:
> On 06/12/2014 07:36 PM, Pedro Alves wrote:
>> What does "show host-charset" show on Windows, before and after
>> you make GDB pick LC_CTYPE=C from the environment (with the
>> setlocale gnulib module)?
>
> GDB on Windows gets host charset from GetACP(), in
> charset.c:_initialize_charset ().
>
> #elif defined (USE_WIN32API)
> {
> /* "CP" + x<=5 digits + paranoia. */
> static char w32_host_default_charset[16];
>
> snprintf (w32_host_default_charset, sizeof w32_host_default_charset,
> "CP%d", GetACP());
> auto_host_charset_name = w32_host_default_charset;
> auto_target_charset_name = auto_host_charset_name;
> }
> #endif
>
I note gnulib's nl_langinfo replacement actually does
the same thing.
> GetACP doesn't depend on locale,
Yeah, it's a mess, and those are really different
things. The former is the system locale, while the latter
the user locale. MSDN is confusing, but lots of blogs around
explaining this.
> so I don't think LC_CTYPE=C affects the
> host-charset in GDB. However, I do this:
>
> printf ("%d\n", GetACP());
>
> setlocale (LC_CTYPE, "");
> printf ("%d\n", GetACP());
>
> setlocale (LC_CTYPE, "C");
> printf ("%d\n", GetACP());
>
> On my Windows machine, 1252 is printed three times.
So what I'm thinking is indeed going with making the test
accept the cent, but conditioned, like:
# Fallback to assuming 7-bit ASCII. Test are ran under LC_CTYPE=C.
set cent "\\\\242"
set test "show host-charset"
gdb_test_multiple $test $test {
-re "CP1252\r\n$gdb_prompt $" {
# With Windows code page 1252 (Latin 1), the cent
# is printable.
set cent "\u00A2"
pass $test
}
-re "$gdb_prompt $" {
pass $test
}
}
>
>>
>> (Ideally, the wchar tests would actually iterate testing GDB
>> behaves as expected with different values of LC_CTYPE, etc. set
>> in the environment. With all other tests assuming ASCII as set
>> by default by the testsuite framework.)
>
> On the condition that we know or enumerate the expected output for
> wchars under each LC_CTYPE on different host (or OS). Test like this
> is out of the scope of GDB (or debugger) testing, IMO.
Not an exaustive test, and not by host, but just by picking a couple
charsets/locales. So that we at least ensure that the framework is
all in sync. That is, check:
$ unset LC_CTYPE; gdb -ex "show host-charset" -ex ' p "\u00A2"' --batch
$ LC_CTYPE=XXX gdb -ex "show host-charset" -ex ' p "\u00A2"' --batch
$ LC_CTYPE=en_US gdb -ex "show host-charset" -ex ' p "\u00A2"' --batch
$ LC_CTYPE=en_US.UTF-8 gdb -ex "show host-charset" -ex ' p "\u00A2"' --batch
--
Pedro Alves
next prev parent reply other threads:[~2014-06-12 17:23 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-27 12:13 Yao Qi
2014-06-04 5:32 ` [ping] " Yao Qi
2014-06-04 12:47 ` Joel Brobecker
2014-06-04 13:21 ` Yao Qi
2014-06-04 13:52 ` Joel Brobecker
2014-06-04 20:15 ` Tom Tromey
2014-06-04 20:23 ` Pedro Alves
2014-06-05 3:31 ` Yao Qi
2014-06-05 8:58 ` Pedro Alves
2014-06-05 9:58 ` Yao Qi
2014-06-05 10:12 ` Pedro Alves
2014-06-05 15:04 ` Eli Zaretskii
2014-06-09 8:37 ` Yao Qi
2014-06-09 10:11 ` Pedro Alves
2014-06-11 2:22 ` Yao Qi
2014-06-11 16:23 ` Eli Zaretskii
2014-06-12 0:48 ` Yao Qi
2014-06-12 2:47 ` Eli Zaretskii
2014-06-12 7:04 ` Yao Qi
2014-06-12 17:03 ` Eli Zaretskii
2014-06-17 1:03 ` Yao Qi
2014-06-12 11:36 ` Pedro Alves
2014-06-12 14:39 ` Yao Qi
2014-06-12 17:07 ` Eli Zaretskii
2014-06-12 17:23 ` Pedro Alves [this message]
2014-06-12 17:48 ` Eli Zaretskii
2014-06-17 3:46 ` Yao Qi
2014-06-17 10:03 ` Pedro Alves
2014-06-17 11:39 ` Yao Qi
2014-06-12 17:09 ` Eli Zaretskii
2014-06-12 17:27 ` Pedro Alves
2014-06-12 17:50 ` Eli Zaretskii
2014-06-12 18:06 ` Pedro Alves
2014-06-12 18:35 ` Eli Zaretskii
2014-06-16 13:58 ` Pedro Alves
2014-06-16 15:40 ` Eli Zaretskii
2014-06-16 16:23 ` Pedro Alves
2014-06-05 10:27 ` Pedro Alves
2014-06-05 14:47 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5399E216.1090601@redhat.com \
--to=palves@redhat.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
--cc=yao@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox