This is the mail archive of the gdb-patches@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: [PATCH] [testsuite] Set target-charset to ascii


On 03/25/2014 09:39 AM, Yao Qi wrote:
> We find gdb.base/printcmds.exp fails a lot on windows host, like this,
> 
>  p ctable1[163]
>  $204 = 163 'Â'
>  (gdb) FAIL: gdb.base/printcmds.exp: p ctable1[163]
> 
> however, on linux host,
> 
>  p ctable1[163]
>  $205 = 163 '\243'
>  (gdb) PASS: gdb.base/printcmds.exp: p ctable1[163]
> 
> The printing related code is in valprint.c:print_wchar,
> 
>   if (gdb_iswprint (w) && (!need_escape || (!gdb_iswdigit (w)
> 					    && w != LCST ('8')
> 					    && w != LCST ('9'))))
>     {
>       gdb_wchar_t wchar = w;
> 
>       if (w == gdb_btowc (quoter) || w == LCST ('\\'))
> 	obstack_grow_wstr (output, LCST ("\\"));
>       obstack_grow (output, &wchar, sizeof (gdb_wchar_t));
>     }
>   else
>    {
>       // print W in hex or octal digits
>    }
> 
> When I debug gdb on different hosts, I find
> on windows host, gdb_iswprint (iswprint) returns true if 'w' is 163.
> However, on linux host, iswprint returns false if 'w' is 163.  Looks
> this difference is caused by the charset.  On Linux host,
> the target-charset is ANSI_X3.4-1968, while on windows host, the
> target-charset is CP1252.
> 
> We can see how target-charset affects the output.  On linux host,
> 
>  (gdb) set target-charset ASCII
>  (gdb) p ctable1[163]
>  $1 = 163 '\243'
>  (gdb) set target-charset CP1252
>  (gdb) p ctable1[163]
>  $2 = 163 'Â'
> 
> we can print the pound sign too, and it shows target-charset does
> affect the output.
> 
> This patch is to set target-charset temporarily to ASCII for some
> charset-sensitive tests.  Tested on arm-none-eabi and
> powerpc-linux-gnu on mingw32 host.  More than one hundred fails are
> fixed.
> 
> gdb/testsuite:
> 
> 2014-03-25  Yao Qi  <yao@codesourcery.com>
> 
> 	* lib/gdb.exp (with_target_charset): New proc.
> 	* gdb.base/printcmds.exp (test_print_all_chars): Wrap tests with
> 	with_target_charset.
> 	(test_print_strings): Likewise.
> 	(test_repeat_bytes): Likewise.
> 	* gdb.base/setvar.exp: Set target-charset to ASCII temporarily
> 	for some tests.

Ping.  https://sourceware.org/ml/gdb-patches/2014-03/msg00589.html

-- 
Yao (éå)


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