From 96c07c5b96e970c93ab71a1f351ca669bba78d1a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 25 Sep 2009 21:39:53 +0000 Subject: gdb PR python/10664: * language.h (struct language_defn) : Add 'char_type' argument. (LA_GET_STRING): Likewise. (default_get_string, c_get_string): Update. * language.c (default_get_string): Add 'char_type' argument. * c-valprint.c (c_textual_element_type): Rename from textual_element_type. No longer static. Update callers. * c-lang.h (c_textual_element_type): Declare. * c-lang.c (c_get_string): Add 'char_type' argument. gdb/testsuite PR python/10664: * gdb.base/charset.exp: Test utf-16 strings with Python. --- gdb/c-lang.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'gdb/c-lang.c') diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 64258de..405c489 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -618,7 +618,7 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string, void c_get_string (struct value *value, gdb_byte **buffer, int *length, - const char **charset) + struct type **char_type, const char **charset) { int err, width; unsigned int fetchlimit; @@ -626,6 +626,7 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length, struct type *element_type = TYPE_TARGET_TYPE (type); int req_length = *length; enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); + enum c_string_type kind; if (element_type == NULL) goto error; @@ -652,13 +653,11 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length, /* We work only with arrays and pointers. */ goto error; - element_type = check_typedef (element_type); - if (TYPE_CODE (element_type) != TYPE_CODE_INT - && TYPE_CODE (element_type) != TYPE_CODE_CHAR) - /* If the elements are not integers or characters, we don't consider it - a string. */ + if (! c_textual_element_type (element_type, 0)) goto error; - + kind = classify_type (element_type, + gdbarch_byte_order (get_type_arch (element_type)), + charset); width = TYPE_LENGTH (element_type); /* If the string lives in GDB's memory instead of the inferior's, then we @@ -717,7 +716,7 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length, if (*length != 0) *length = *length / width; - *charset = target_charset (); + *char_type = element_type; return; -- cgit v1.1