gdb
2010-03-05 Corinna Vinschen <vinschen@redhat.com> Tom Tromey <tromey@redhat.com> * utils.c (host_char_to_target): Add 'gdbarch' argument. (parse_escape): Likewise. * python/py-utils.c (unicode_to_target_string): Update. (unicode_to_target_python_string): Update. (target_string_to_unicode): Update. * printcmd.c (printf_command): Update. * p-exp.y (yylex): Update. * objc-exp.y (yylex): Update. * mi/mi-parse.c: Include charset.h. (mi_parse_escape): New function. (mi_parse_argv): Use it. * jv-exp.y (yylex): Update. * i386-cygwin-tdep.c (i386_cygwin_auto_wide_charset): New function. (i386_cygwin_init_abi): Call set_gdbarch_auto_wide_charset. * gdbarch.sh (auto_charset, auto_wide_charset): New. * gdbarch.c: Rebuild. * gdbarch.h: Rebuild. * defs.h (parse_escape): Update. * cli/cli-setshow.c: Include arch-utils.h. (do_setshow_command): Update. * cli/cli-cmds.c (echo_command): Update. * charset.h (target_charset, target_wide_charset): Update. * charset.c: Include arch-utils.h. (target_charset_name): Default to "auto". (target_wide_charset_name): Likewise. (show_target_charset_name): Handle "auto". (show_target_wide_charset_name): Likewise. (be_le_arch): New global. (set_be_le_names): Add 'gdbarch' argument. (validate): Likewise. Don't call set_be_le_names. (set_charset_sfunc, set_host_charset_sfunc) (set_target_charset_sfunc, set_target_wide_charset_sfunc): Update. (target_charset): Add 'gdbarch' argument. (target_wide_charset): Likewise. Remove 'byte_order' argument. (auto_target_charset_name): New global. (default_auto_charset, default_auto_wide_charset): New functions. (_initialize_charset): Set auto_target_charset_name. Allow "auto" for target charsets. Copy result of nl_langinfo. Use GetACP if USE_WIN32API. * c-lang.c (charset_for_string_type): Add 'gdbarch' argument, remove 'byte_order' argument. Update. (classify_type): Likewise. (c_emit_char): Update. (c_printchar): Update. (c_printstr): Update. (c_get_string): Update. (evaluate_subexp_c): Update. * arch-utils.h (default_auto_charset, default_auto_wide_charset): Declare. * python/python.c (gdbpy_target_charset): New function. (gdbpy_target_wide_charset): Likewise. (GdbMethods): Update. * NEWS: Update. gdb/doc * gdb.texinfo (Basic Python): Document target_charset and target_wide_charset. gdb/testsuite * gdb.python/py-prettyprint.py (pp_nullstr.to_string): Use gdb.target_charset. (pp_ns.to_string): Likewise.
This commit is contained in:
parent
78e2826bcc
commit
f870a310ee
25 changed files with 397 additions and 72 deletions
27
gdb/c-lang.c
27
gdb/c-lang.c
|
@ -43,23 +43,23 @@ extern void _initialize_c_language (void);
|
|||
|
||||
static const char *
|
||||
charset_for_string_type (enum c_string_type str_type,
|
||||
enum bfd_endian byte_order)
|
||||
struct gdbarch *gdbarch)
|
||||
{
|
||||
switch (str_type & ~C_CHAR)
|
||||
{
|
||||
case C_STRING:
|
||||
return target_charset ();
|
||||
return target_charset (gdbarch);
|
||||
case C_WIDE_STRING:
|
||||
return target_wide_charset (byte_order);
|
||||
return target_wide_charset (gdbarch);
|
||||
case C_STRING_16:
|
||||
/* FIXME: UTF-16 is not always correct. */
|
||||
if (byte_order == BFD_ENDIAN_BIG)
|
||||
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
|
||||
return "UTF-16BE";
|
||||
else
|
||||
return "UTF-16LE";
|
||||
case C_STRING_32:
|
||||
/* FIXME: UTF-32 is not always correct. */
|
||||
if (byte_order == BFD_ENDIAN_BIG)
|
||||
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
|
||||
return "UTF-32BE";
|
||||
else
|
||||
return "UTF-32LE";
|
||||
|
@ -73,7 +73,7 @@ charset_for_string_type (enum c_string_type str_type,
|
|||
characters of this type in target BYTE_ORDER to the host character set. */
|
||||
|
||||
static enum c_string_type
|
||||
classify_type (struct type *elttype, enum bfd_endian byte_order,
|
||||
classify_type (struct type *elttype, struct gdbarch *gdbarch,
|
||||
const char **encoding)
|
||||
{
|
||||
struct type *saved_type;
|
||||
|
@ -134,7 +134,7 @@ classify_type (struct type *elttype, enum bfd_endian byte_order,
|
|||
|
||||
done:
|
||||
if (encoding)
|
||||
*encoding = charset_for_string_type (result, byte_order);
|
||||
*encoding = charset_for_string_type (result, gdbarch);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ c_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
|
|||
struct wchar_iterator *iter;
|
||||
int need_escape = 0;
|
||||
|
||||
classify_type (type, byte_order, &encoding);
|
||||
classify_type (type, get_type_arch (type), &encoding);
|
||||
|
||||
buf = alloca (TYPE_LENGTH (type));
|
||||
pack_long (buf, type, c);
|
||||
|
@ -340,7 +340,7 @@ c_printchar (int c, struct type *type, struct ui_file *stream)
|
|||
{
|
||||
enum c_string_type str_type;
|
||||
|
||||
str_type = classify_type (type, BFD_ENDIAN_UNKNOWN, NULL);
|
||||
str_type = classify_type (type, get_type_arch (type), NULL);
|
||||
switch (str_type)
|
||||
{
|
||||
case C_CHAR:
|
||||
|
@ -396,7 +396,8 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
|
|||
width, byte_order) == 0))
|
||||
length--;
|
||||
|
||||
str_type = classify_type (type, byte_order, &type_encoding) & ~C_CHAR;
|
||||
str_type = (classify_type (type, get_type_arch (type), &type_encoding)
|
||||
& ~C_CHAR);
|
||||
switch (str_type)
|
||||
{
|
||||
case C_STRING:
|
||||
|
@ -659,7 +660,7 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
|
|||
if (! c_textual_element_type (element_type, 0))
|
||||
goto error;
|
||||
kind = classify_type (element_type,
|
||||
gdbarch_byte_order (get_type_arch (element_type)),
|
||||
get_type_arch (element_type),
|
||||
charset);
|
||||
width = TYPE_LENGTH (element_type);
|
||||
|
||||
|
@ -942,7 +943,6 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
|
|||
struct value *result;
|
||||
enum c_string_type dest_type;
|
||||
const char *dest_charset;
|
||||
enum bfd_endian byte_order;
|
||||
|
||||
obstack_init (&output);
|
||||
cleanup = make_cleanup_obstack_free (&output);
|
||||
|
@ -979,8 +979,7 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
|
|||
/* Ensure TYPE_LENGTH is valid for TYPE. */
|
||||
check_typedef (type);
|
||||
|
||||
byte_order = gdbarch_byte_order (exp->gdbarch);
|
||||
dest_charset = charset_for_string_type (dest_type, byte_order);
|
||||
dest_charset = charset_for_string_type (dest_type, exp->gdbarch);
|
||||
|
||||
++*pos;
|
||||
while (*pos < limit)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue