From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28535 invoked by alias); 12 Jun 2014 17:23:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 28516 invoked by uid 89); 12 Jun 2014 17:23:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Jun 2014 17:23:43 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5CHNaiX012253 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jun 2014 13:23:36 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5CHNYtO005351; Thu, 12 Jun 2014 13:23:35 -0400 Message-ID: <5399E216.1090601@redhat.com> Date: Thu, 12 Jun 2014 17:23:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Yao Qi CC: Tom Tromey , Joel Brobecker , gdb-patches@sourceware.org Subject: Re: [ping] [PATCH] Different outputs affected by locale References: <1401192650-29688-1-git-send-email-yao@codesourcery.com> <538EAEE5.2080708@codesourcery.com> <20140604124708.GR4289@adacore.com> <538F1CC3.9090605@codesourcery.com> <87oay8a0t6.fsf@fleche.redhat.com> <538F803A.9020007@redhat.com> <538FE412.1050806@codesourcery.com> <53903119.6000204@redhat.com> <53903EE5.8090107@codesourcery.com> <539042A2.4050409@redhat.com> <539571C6.40605@codesourcery.com> <53958862.5020106@redhat.com> <5397BCEC.8080300@codesourcery.com> <539990BD.9020504@redhat.com> <5399BB32.5050409@codesourcery.com> In-Reply-To: <5399BB32.5050409@codesourcery.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-06/txt/msg00513.txt.bz2 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