aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-lang.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2009-09-25 21:39:53 +0000
committerTom Tromey <tromey@redhat.com>2009-09-25 21:39:53 +0000
commit96c07c5b96e970c93ab71a1f351ca669bba78d1a (patch)
tree0228be5148273ed3078a199936b4ebf6cb9534d5 /gdb/c-lang.c
parentb8899f2b6861deda28ccc10d925105e7e516d68b (diff)
downloadgdb-96c07c5b96e970c93ab71a1f351ca669bba78d1a.zip
gdb-96c07c5b96e970c93ab71a1f351ca669bba78d1a.tar.gz
gdb-96c07c5b96e970c93ab71a1f351ca669bba78d1a.tar.bz2
gdb
PR python/10664: * language.h (struct language_defn) <la_get_string>: 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.
Diffstat (limited to 'gdb/c-lang.c')
-rw-r--r--gdb/c-lang.c15
1 files changed, 7 insertions, 8 deletions
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;