This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Import setenv and unsetenv from gnulib
On 07/05/2017 11:32 AM, Anton Kolesov wrote:
>>
>> On 07/04/2017 07:06 PM, Anton Kolesov wrote:
>>> Selftests pass on x86_64-linux. On Windows with this patch there is a
>>> failure in iconv sefltest, which seems unrelated (was present even
>>> when I've tried to use putenv directly instead of importing gnulib module).
>>
>> I take it you meant the s/iconv/gdb_environ/ selftest.
>> Can you show what does "maint selftest" say?
>
> z:\tmp>gdb.exe -ex "mt selftest" -batch
> Self test failed: Converting character sets: No error.
> Ran 11 unit tests, 1 failed
>
> Grepping for "Converting character sets" points to iconv_wrapper in charset.c.
I put a breakpoint on iconv_wrapper::iconv_wrapper, and ran
"mt selftest" on my GNU/Linux machine, and that leads to the Rust unit tests,
from here in rust-exp.y:
convert_between_encodings ("UTF-32", "UTF-8", (gdb_byte *) &value,
sizeof (value), sizeof (value),
&work_obstack, translit_none);
That's "UTF-32" -> "UTF-8".
I guess your build is using the phony iconv, which has (gdb/charset.c):
/* We allow conversions from UTF-32, wchar_t, and the host charset.
We allow conversions to wchar_t and the host charset.
Return 1 if we are converting from UTF-32BE, 2 if from UTF32-LE,
0 otherwise. This is used as a flag in calls to iconv. */
static iconv_t
phony_iconv_open (const char *to, const char *from)
{
if (strcmp (to, "wchar_t") && strcmp (to, GDB_DEFAULT_HOST_CHARSET))
return -1;
if (!strcmp (from, "UTF-32BE") || !strcmp (from, "UTF-32"))
return 1;
if (!strcmp (from, "UTF-32LE"))
return 2;
if (strcmp (from, "wchar_t") && strcmp (from, GDB_DEFAULT_HOST_CHARSET))
return -1;
return 0;
}
With host charset defined as:
#undef GDB_DEFAULT_HOST_CHARSET
#ifdef USE_WIN32API
# define GDB_DEFAULT_HOST_CHARSET "CP1252"
...
#endif
> I'm cross-building with Mingw GCC 4.9.2 from EPEL repositories for CentOS/RHEL 6.
> Maybe some problems with this toolchain or my windows environment.
>
So it looks like for proper Rust support on Windows, we'd either need to
teach the phony iconv about utf-32 -> utf-8 conversion, or you have to
link GDB with the real iconv.
Thanks,
Pedro Alves