This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, testsuite] check for UTF-32 target wide charset support in gdb.base/wchar.exp


Sandra Loosemore <sandra@codesourcery.com> writes:
> This patch is related to the one I posted yesterday to make
> with_target_charset do something reasonable in the absence of ICONV
> support:
>
> https://sourceware.org/ml/gdb-patches/2015-09/msg00357.html
>
> If GDB is configured without ICONV support, the target wide charset
> defaults to "ISO-8859-1" (which isn't even a wide charset), and all
> the wide strings in this test print as gibberish.  Otherwise, GDB
> seems to think the default is "auto; currently UTF-32", so let's make
> the dependency on UTF-32 explicit here and bail out if it's not
> available.
>
> OK to commit?
>
> -Sandra
>
>
> 2015-09-16  Sandra Loosemore  <sandra@codesourcery.com>
>
> 	gdb/testsuite/
> 	* gdb.base/wchar.exp: Require UTF-32 target wide charset support,
> 	otherwise skip this test.
>
> diff --git a/gdb/testsuite/gdb.base/wchar.exp b/gdb/testsuite/gdb.base/wchar.exp
> index 1a5a2d4..171385b 100644
> --- a/gdb/testsuite/gdb.base/wchar.exp
> +++ b/gdb/testsuite/gdb.base/wchar.exp
> @@ -24,6 +24,19 @@ if ![runto "wchar.c:$bp_location" ] then {
>    return -1
>  }
>  
> +# This test requires wide character support in GDB.
> +# Setting the charset may fail if GDB was configured without
> +# ICONV support.
> +gdb_test_multiple "set target-wide-charset UTF-32" "" {
> +    -re "Undefined item.*$gdb_prompt " {
> +	unsupported "Unknown charset UTF-32"
> +	return -1
> +    }
> +    -re ".*$gdb_prompt " {
> +	pass "set target-wide-charset UTF-32"
> +    }
> +}
> +
>  gdb_test "print narrow" "= 97 L'a'"
>  
>  gdb_test "print single" "= 48879 L'\\\\xbeef'"

Yeah, the default for the !iconv case doesn't seem right:

#ifdef PHONY_ICONV

/* Provide a phony iconv that does as little as possible.  Also,
   arrange for there to be a single available character set.  */

#undef GDB_DEFAULT_HOST_CHARSET
#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
#define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
#define GDB_DEFAULT_TARGET_WIDE_CHARSET "ISO-8859-1" <<<<

How reasonable is it to enhance the PHONY_ICONV support so that
it handles this better?
I see it already tries to provide some minimal functionality:

static iconv_t
phony_iconv_open (const char *to, const char *from)
{
  /* We allow conversions from UTF-32BE, wchar_t, and the host charset.
     We allow conversions to wchar_t and the host charset.  */
  if (strcmp (from, "UTF-32BE") && strcmp (from, "wchar_t")
      && strcmp (from, GDB_DEFAULT_HOST_CHARSET))
    return -1;
  if (strcmp (to, "wchar_t") && strcmp (to, GDB_DEFAULT_HOST_CHARSET))
    return -1;

  /* Return 1 if we are converting from UTF-32BE, 0 otherwise.  This is
     used as a flag in calls to iconv.  */
  return !strcmp (from, "UTF-32BE");
}

I don't know, off hand, why big endian is supported and not little endian.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]