[patch] fix phony_iconv wide character support

Sandra Loosemore sandra@codesourcery.com
Thu Dec 31 16:48:00 GMT 2015


A while back I submitted a patch to skip gdb.base/wchar.exp tests when 
GDB is built with PHONY_ICONV enabled:

https://sourceware.org/ml/gdb-patches/2015-09/msg00388.html

The consensus from the discussion seemed to be that it would be better 
to fix the PHONY_ICONV support instead, so that's what this patch does.

I found a whole bunch of bugs in the existing code....

(1) phony_iconv_open had code to recognize "UTF-32BE" as a wide 
character set, but GDB_DEFAULT_TARGET_WIDE_CHARSET was set to 
"ISO-8859-1" instead, so the decoding wasn't getting triggered.

(2) phony_iconv wasn't advancing *inbuf properly after processing each 
4-byte group, plus it wasn't checking for output overflow.  I don't see 
how the old code could ever have worked even if you explicitly chose 
UTF-32BE.

(3) I was doing experiments on a little-endian target (nios2-linux-gnu), 
so I had to extend the conversion code to handle both endiannesses.

(4) On Windows host, the system default (narrow) charset is CP1252 
rather than ISO-8859-1; this affects the behavior of functions like 
isprint, and in particular what is printed for the character constant 
cent ('\242') used in the testcase.  The testcase already checks for 
CP1252 but GDB wasn't reporting the default correctly.

So, my patch fixes all these things and the gdb.base/wchar.exp tests now 
all PASS in this configuration.  OK to commit?

-Sandra

-------------- next part --------------
A non-text attachment was scrubbed...
Name: iconv.log
Type: text/x-log
Size: 533 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20151231/f4cac10d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iconv.patch
Type: text/x-patch
Size: 3646 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20151231/f4cac10d/attachment-0001.bin>


More information about the Gdb-patches mailing list