]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Fix printing strings on macOS Sonoma
authorCiaran Woodward <ciaranwoodward@xmos.com>
Mon, 10 Jun 2024 15:52:37 +0000 (16:52 +0100)
committerCiaran Woodward <ciaranwoodward@xmos.com>
Wed, 12 Jun 2024 10:20:36 +0000 (11:20 +0100)
commitf41400ee71f8cfa40b4fb784cbba231394b9c698
tree48102537f0a5bed615e9bf25d40abfa87e0f8fa1
parent0c7da7665fcb0edbb330c8ac25eaaaac3bb9d06a
Fix printing strings on macOS Sonoma

On macOS sonoma, printing a string would only print the first
character. For instance, if there was a 'const char *s = "foobar"',
then the 'print s' command would print '$1 = "f"' rather than the
expected '$1 = "foobar"'.

It seems that this is due to Apple silently replacing the version
of libiconv they ship with the OS to one which silently fails to
handle the 'outbytesleft' parameter correctly when using 'wchar_t'
as a target encoding.

This specifically causes issues when using iterating through a
string as wchar_iterator does.

This bug is visible even if you build for an old version of macOS,
but then run on Sonoma. Therefore this fix in the code applies
generally to macOS, and not specific to building on Sonoma. Building
for an older version and expecting forwards compatibility is a
common situation on macOS.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31853
Approved-By: Tom Tromey <tom@tromey.com>
(cherry picked from commit bb2981798f54e6eb30e46fb11cda2ca49561ffd3)
gdb/gdb_wchar.h