From: Aditya Vidyadhar Kamath <akamath996@gmail.com>
To: ulrich.weigand@de.ibm.com, simon.marchi@polymtl.ca, tom@tromey.com
Cc: gdb-patches@sourceware.org, Aditya.Kamath1@ibm.com,
sangamesh.swamy@in.ibm.com,
Aditya Vidyadhar Kamath <aditya.kamath1@ibm.com>
Subject: [PATCH] Use UTF-32 as the wide charset for 64-bit
Date: Thu, 15 Oct 2026 19:17:23 +0530 [thread overview]
Message-ID: <20261015134722.81702-2-akamath996@gmail.com> (raw)
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
next reply other threads:[~2026-10-15 13:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 13:47 Aditya Vidyadhar Kamath [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261015134722.81702-2-akamath996@gmail.com \
--to=akamath996@gmail.com \
--cc=Aditya.Kamath1@ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=sangamesh.swamy@in.ibm.com \
--cc=simon.marchi@polymtl.ca \
--cc=tom@tromey.com \
--cc=ulrich.weigand@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox