public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Different outputs affected by locale
@ 2014-05-27 12:13 Yao Qi
  2014-06-04  5:32 ` [ping] " Yao Qi
  0 siblings, 1 reply; 39+ messages in thread
From: Yao Qi @ 2014-05-27 12:13 UTC (permalink / raw)
  To: gdb-patches

We find the following fails in gdb test on mingw host.

FAIL: gdb.base/wchar.exp: print repeat
FAIL: gdb.base/wchar.exp: print repeat_p
FAIL: gdb.base/wchar.exp: print repeat (print null on)
FAIL: gdb.base/wchar.exp: print repeat (print elements 3)
FAIL: gdb.base/wchar.exp: print repeat_p (print elements 3)

print repeat^M
$7 = L"A", '¢' <repeats 21 times>, "B", '\000' <repeats 104 times>^M
(gdb) FAIL: gdb.base/wchar.exp: print repeat

the \242 is expected in the test but cent sign is displayed.

In valprint.c:print_wchar, wchar_printable is called to determine
whether a wchar is printable.  wchar_printable calls iswprint but
the iswprint's return value depends on LC_CTYPE setting of locale [1, 2].
The output may vary with different locale settings.  I noticed that
gdb.exp:gdb_init set LC_CTYPE to C.  If I remove that line, tests
fail on native testing too.

IMO, either \242 or '¢' (cent sign) is a correct output, which is
affect by locale, and it is not related to gdb at all.

[1] http://pubs.opengroup.org/onlinepubs/009604499/functions/iswprint.html
[2] msdn.microsoft.com/en-us/library/ewx8s4kw.aspx

This patch is to add code to 'p repeat[1]' to extract the cent first,
and then use it to match in the following tests.

gdb/testsuite:

2014-05-27  Yao Qi  <yao@codesourcery.com>

	* gdb.base/wchar.exp: Execute command 'p repeat[1]' and extract
	cent from the output.
---
 gdb/testsuite/gdb.base/wchar.exp | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/wchar.exp b/gdb/testsuite/gdb.base/wchar.exp
index 4290478..215d2f4 100644
--- a/gdb/testsuite/gdb.base/wchar.exp
+++ b/gdb/testsuite/gdb.base/wchar.exp
@@ -36,7 +36,23 @@ gdb_test "print simple\[2\]" "= 99 L'c'"
 
 gdb_test "print difficile\[2\]" "= 65261 L'\\\\xfeed'"
 
-set cent "\\\\242"
+# The contents in 'repeat' are shown differently under different
+# locale.  In stead of hard code the cent sign in variable 'cent',
+# extract it from the output of 'print repeat[1]', and use it to
+# match the output in the following tests.
+set cent ""
+set test "get cent"
+gdb_test_multiple "p repeat\[1\]" $test {
+    -re " = 162 L'(.*)'.*\r\n$gdb_prompt $" {
+	set cent [string_to_regexp $expect_out(1,string)]
+	pass $test
+    }
+    -re ".*$gdb_prompt $" {
+	fail $test
+	return
+    }
+}
+
 gdb_test "print repeat" "= L\"A\", '$cent' <repeats 21 times>, \"B.*"
 
 global hex
-- 
1.9.0

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2014-06-17 11:39 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-27 12:13 [PATCH] Different outputs affected by locale 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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).