aboutsummaryrefslogtreecommitdiff
path: root/gdb/printcmd.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-09-05 00:51:49 +0000
committerDaniel Jacobowitz <drow@false.org>2007-09-05 00:51:49 +0000
commitea37ba09261f349ac2748da0d4f8f513184776f9 (patch)
treee809a75cbee45334e9521254235524a6394f406c /gdb/printcmd.c
parentfcd776e5474bde02e7555b33ef57905eae0f7d3e (diff)
downloadgdb-ea37ba09261f349ac2748da0d4f8f513184776f9.zip
gdb-ea37ba09261f349ac2748da0d4f8f513184776f9.tar.gz
gdb-ea37ba09261f349ac2748da0d4f8f513184776f9.tar.bz2
* NEWS: Update description of string changes. Mention print/s.
* c-valprint.c (textual_element_type): New. (c_val_print): Use it. Do not skip address printing for pointers with a string format. (c_value_print): Doc update. * dwarf2read.c (read_array_type): Use make_vector_type. * gdbtypes.c (make_vector_type): New. (init_vector_type): Use it. (gdbtypes_post_init): Initialize builtin_true_unsigned_char. (_initialize_gdbtypes): Mark int8_t and uint8_t as TYPE_FLAG_NOTTEXT. * gdbtypes.h (struct builtin_type): Add builtin_true_unsigned_char. (TYPE_FLAG_NOTTEXT, TYPE_NOTTEXT): New. (make_vector_type): New. * printcmd.c (print_formatted): Only handle 's' and 'i' for examine. Call the language print routine for string format. (print_scalar_formatted): Call val_print for string format. Handle unsigned original types for char format. (validate_format): Do not reject string format. * stabsread.c (read_type): Use make_vector_type. * xml-tdesc.c (tdesc_start_vector): Use init_vector_type. * gdb.texinfo (Output Formats): Update 'c' description. Describe 's'. (Examining Memory): Update mentions of the 's' format. (Automatic Display): Likewise. * gdb.arch/i386-sse.exp: Do not expect character constants. * gdb.base/charsign.c, gdb.base/charsign.exp: Delete. * gdb.base/display.exp: Allow print/s. * gdb.base/printcmds.exp, gdb.base/setvar.exp: Revert signed and unsigned char array changes.
Diffstat (limited to 'gdb/printcmd.c')
-rw-r--r--gdb/printcmd.c95
1 files changed, 55 insertions, 40 deletions
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 019a4a6..04cfd77 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -250,7 +250,8 @@ decode_format (char **string_ptr, int oformat, int osize)
Do not end with a newline.
0 means print VAL according to its own type.
SIZE is the letter for the size of datum being printed.
- This is used to pad hex numbers so they line up. */
+ This is used to pad hex numbers so they line up. SIZE is 0
+ for print / output and set for examine. */
static void
print_formatted (struct value *val, int format, int size,
@@ -262,45 +263,41 @@ print_formatted (struct value *val, int format, int size,
if (VALUE_LVAL (val) == lval_memory)
next_address = VALUE_ADDRESS (val) + len;
- switch (format)
+ if (size)
{
- case 's':
- /* FIXME: Need to handle wchar_t's here... */
- next_address = VALUE_ADDRESS (val)
- + val_print_string (VALUE_ADDRESS (val), -1, 1, stream);
- break;
-
- case 'i':
- /* The old comment says
- "Force output out, print_insn not using _filtered".
- I'm not completely sure what that means, I suspect most print_insn
- now do use _filtered, so I guess it's obsolete.
- --Yes, it does filter now, and so this is obsolete. -JB */
-
- /* We often wrap here if there are long symbolic names. */
- wrap_here (" ");
- next_address = (VALUE_ADDRESS (val)
- + gdb_print_insn (VALUE_ADDRESS (val), stream,
- &branch_delay_insns));
- break;
+ switch (format)
+ {
+ case 's':
+ /* FIXME: Need to handle wchar_t's here... */
+ next_address = VALUE_ADDRESS (val)
+ + val_print_string (VALUE_ADDRESS (val), -1, 1, stream);
+ return;
- default:
- if (format == 0
- || TYPE_CODE (type) == TYPE_CODE_ARRAY
- || TYPE_CODE (type) == TYPE_CODE_STRING
- || TYPE_CODE (type) == TYPE_CODE_STRUCT
- || TYPE_CODE (type) == TYPE_CODE_UNION
- || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
- /* If format is 0, use the 'natural' format for that type of
- value. If the type is non-scalar, we have to use language
- rules to print it as a series of scalars. */
- value_print (val, stream, format, Val_pretty_default);
- else
- /* User specified format, so don't look to the the type to
- tell us what to do. */
- print_scalar_formatted (value_contents (val), type,
- format, size, stream);
+ case 'i':
+ /* We often wrap here if there are long symbolic names. */
+ wrap_here (" ");
+ next_address = (VALUE_ADDRESS (val)
+ + gdb_print_insn (VALUE_ADDRESS (val), stream,
+ &branch_delay_insns));
+ return;
+ }
}
+
+ if (format == 0 || format == 's'
+ || TYPE_CODE (type) == TYPE_CODE_ARRAY
+ || TYPE_CODE (type) == TYPE_CODE_STRING
+ || TYPE_CODE (type) == TYPE_CODE_STRUCT
+ || TYPE_CODE (type) == TYPE_CODE_UNION
+ || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
+ /* If format is 0, use the 'natural' format for that type of
+ value. If the type is non-scalar, we have to use language
+ rules to print it as a series of scalars. */
+ value_print (val, stream, format, Val_pretty_default);
+ else
+ /* User specified format, so don't look to the the type to
+ tell us what to do. */
+ print_scalar_formatted (value_contents (val), type,
+ format, size, stream);
}
/* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
@@ -317,6 +314,15 @@ print_scalar_formatted (const void *valaddr, struct type *type,
LONGEST val_long = 0;
unsigned int len = TYPE_LENGTH (type);
+ /* If we get here with a string format, try again without it. Go
+ all the way back to the language printers, which may call us
+ again. */
+ if (format == 's')
+ {
+ val_print (type, valaddr, 0, 0, stream, 0, 0, 0, Val_pretty_default);
+ return;
+ }
+
if (len > sizeof(LONGEST) &&
(TYPE_CODE (type) == TYPE_CODE_INT
|| TYPE_CODE (type) == TYPE_CODE_ENUM))
@@ -407,8 +413,17 @@ print_scalar_formatted (const void *valaddr, struct type *type,
break;
case 'c':
- value_print (value_from_longest (builtin_type_true_char, val_long),
- stream, 0, Val_pretty_default);
+ if (TYPE_UNSIGNED (type))
+ {
+ struct type *utype;
+
+ utype = builtin_type (current_gdbarch)->builtin_true_unsigned_char;
+ value_print (value_from_longest (utype, val_long),
+ stream, 0, Val_pretty_default);
+ }
+ else
+ value_print (value_from_longest (builtin_type_true_char, val_long),
+ stream, 0, Val_pretty_default);
break;
case 'f':
@@ -809,7 +824,7 @@ validate_format (struct format_data fmt, char *cmdname)
if (fmt.count != 1)
error (_("Item count other than 1 is meaningless in \"%s\" command."),
cmdname);
- if (fmt.format == 'i' || fmt.format == 's')
+ if (fmt.format == 'i')
error (_("Format letter \"%c\" is meaningless in \"%s\" command."),
fmt.format, cmdname);
}