[testsuite] Set target-charset to ascii
Hi,
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-04-17 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.