aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-valprint.c
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1993-01-16 05:15:58 +0000
committerFred Fish <fnf@specifix.com>1993-01-16 05:15:58 +0000
commitc4413e2c9b9e257a93b4370c5e4e976c768b9e9a (patch)
tree2a5d96fdb815d54e5d8d800918fe16e06471d816 /gdb/c-valprint.c
parent7d9f0c54d614f654124963d8e1b48fd884b92f24 (diff)
downloadgdb-c4413e2c9b9e257a93b4370c5e4e976c768b9e9a.zip
gdb-c4413e2c9b9e257a93b4370c5e4e976c768b9e9a.tar.gz
gdb-c4413e2c9b9e257a93b4370c5e4e976c768b9e9a.tar.bz2
* c-exp.y (exp:STRING): Convert C strings into array-of-char
constants with an explicit null byte terminator. OP_STRING is now used for real string types. * c-lang.c (builtin_type_*): Move declarations to lang.c since they are used by all languages. * c-lang.c (_initialize_c_language): Move initializations of builtin_type_* to lang.c. * c-typeprint.c (c_type_print_varspec_prefix, c_type_print_varspec_suffix): TYPE_CODE_PASCAL_ARRAY renamed to TYPE_CODE_STRING. * c-valprint.c (c_val_print): Change the way character arrays are printed as strings to be consistent with the way strings are printed when pointer-to-char types are dereferenced. Remove test of print_max before calling val_print_string, which now does it's own test. * eval.c (evaluate_subexp): Add case for OP_ARRAY. * expprint.c (print_subexp, dump_expression): Add case for OP_ARRAY. * expression.h (enum exp_opcode): Add OP_ARRAY and document. * gdbtypes.c (builtin_type_*): Add declarations moved from c-lang.c. * gdbtypes.c (create_string_type): New function to create real string types. * gdbtypes.c (recursive_dump_type): TYPE_CODE_PASCAL_ARRAY renamed to TYPE_CODE_STRING. * gdbtypes.c (_initialize_gdbtypes): Add initializations of builtin_type_* types moved from c-lang.c. * gdbtypes.h (enum type_code): TYPE_CODE_PASCAL_ARRAY renamed to TYPE_CODE_STRING. * gdbtypes.h (builtin_type_string): Add extern declaration. * gdbtypes.h (create_string_type): Add prototype. * m2-lang.c (m2_create_fundamental_type): TYPE_CODE_PASCAL_ARRAY renamed to TYPE_CODE_STRING. * m88k-tdep.c (pushed_size): TYPE_CODE_PASCAL_ARRAY renamed to TYPE_CODE_STRING. * mipsread.c (_initialize_mipsread): TYPE_CODE_PASCAL_ARRAY renamed to TYPE_CODE_STRING. * parse.c (length_of_subexp, prefixify_subexp): Add case for OP_ARRAY. * printcmd.c (print_formatted): Recognize TYPE_CODE_STRING. * typeprint.c (print_type_scalar): TYPE_CODE_PASCAL_ARRAY renamed to TYPE_CODE_STRING. * valops.c (allocate_space_in_inferior): New function and prototype, using code ripped out of value_string. * valops.c (value_string): Rewritten to use new function allocate_space_in_inferior, but temporarily disabled until some other support is in place. * valops.c (value_array): New function to create array constants. * valprint.c (val_print_string): Add comment to document use, complete rewrite to fix several small buglets. * value.h (value_array): Add prototype. * value.h (val_print_string): Change prototype to match rewrite. **** start-sanitize-chill **** * ch-valprint.c (chill_val_print): Add case for TYPE_CODE_STRING. * ch-exp.y (match_character_literal): Disable recognition of control sequence form of character literals and document why. **** end-sanitize-chill ****
Diffstat (limited to 'gdb/c-valprint.c')
-rw-r--r--gdb/c-valprint.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 4b7da62..2d13db2 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -89,12 +89,13 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
int recurse;
enum val_prettyprint pretty;
{
- register unsigned int i;
+ register unsigned int i = 0; /* Number of characters printed */
unsigned len;
struct type *elttype;
unsigned eltlen;
LONGEST val;
unsigned char c;
+ CORE_ADDR addr;
switch (TYPE_CODE (type))
{
@@ -108,15 +109,19 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
{
print_spaces_filtered (2 + 2 * recurse, stream);
}
- fprintf_filtered (stream, "{");
/* For an array of chars, print with string syntax. */
if (eltlen == 1 && TYPE_CODE (elttype) == TYPE_CODE_INT
- && (format == 0 || format == 's') )
+ && (format == 0 || format == 's'))
{
+ if (addressprint && format != 's')
+ {
+ fprintf_filtered (stream, "0x%x ", address);
+ }
LA_PRINT_STRING (stream, valaddr, len, 0);
}
else
{
+ fprintf_filtered (stream, "{");
/* If this is a virtual function table, print the 0th
entry specially, and the rest of the members normally. */
if (cp_is_vtbl_ptr_type (elttype))
@@ -130,12 +135,13 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
}
val_print_array_elements (type, valaddr, address, stream,
format, deref_ref, recurse, pretty, i);
+ fprintf_filtered (stream, "}");
}
- fprintf_filtered (stream, "}");
break;
}
/* Array of unspecified length: treat like pointer to first elt. */
valaddr = (char *) &address;
+ /* FALL THROUGH */
case TYPE_CODE_PTR:
if (format && format != 's')
@@ -155,7 +161,7 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
}
else
{
- CORE_ADDR addr = unpack_pointer (type, valaddr);
+ addr = unpack_pointer (type, valaddr);
elttype = TYPE_TARGET_TYPE (type);
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
@@ -173,16 +179,12 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
/* For a pointer to char or unsigned char, also print the string
pointed to, unless pointer is null. */
- i = 0; /* Number of characters printed. */
- if (TYPE_LENGTH (elttype) == 1 &&
- TYPE_CODE (elttype) == TYPE_CODE_INT &&
- (format == 0 || format == 's') &&
- addr != 0 &&
- /* If print_max is UINT_MAX, the alloca below will fail.
- In that case don't try to print the string. */
- print_max < UINT_MAX)
+ if (TYPE_LENGTH (elttype) == 1
+ && TYPE_CODE (elttype) == TYPE_CODE_INT
+ && (format == 0 || format == 's')
+ && addr != 0)
{
- i = val_print_string (addr, stream);
+ i = val_print_string (addr, 0, stream);
}
else if (cp_is_vtbl_member(type))
{