aboutsummaryrefslogtreecommitdiff
path: root/gdb/printcmd.c
diff options
context:
space:
mode:
authorPierre Muller <muller@sourceware.org>2010-04-21 23:21:04 +0000
committerPierre Muller <muller@sourceware.org>2010-04-21 23:21:04 +0000
commit9a22f0d0aeec70f4ee1908008f3a2defaad6f7dd (patch)
treea36134950efba04d0c0104c79b7714b47e7e5d49 /gdb/printcmd.c
parent32d7376d07d6b1ae69b5e15d6b546a07f9fee446 (diff)
downloadgdb-9a22f0d0aeec70f4ee1908008f3a2defaad6f7dd.zip
gdb-9a22f0d0aeec70f4ee1908008f3a2defaad6f7dd.tar.gz
gdb-9a22f0d0aeec70f4ee1908008f3a2defaad6f7dd.tar.bz2
gdb ChangeLog
* gdbtypes.h (builtin_type): Add builtin_char16 and builtin_char32 fields. * gdbtypes.c (gdbtypes_post_init): Set builtin_char16 and builtin_char32 fields. * printcmd.c (decode_format): Set char size to '\0' for strings unless explicit size is given. (print_formatted): Correct calculation of NEXT_ADDRESS for 16 or 32 bit strings. (do_examine): Do not force byte size for strings. Use builtin_char16 and builtin_char32 types to display 16 or 32 bit-wide strings. (x_command): Set LAST_SIZE to 'b' for string type. gdb/doc ChangeLog * gdb.texinfo (Examining memory): Update for change in string display with explicit size. gdb/testsuite ChangeLog * gdb.base/charset.c (Strin16, String32): New variables. * gdb.base/charset.exp (gdb_test): Test correct display of 16 or 32 bit strings.
Diffstat (limited to 'gdb/printcmd.c')
-rw-r--r--gdb/printcmd.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index c2468d0..be6a8a5 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -260,6 +260,11 @@ decode_format (char **string_ptr, int oformat, int osize)
/* Characters default to one byte. */
val.size = osize ? 'b' : osize;
break;
+ case 's':
+ /* Display strings with byte size chars unless explicitly specified. */
+ val.size = '\0';
+ break;
+
default:
/* The default is the size most recently specified. */
val.size = osize;
@@ -295,7 +300,7 @@ print_formatted (struct value *val, int size,
next_address = (value_address (val)
+ val_print_string (elttype,
value_address (val), -1,
- stream, options));
+ stream, options) * len);
}
return;
@@ -802,9 +807,11 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
next_gdbarch = gdbarch;
next_address = addr;
- /* String or instruction format implies fetch single bytes
- regardless of the specified size. */
- if (format == 's' || format == 'i')
+ /* Instruction format implies fetch single bytes
+ regardless of the specified size.
+ The case of strings is handled in decode_format, only explicit
+ size operator are not changed to 'b'. */
+ if (format == 'i')
size = 'b';
if (size == 'a')
@@ -831,6 +838,27 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
else if (size == 'g')
val_type = builtin_type (next_gdbarch)->builtin_int64;
+ if (format == 's')
+ {
+ struct type *char_type = NULL;
+ /* Search for "char16_t" or "char32_t" types or fall back to 8-bit char
+ if type is not found. */
+ if (size == 'h')
+ char_type = builtin_type (next_gdbarch)->builtin_char16;
+ else if (size == 'w')
+ char_type = builtin_type (next_gdbarch)->builtin_char32;
+ if (char_type)
+ val_type = char_type;
+ else
+ {
+ if (size != '\0' && size != 'b')
+ warning (_("Unable to display strings with size '%c', using 'b' \
+instead."), size);
+ size = 'b';
+ val_type = builtin_type (next_gdbarch)->builtin_int8;
+ }
+ }
+
maxelts = 8;
if (size == 'w')
maxelts = 4;
@@ -1413,8 +1441,11 @@ x_command (char *exp, int from_tty)
do_examine (fmt, next_gdbarch, next_address);
/* If the examine succeeds, we remember its size and format for next
- time. */
- last_size = fmt.size;
+ time. Set last_size to 'b' for strings. */
+ if (fmt.format == 's')
+ last_size = 'b';
+ else
+ last_size = fmt.size;
last_format = fmt.format;
/* Set a couple of internal variables if appropriate. */