* [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp
@ 2015-09-17 3:25 Sandra Loosemore
2015-09-17 4:31 ` Doug Evans
2015-09-17 5:07 ` Eli Zaretskii
0 siblings, 2 replies; 10+ messages in thread
From: Sandra Loosemore @ 2015-09-17 3:25 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 576 bytes --]
This patch is related to the one I posted yesterday to make
with_target_charset do something reasonable in the absence of ICONV support:
https://sourceware.org/ml/gdb-patches/2015-09/msg00357.html
If GDB is configured without ICONV support, the target wide charset
defaults to "ISO-8859-1" (which isn't even a wide charset), and all the
wide strings in this test print as gibberish. Otherwise, GDB seems to
think the default is "auto; currently UTF-32", so let's make the
dependency on UTF-32 explicit here and bail out if it's not available.
OK to commit?
-Sandra
[-- Attachment #2: wchar.log --]
[-- Type: text/x-log, Size: 167 bytes --]
2015-09-16 Sandra Loosemore <sandra@codesourcery.com>
gdb/testsuite/
* gdb.base/wchar.exp: Require UTF-32 target wide charset support,
otherwise skip this test.
[-- Attachment #3: wchar.patch --]
[-- Type: text/x-patch, Size: 726 bytes --]
diff --git a/gdb/testsuite/gdb.base/wchar.exp b/gdb/testsuite/gdb.base/wchar.exp
index 1a5a2d4..171385b 100644
--- a/gdb/testsuite/gdb.base/wchar.exp
+++ b/gdb/testsuite/gdb.base/wchar.exp
@@ -24,6 +24,19 @@ if ![runto "wchar.c:$bp_location" ] then {
return -1
}
+# This test requires wide character support in GDB.
+# Setting the charset may fail if GDB was configured without
+# ICONV support.
+gdb_test_multiple "set target-wide-charset UTF-32" "" {
+ -re "Undefined item.*$gdb_prompt " {
+ unsupported "Unknown charset UTF-32"
+ return -1
+ }
+ -re ".*$gdb_prompt " {
+ pass "set target-wide-charset UTF-32"
+ }
+}
+
gdb_test "print narrow" "= 97 L'a'"
gdb_test "print single" "= 48879 L'\\\\xbeef'"
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp
2015-09-17 3:25 [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp Sandra Loosemore
@ 2015-09-17 4:31 ` Doug Evans
2015-09-17 5:10 ` Eli Zaretskii
2015-09-17 5:07 ` Eli Zaretskii
1 sibling, 1 reply; 10+ messages in thread
From: Doug Evans @ 2015-09-17 4:31 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: gdb-patches
Sandra Loosemore <sandra@codesourcery.com> writes:
> This patch is related to the one I posted yesterday to make
> with_target_charset do something reasonable in the absence of ICONV
> support:
>
> https://sourceware.org/ml/gdb-patches/2015-09/msg00357.html
>
> If GDB is configured without ICONV support, the target wide charset
> defaults to "ISO-8859-1" (which isn't even a wide charset), and all
> the wide strings in this test print as gibberish. Otherwise, GDB
> seems to think the default is "auto; currently UTF-32", so let's make
> the dependency on UTF-32 explicit here and bail out if it's not
> available.
>
> OK to commit?
>
> -Sandra
>
>
> 2015-09-16 Sandra Loosemore <sandra@codesourcery.com>
>
> gdb/testsuite/
> * gdb.base/wchar.exp: Require UTF-32 target wide charset support,
> otherwise skip this test.
>
> diff --git a/gdb/testsuite/gdb.base/wchar.exp b/gdb/testsuite/gdb.base/wchar.exp
> index 1a5a2d4..171385b 100644
> --- a/gdb/testsuite/gdb.base/wchar.exp
> +++ b/gdb/testsuite/gdb.base/wchar.exp
> @@ -24,6 +24,19 @@ if ![runto "wchar.c:$bp_location" ] then {
> return -1
> }
>
> +# This test requires wide character support in GDB.
> +# Setting the charset may fail if GDB was configured without
> +# ICONV support.
> +gdb_test_multiple "set target-wide-charset UTF-32" "" {
> + -re "Undefined item.*$gdb_prompt " {
> + unsupported "Unknown charset UTF-32"
> + return -1
> + }
> + -re ".*$gdb_prompt " {
> + pass "set target-wide-charset UTF-32"
> + }
> +}
> +
> gdb_test "print narrow" "= 97 L'a'"
>
> gdb_test "print single" "= 48879 L'\\\\xbeef'"
Yeah, the default for the !iconv case doesn't seem right:
#ifdef PHONY_ICONV
/* Provide a phony iconv that does as little as possible. Also,
arrange for there to be a single available character set. */
#undef GDB_DEFAULT_HOST_CHARSET
#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
#define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
#define GDB_DEFAULT_TARGET_WIDE_CHARSET "ISO-8859-1" <<<<
How reasonable is it to enhance the PHONY_ICONV support so that
it handles this better?
I see it already tries to provide some minimal functionality:
static iconv_t
phony_iconv_open (const char *to, const char *from)
{
/* We allow conversions from UTF-32BE, wchar_t, and the host charset.
We allow conversions to wchar_t and the host charset. */
if (strcmp (from, "UTF-32BE") && strcmp (from, "wchar_t")
&& strcmp (from, GDB_DEFAULT_HOST_CHARSET))
return -1;
if (strcmp (to, "wchar_t") && strcmp (to, GDB_DEFAULT_HOST_CHARSET))
return -1;
/* Return 1 if we are converting from UTF-32BE, 0 otherwise. This is
used as a flag in calls to iconv. */
return !strcmp (from, "UTF-32BE");
}
I don't know, off hand, why big endian is supported and not little endian.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp
2015-09-17 3:25 [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp Sandra Loosemore
2015-09-17 4:31 ` Doug Evans
@ 2015-09-17 5:07 ` Eli Zaretskii
2015-09-17 5:17 ` Sandra Loosemore
2015-09-18 4:41 ` Doug Evans
1 sibling, 2 replies; 10+ messages in thread
From: Eli Zaretskii @ 2015-09-17 5:07 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: gdb-patches
> Date: Wed, 16 Sep 2015 21:24:13 -0600
> From: Sandra Loosemore <sandra@codesourcery.com>
>
> If GDB is configured without ICONV support, the target wide charset
> defaults to "ISO-8859-1" (which isn't even a wide charset), and all the
> wide strings in this test print as gibberish. Otherwise, GDB seems to
> think the default is "auto; currently UTF-32", so let's make the
> dependency on UTF-32 explicit here and bail out if it's not available.
Why UTF-32, hard-coded? Why not allow also UTF-16, for example?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp
2015-09-17 4:31 ` Doug Evans
@ 2015-09-17 5:10 ` Eli Zaretskii
2015-09-18 4:38 ` Doug Evans
0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2015-09-17 5:10 UTC (permalink / raw)
To: Doug Evans; +Cc: sandra, gdb-patches
> From: Doug Evans <xdje42@gmail.com>
> Cc: gdb-patches <gdb-patches@sourceware.org>
> Date: Wed, 16 Sep 2015 21:30:46 -0700
>
> #undef GDB_DEFAULT_HOST_CHARSET
> #define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
> #define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
> #define GDB_DEFAULT_TARGET_WIDE_CHARSET "ISO-8859-1" <<<<
>
> How reasonable is it to enhance the PHONY_ICONV support so that
> it handles this better?
You mean, have functions like strlen and strcat handle 32-bit wchar_t
strings? Not reasonable.
> I see it already tries to provide some minimal functionality:
>
> static iconv_t
> phony_iconv_open (const char *to, const char *from)
> {
> /* We allow conversions from UTF-32BE, wchar_t, and the host charset.
> We allow conversions to wchar_t and the host charset. */
> if (strcmp (from, "UTF-32BE") && strcmp (from, "wchar_t")
> && strcmp (from, GDB_DEFAULT_HOST_CHARSET))
> return -1;
> if (strcmp (to, "wchar_t") && strcmp (to, GDB_DEFAULT_HOST_CHARSET))
> return -1;
>
> /* Return 1 if we are converting from UTF-32BE, 0 otherwise. This is
> used as a flag in calls to iconv. */
> return !strcmp (from, "UTF-32BE");
> }
>
> I don't know, off hand, why big endian is supported and not little endian.
Supported by whom?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp
2015-09-17 5:07 ` Eli Zaretskii
@ 2015-09-17 5:17 ` Sandra Loosemore
2015-09-17 5:59 ` Eli Zaretskii
2015-09-18 4:48 ` Doug Evans
2015-09-18 4:41 ` Doug Evans
1 sibling, 2 replies; 10+ messages in thread
From: Sandra Loosemore @ 2015-09-17 5:17 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
On 09/16/2015 11:07 PM, Eli Zaretskii wrote:
>> Date: Wed, 16 Sep 2015 21:24:13 -0600
>> From: Sandra Loosemore <sandra@codesourcery.com>
>>
>> If GDB is configured without ICONV support, the target wide charset
>> defaults to "ISO-8859-1" (which isn't even a wide charset), and all the
>> wide strings in this test print as gibberish. Otherwise, GDB seems to
>> think the default is "auto; currently UTF-32", so let's make the
>> dependency on UTF-32 explicit here and bail out if it's not available.
>
> Why UTF-32, hard-coded? Why not allow also UTF-16, for example?
It looked to me like the default target wide charset is UTF-32 if you
don't pick one explicitly. Since the test as currently written doesn't,
the patterns the .exp file is trying to match must assume the default
target wide charset, and not some other wide charset that might happen
to be supported.
If I'm confused and the default charset might not always be UTF-32 if
ICONV is present, how about changing the testcase to bail if it sees the
default wide charset is ISO-8859-1? That means either ICONV is not
present or GDB's default is otherwise wrongly configured.
-Sandra
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp
2015-09-17 5:17 ` Sandra Loosemore
@ 2015-09-17 5:59 ` Eli Zaretskii
2015-09-18 4:48 ` Doug Evans
1 sibling, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2015-09-17 5:59 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: gdb-patches
> Date: Wed, 16 Sep 2015 23:16:37 -0600
> From: Sandra Loosemore <sandra@codesourcery.com>
> CC: <gdb-patches@sourceware.org>
>
> If I'm confused and the default charset might not always be UTF-32 if
> ICONV is present, how about changing the testcase to bail if it sees the
> default wide charset is ISO-8859-1? That means either ICONV is not
> present or GDB's default is otherwise wrongly configured.
If the test makes no sense without ICONV, I think it indeed will be
better to skip it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp
2015-09-17 5:10 ` Eli Zaretskii
@ 2015-09-18 4:38 ` Doug Evans
0 siblings, 0 replies; 10+ messages in thread
From: Doug Evans @ 2015-09-18 4:38 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: sandra, gdb-patches
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Doug Evans <xdje42@gmail.com>
>> Cc: gdb-patches <gdb-patches@sourceware.org>
>> Date: Wed, 16 Sep 2015 21:30:46 -0700
>>
>> #undef GDB_DEFAULT_HOST_CHARSET
>> #define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
>> #define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
>> #define GDB_DEFAULT_TARGET_WIDE_CHARSET "ISO-8859-1" <<<<
>>
>> How reasonable is it to enhance the PHONY_ICONV support so that
>> it handles this better?
>
> You mean, have functions like strlen and strcat handle 32-bit wchar_t
> strings? Not reasonable.
Yikes. No, I didn't mean that. :-)
I meant have the PHONY_ICONV case use a better value for
GDB_DEFAULT_TARGET_WIDE_CHARSET.
>> I see it already tries to provide some minimal functionality:
>>
>> static iconv_t
>> phony_iconv_open (const char *to, const char *from)
>> {
>> /* We allow conversions from UTF-32BE, wchar_t, and the host charset.
>> We allow conversions to wchar_t and the host charset. */
>> if (strcmp (from, "UTF-32BE") && strcmp (from, "wchar_t")
>> && strcmp (from, GDB_DEFAULT_HOST_CHARSET))
>> return -1;
>> if (strcmp (to, "wchar_t") && strcmp (to, GDB_DEFAULT_HOST_CHARSET))
>> return -1;
>>
>> /* Return 1 if we are converting from UTF-32BE, 0 otherwise. This is
>> used as a flag in calls to iconv. */
>> return !strcmp (from, "UTF-32BE");
>> }
>>
>> I don't know, off hand, why big endian is supported and not little endian.
>
> Supported by whom?
By PHONY_ICONV.
[which is more of a minimal iconv than a phony iconv, but whatever]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp
2015-09-17 5:07 ` Eli Zaretskii
2015-09-17 5:17 ` Sandra Loosemore
@ 2015-09-18 4:41 ` Doug Evans
1 sibling, 0 replies; 10+ messages in thread
From: Doug Evans @ 2015-09-18 4:41 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Sandra Loosemore, gdb-patches
Eli Zaretskii <eliz@gnu.org> writes:
>> Date: Wed, 16 Sep 2015 21:24:13 -0600
>> From: Sandra Loosemore <sandra@codesourcery.com>
>>
>> If GDB is configured without ICONV support, the target wide charset
>> defaults to "ISO-8859-1" (which isn't even a wide charset), and all the
>> wide strings in this test print as gibberish. Otherwise, GDB seems to
>> think the default is "auto; currently UTF-32", so let's make the
>> dependency on UTF-32 explicit here and bail out if it's not available.
>
> Why UTF-32, hard-coded? Why not allow also UTF-16, for example?
Because this is the case of no iconv support and thus gdb is supplying its own
minimal version. No point in supporting anything unwarranted.
If a compelling case arises for UTF-16 we can cross that bridge
when we get to it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp
2015-09-17 5:17 ` Sandra Loosemore
2015-09-17 5:59 ` Eli Zaretskii
@ 2015-09-18 4:48 ` Doug Evans
2015-09-29 13:50 ` Pedro Alves
1 sibling, 1 reply; 10+ messages in thread
From: Doug Evans @ 2015-09-18 4:48 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: Eli Zaretskii, gdb-patches
Sandra Loosemore <sandra@codesourcery.com> writes:
> On 09/16/2015 11:07 PM, Eli Zaretskii wrote:
>>> Date: Wed, 16 Sep 2015 21:24:13 -0600
>>> From: Sandra Loosemore <sandra@codesourcery.com>
>>>
>>> If GDB is configured without ICONV support, the target wide charset
>>> defaults to "ISO-8859-1" (which isn't even a wide charset), and all the
>>> wide strings in this test print as gibberish. Otherwise, GDB seems to
>>> think the default is "auto; currently UTF-32", so let's make the
>>> dependency on UTF-32 explicit here and bail out if it's not available.
>>
>> Why UTF-32, hard-coded? Why not allow also UTF-16, for example?
>
> It looked to me like the default target wide charset is UTF-32 if you
> don't pick one explicitly. Since the test as currently written
> doesn't, the patterns the .exp file is trying to match must assume the
> default target wide charset, and not some other wide charset that
> might happen to be supported.
>
> If I'm confused and the default charset might not always be UTF-32 if
> ICONV is present, how about changing the testcase to bail if it sees
> the default wide charset is ISO-8859-1? That means either ICONV is
> not present or GDB's default is otherwise wrongly configured.
The question I have is what's the intent behind PHONY_ICONV?
[The fact that it apparently tries to provide some minimal wide char
support but defines GDB_DEFAULT_TARGET_WIDE_CHARSET as "ISO-8859-1"
seems like a bug to me.]
Is it intended that it provide some minimal wide char support?
And if so, my preference would be to keep the test if it's easy.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp
2015-09-18 4:48 ` Doug Evans
@ 2015-09-29 13:50 ` Pedro Alves
0 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2015-09-29 13:50 UTC (permalink / raw)
To: Doug Evans, Sandra Loosemore; +Cc: Eli Zaretskii, gdb-patches
On 09/18/2015 05:47 AM, Doug Evans wrote:
> The question I have is what's the intent behind PHONY_ICONV?
> [The fact that it apparently tries to provide some minimal wide char
> support but defines GDB_DEFAULT_TARGET_WIDE_CHARSET as "ISO-8859-1"
> seems like a bug to me.]
>
> Is it intended that it provide some minimal wide char support?
I recall the feature being submitted and the follow up Solaris fixes,
but I wasn't the one doing the work, so I'm not 100% sure of anything,
but I believe the intention is to punt on wide char support with the least
extra code possible. That seems to be what the original submission
suggests as well:
https://sourceware.org/ml/gdb-patches/2009-01/msg00533.html
https://sourceware.org/ml/gdb-patches/2009-03/msg00420.html
along with the comments in mails around the follow up Solaris fixes:
https://www.sourceware.org/ml/gdb-patches/2010-08/msg00339.html
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-09-29 13:50 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-17 3:25 [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp Sandra Loosemore
2015-09-17 4:31 ` Doug Evans
2015-09-17 5:10 ` Eli Zaretskii
2015-09-18 4:38 ` Doug Evans
2015-09-17 5:07 ` Eli Zaretskii
2015-09-17 5:17 ` Sandra Loosemore
2015-09-17 5:59 ` Eli Zaretskii
2015-09-18 4:48 ` Doug Evans
2015-09-29 13:50 ` Pedro Alves
2015-09-18 4:41 ` Doug Evans
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox