case C_WIDE_STRING:
return target_wide_charset (byte_order);
case C_STRING_16:
- /* FIXME: UCS-2 is not always correct. */
+ /* FIXME: UTF-16 is not always correct. */
if (byte_order == BFD_ENDIAN_BIG)
- return "UCS-2BE";
+ return "UTF-16BE";
else
- return "UCS-2LE";
+ return "UTF-16LE";
case C_STRING_32:
- /* FIXME: UCS-4 is not always correct. */
+ /* FIXME: UTF-32 is not always correct. */
if (byte_order == BFD_ENDIAN_BIG)
- return "UCS-4BE";
+ return "UTF-32BE";
else
- return "UCS-4LE";
+ return "UTF-32LE";
}
internal_error (__FILE__, __LINE__, "unhandled c_string_type");
}
single character in isolation. This makes the code simpler
and probably does the sensible thing in the majority of
cases. */
- while (num_chars == 1)
+ while (num_chars == 1 && things_printed < options->print_max)
{
/* Count the number of repetitions. */
unsigned int reps = 0;
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;
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;
/* 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
if (*length != 0)
*length = *length / width;
- *charset = target_charset ();
+ *char_type = element_type;
return;
result >>= 8;
}
- convert_between_encodings ("UCS-4BE", dest_charset, data, 4, 4, output,
+ convert_between_encodings ("UTF-32BE", dest_charset, data, 4, 4, output,
translit_none);
return p;