* 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 ****
This commit is contained in:
parent
7d9f0c54d6
commit
c4413e2c9b
16 changed files with 303 additions and 137 deletions
123
gdb/gdbtypes.c
123
gdb/gdbtypes.c
|
@ -32,6 +32,28 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||
#include "demangle.h"
|
||||
#include "complaints.h"
|
||||
|
||||
/* These variables point to the objects
|
||||
representing the predefined C data types. */
|
||||
|
||||
struct type *builtin_type_void;
|
||||
struct type *builtin_type_char;
|
||||
struct type *builtin_type_short;
|
||||
struct type *builtin_type_int;
|
||||
struct type *builtin_type_long;
|
||||
struct type *builtin_type_long_long;
|
||||
struct type *builtin_type_signed_char;
|
||||
struct type *builtin_type_unsigned_char;
|
||||
struct type *builtin_type_unsigned_short;
|
||||
struct type *builtin_type_unsigned_int;
|
||||
struct type *builtin_type_unsigned_long;
|
||||
struct type *builtin_type_unsigned_long_long;
|
||||
struct type *builtin_type_float;
|
||||
struct type *builtin_type_double;
|
||||
struct type *builtin_type_long_double;
|
||||
struct type *builtin_type_complex;
|
||||
struct type *builtin_type_double_complex;
|
||||
struct type *builtin_type_string;
|
||||
|
||||
/* Alloc a new type structure and fill it with some defaults. If
|
||||
OBJFILE is non-NULL, then allocate the space for the type structure
|
||||
in that objfile's type_obstack. */
|
||||
|
@ -370,6 +392,26 @@ create_array_type (result_type, element_type, range_type)
|
|||
return (result_type);
|
||||
}
|
||||
|
||||
/* Create a string type using either a blank type supplied in RESULT_TYPE,
|
||||
or creating a new type. String types are similar enough to array of
|
||||
char types that we can use create_array_type to build the basic type
|
||||
and then bash it into a string type.
|
||||
|
||||
For fixed length strings, the range type contains 0 as the lower
|
||||
bound and the length of the string minus one as the upper bound.
|
||||
|
||||
FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
|
||||
sure it is TYPE_CODE_UNDEF before we bash it into a string type? */
|
||||
|
||||
struct type *
|
||||
create_string_type (result_type, range_type)
|
||||
struct type *result_type;
|
||||
struct type *range_type;
|
||||
{
|
||||
result_type = create_array_type (result_type, builtin_type_char, range_type);
|
||||
TYPE_CODE (result_type) = TYPE_CODE_STRING;
|
||||
return (result_type);
|
||||
}
|
||||
|
||||
/* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE.
|
||||
A MEMBER is a wierd thing -- it amounts to a typed offset into
|
||||
|
@ -1188,8 +1230,8 @@ recursive_dump_type (type, spaces)
|
|||
case TYPE_CODE_RANGE:
|
||||
printf_filtered ("(TYPE_CODE_RANGE)");
|
||||
break;
|
||||
case TYPE_CODE_PASCAL_ARRAY:
|
||||
printf_filtered ("(TYPE_CODE_PASCAL_ARRAY)");
|
||||
case TYPE_CODE_STRING:
|
||||
printf_filtered ("(TYPE_CODE_STRING)");
|
||||
break;
|
||||
case TYPE_CODE_ERROR:
|
||||
printf_filtered ("(TYPE_CODE_ERROR)");
|
||||
|
@ -1297,3 +1339,80 @@ recursive_dump_type (type, spaces)
|
|||
}
|
||||
|
||||
#endif /* MAINTENANCE_CMDS */
|
||||
|
||||
void
|
||||
_initialize_gdbtypes ()
|
||||
{
|
||||
builtin_type_void =
|
||||
init_type (TYPE_CODE_VOID, 1,
|
||||
0,
|
||||
"void", (struct objfile *) NULL);
|
||||
builtin_type_char =
|
||||
init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
||||
0,
|
||||
"char", (struct objfile *) NULL);
|
||||
builtin_type_signed_char =
|
||||
init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
||||
TYPE_FLAG_SIGNED,
|
||||
"signed char", (struct objfile *) NULL);
|
||||
builtin_type_unsigned_char =
|
||||
init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
||||
TYPE_FLAG_UNSIGNED,
|
||||
"unsigned char", (struct objfile *) NULL);
|
||||
builtin_type_short =
|
||||
init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
|
||||
0,
|
||||
"short", (struct objfile *) NULL);
|
||||
builtin_type_unsigned_short =
|
||||
init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
|
||||
TYPE_FLAG_UNSIGNED,
|
||||
"unsigned short", (struct objfile *) NULL);
|
||||
builtin_type_int =
|
||||
init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
|
||||
0,
|
||||
"int", (struct objfile *) NULL);
|
||||
builtin_type_unsigned_int =
|
||||
init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
|
||||
TYPE_FLAG_UNSIGNED,
|
||||
"unsigned int", (struct objfile *) NULL);
|
||||
builtin_type_long =
|
||||
init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
|
||||
0,
|
||||
"long", (struct objfile *) NULL);
|
||||
builtin_type_unsigned_long =
|
||||
init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
|
||||
TYPE_FLAG_UNSIGNED,
|
||||
"unsigned long", (struct objfile *) NULL);
|
||||
builtin_type_long_long =
|
||||
init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
|
||||
0,
|
||||
"long long", (struct objfile *) NULL);
|
||||
builtin_type_unsigned_long_long =
|
||||
init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
|
||||
TYPE_FLAG_UNSIGNED,
|
||||
"unsigned long long", (struct objfile *) NULL);
|
||||
builtin_type_float =
|
||||
init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
|
||||
0,
|
||||
"float", (struct objfile *) NULL);
|
||||
builtin_type_double =
|
||||
init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
|
||||
0,
|
||||
"double", (struct objfile *) NULL);
|
||||
builtin_type_long_double =
|
||||
init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
|
||||
0,
|
||||
"long double", (struct objfile *) NULL);
|
||||
builtin_type_complex =
|
||||
init_type (TYPE_CODE_FLT, TARGET_COMPLEX_BIT / TARGET_CHAR_BIT,
|
||||
0,
|
||||
"complex", (struct objfile *) NULL);
|
||||
builtin_type_double_complex =
|
||||
init_type (TYPE_CODE_FLT, TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT,
|
||||
0,
|
||||
"double complex", (struct objfile *) NULL);
|
||||
builtin_type_string =
|
||||
init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
||||
0,
|
||||
"string", (struct objfile *) NULL);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue