* [PATCH] Use UTF-32 as the wide charset for 64-bit
@ 2026-10-15 13:47 Aditya Vidyadhar Kamath
2026-10-15 14:05 ` Tom Tromey
2026-10-19 16:04 ` Tom Tromey
0 siblings, 2 replies; 5+ messages in thread
From: Aditya Vidyadhar Kamath @ 2026-10-15 13:47 UTC (permalink / raw)
To: ulrich.weigand, simon.marchi, tom
Cc: gdb-patches, Aditya.Kamath1, sangamesh.swamy, Aditya Vidyadhar Kamath
From: Aditya Vidyadhar Kamath <aditya.kamath1@ibm.com>
On AIX, wchar_t is 4 bytes in 64-bit mode and 2 bytes in 32-bit mode,
and rs6000_aix_init_osabi sets wchar_bit accordingly. The
auto_wide_charset method however always returned "UTF-16", so a 64-bit
inferior's wide strings were decoded as 2-byte units. This printed
L'\000\000a' for L'a', and GDB crashed with SIGSEGV on the following
print in gdb.base/wchar.exp.
Return "UTF-32" for 64-bit and keep "UTF-16" for 32-bit. wchar.exp now
passes in 64-bit mode.
---
gdb/rs6000-aix-tdep.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index d823fea5645..a80caa9dc18 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -1052,14 +1052,22 @@ rs6000_software_single_step (struct regcache *regcache)
return next_pcs;
}
-/* Implement the "auto_wide_charset" gdbarch method for this platform. */
+/* Implement the "auto_wide_charset" gdbarch method for this platform.
+ wchar_t is 2 bytes in 32-bit mode and 4 bytes in 64-bit mode, see
+ the set_gdbarch_wchar_bit calls in rs6000_aix_init_osabi. */
static const char *
-rs6000_aix_auto_wide_charset (void)
+rs6000_aix_auto_wide_charset_32 (void)
{
return "UTF-16";
}
+static const char *
+rs6000_aix_auto_wide_charset_64 (void)
+{
+ return "UTF-32";
+}
+
/* Implement an osabi sniffer for RS6000/AIX.
This function assumes that ABFD's flavour is XCOFF. In other words,
@@ -1404,11 +1412,18 @@ rs6000_aix_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_frame_red_zone_size (gdbarch, 288);
if (tdep->wordsize == 8)
- set_gdbarch_wchar_bit (gdbarch, 32);
+ {
+ set_gdbarch_wchar_bit (gdbarch, 32);
+ set_gdbarch_auto_wide_charset (gdbarch,
+ rs6000_aix_auto_wide_charset_64);
+ }
else
- set_gdbarch_wchar_bit (gdbarch, 16);
+ {
+ set_gdbarch_wchar_bit (gdbarch, 16);
+ set_gdbarch_auto_wide_charset (gdbarch,
+ rs6000_aix_auto_wide_charset_32);
+ }
set_gdbarch_wchar_signed (gdbarch, false);
- set_gdbarch_auto_wide_charset (gdbarch, rs6000_aix_auto_wide_charset);
set_gdbarch_make_solib_ops (gdbarch, make_aix_solib_ops);
frame_unwind_append_unwinder (gdbarch, &aix_sighandle_frame_unwind);
--
2.51.2
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] Use UTF-32 as the wide charset for 64-bit
2026-10-15 13:47 [PATCH] Use UTF-32 as the wide charset for 64-bit Aditya Vidyadhar Kamath
@ 2026-10-15 14:05 ` Tom Tromey
2026-10-16 12:02 ` Aditya Kamath
2026-10-19 16:04 ` Tom Tromey
1 sibling, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2026-10-15 14:05 UTC (permalink / raw)
To: Aditya Vidyadhar Kamath
Cc: ulrich.weigand, simon.marchi, tom, gdb-patches, Aditya.Kamath1,
sangamesh.swamy
>>>>> Aditya Vidyadhar Kamath <akamath996@gmail.com> writes:
> This printed
> L'\000\000a' for L'a', and GDB crashed with SIGSEGV on the following
> print in gdb.base/wchar.exp.
Does this mean if the user sets the wide charset they can provoke a gdb
crash? If so that seems like a bug worth fixing.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] Use UTF-32 as the wide charset for 64-bit
2026-10-15 14:05 ` Tom Tromey
@ 2026-10-16 12:02 ` Aditya Kamath
0 siblings, 0 replies; 5+ messages in thread
From: Aditya Kamath @ 2026-10-16 12:02 UTC (permalink / raw)
To: Tom Tromey, Aditya Vidyadhar Kamath
Cc: Ulrich Weigand, simon.marchi, tom, gdb-patches, SANGAMESH MALLAYYA
[-- Attachment #1: Type: text/plain, Size: 600 bytes --]
Hi Tom and community members,
>>>>> Aditya Vidyadhar Kamath <akamath996@gmail.com> writes:
>> This printed
>> L'\000\000a' for L'a', and GDB crashed with SIGSEGV on the following
>> print in gdb.base/wchar.exp.
>Does this mean if the user sets the wide charset they can provoke a gdb
>crash? If so that seems like a bug worth fixing.
Yes we do get a crash. Thanks for asking. I am sending you another proposed patch to fix that. So now we have two patches. One this one related to AIX and the other related to the question you asked.
Have a nice day ahead.
Regards,
Aditya.
[-- Attachment #2: Type: text/html, Size: 1676 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Use UTF-32 as the wide charset for 64-bit
2026-10-15 13:47 [PATCH] Use UTF-32 as the wide charset for 64-bit Aditya Vidyadhar Kamath
2026-10-15 14:05 ` Tom Tromey
@ 2026-10-19 16:04 ` Tom Tromey
2026-10-21 6:32 ` Aditya Kamath
1 sibling, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2026-10-19 16:04 UTC (permalink / raw)
To: Aditya Vidyadhar Kamath
Cc: ulrich.weigand, simon.marchi, tom, gdb-patches, Aditya.Kamath1,
sangamesh.swamy
>>>>> Aditya Vidyadhar Kamath <akamath996@gmail.com> writes:
> From: Aditya Vidyadhar Kamath <aditya.kamath1@ibm.com>
> On AIX, wchar_t is 4 bytes in 64-bit mode and 2 bytes in 32-bit mode,
> and rs6000_aix_init_osabi sets wchar_bit accordingly. The
> auto_wide_charset method however always returned "UTF-16", so a 64-bit
> inferior's wide strings were decoded as 2-byte units. This printed
> L'\000\000a' for L'a', and GDB crashed with SIGSEGV on the following
> print in gdb.base/wchar.exp.
> Return "UTF-32" for 64-bit and keep "UTF-16" for 32-bit. wchar.exp now
> passes in 64-bit mode.
Thanks for the patch.
> static const char *
> -rs6000_aix_auto_wide_charset (void)
> +rs6000_aix_auto_wide_charset_32 (void)
Could you remove the 'void' here?
> +static const char *
> +rs6000_aix_auto_wide_charset_64 (void)
Here too?
'void' is only needed here for C, it's an anachronism in the gdb code,
so when touching one of these lines it's nice to remove it; and not to
add new instances.
Ok with this change.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] Use UTF-32 as the wide charset for 64-bit
2026-10-19 16:04 ` Tom Tromey
@ 2026-10-21 6:32 ` Aditya Kamath
0 siblings, 0 replies; 5+ messages in thread
From: Aditya Kamath @ 2026-10-21 6:32 UTC (permalink / raw)
To: Tom Tromey, Aditya Vidyadhar Kamath
Cc: Ulrich Weigand, simon.marchi, tom, gdb-patches, SANGAMESH MALLAYYA
[-- Attachment #1: Type: text/plain, Size: 617 bytes --]
Hi Tom and community members,
>> static const char *
>> -rs6000_aix_auto_wide_charset (void)
>> +rs6000_aix_auto_wide_charset_32 (void)
>Could you remove the 'void' here?
>> +static const char *
>> +rs6000_aix_auto_wide_charset_64 (void)
>Here too?
>'void' is only needed here for C, it's an anachronism in the gdb code,
>so when touching one of these lines it's nice to remove it; and not to
>add new instances.
Thanks for the review, Tom. Pushed with this change.
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=6fd421ad78bcb259f371394498e2c1346380e5b7
Regards,
Aditya
[-- Attachment #2: Type: text/html, Size: 1913 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-21 6:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15 13:47 [PATCH] Use UTF-32 as the wide charset for 64-bit Aditya Vidyadhar Kamath
2026-10-15 14:05 ` Tom Tromey
2026-10-16 12:02 ` Aditya Kamath
2026-10-19 16:04 ` Tom Tromey
2026-10-21 6:32 ` Aditya Kamath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox