diff options
author | Michael Snyder <msnyder@vmware.com> | 2001-11-15 01:55:59 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 2001-11-15 01:55:59 +0000 |
commit | 47663de5984a7cf5eff8c8780cdf093aa9629a64 (patch) | |
tree | b868003a2f140dfddb88e63e9574324cdbcd1663 /gdb/c-typeprint.c | |
parent | 73d074b4e2c7e9a3954d0b08f048ebccd6c3e671 (diff) | |
download | gdb-47663de5984a7cf5eff8c8780cdf093aa9629a64.zip gdb-47663de5984a7cf5eff8c8780cdf093aa9629a64.tar.gz gdb-47663de5984a7cf5eff8c8780cdf093aa9629a64.tar.bz2 |
2001-11-14 Michael Snyder <msnyder@redhat.com>
Add address space identifiers to expression language for types.
* c-exp.y (space_identifier, cv_with_space_id,
const_or_volatile_or_space_identifier_noopt,
const_or_volatile_or_space_identifier): New terminals.
(ptype): Accept const_or_volatile_or_space_identifier.
(typebase): Accept const_or_volatile_or_space_identifier.
* c-typeprint.c (c_type_print_cv_qualifier): Rename to
c_type_print_modifier. Handle address space modified types.
* gdbtypes.h (TYPE_FLAG_CODE_SPACE, TYPE_FLAG_DATA_SPACE):
New type flags.
(struct type): Add new field as_type for addr-space qualified types.
(TYPE_AS_TYPE): New macro, retrieves the chain of types that are
identical to this one except for address-space qualification.
* gdbtypes.c (alloc_type): Initialize new field 'as_type'.
(address_space_name_to_int): New function.
(address_space_int_to_name): New function.
(make_type_with_address_space): New function.
(make_cv_type): Handle as_type field of new struct type object.
* parse.c (check_type_stack_depth): New function.
(push_type_address_space): New function.
(follow_types): Handle types with address-space qualifier.
* parser-defs.h (enum type_pieces): Add enum tp_space_identifier.
Diffstat (limited to 'gdb/c-typeprint.c')
-rw-r--r-- | gdb/c-typeprint.c | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 789d5f0..c830029 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -52,8 +52,9 @@ static void cp_type_print_derivation_info (struct ui_file *, struct type *); void c_type_print_varspec_prefix (struct type *, struct ui_file *, int, int); -static void c_type_print_cv_qualifier (struct type *, struct ui_file *, - int, int); +/* Print "const", "volatile", or address space modifiers. */ +static void c_type_print_modifier (struct type *, struct ui_file *, + int, int); @@ -211,7 +212,7 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream, case TYPE_CODE_PTR: c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1); fprintf_filtered (stream, "*"); - c_type_print_cv_qualifier (type, stream, 1, 0); + c_type_print_modifier (type, stream, 1, 0); break; case TYPE_CODE_MEMBER: @@ -242,7 +243,7 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream, case TYPE_CODE_REF: c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1); fprintf_filtered (stream, "&"); - c_type_print_cv_qualifier (type, stream, 1, 0); + c_type_print_modifier (type, stream, 1, 0); break; case TYPE_CODE_FUNC: @@ -289,10 +290,11 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream, NEED_SPACE = 1 indicates an initial white space is needed */ static void -c_type_print_cv_qualifier (struct type *type, struct ui_file *stream, - int need_pre_space, int need_post_space) +c_type_print_modifier (struct type *type, struct ui_file *stream, + int need_pre_space, int need_post_space) { - int flag = 0; + int did_print_modifier = 0; + char *address_space_id; /* We don't print `const' qualifiers for references --- since all operators affect the thing referenced, not the reference itself, @@ -303,18 +305,27 @@ c_type_print_cv_qualifier (struct type *type, struct ui_file *stream, if (need_pre_space) fprintf_filtered (stream, " "); fprintf_filtered (stream, "const"); - flag = 1; + did_print_modifier = 1; } if (TYPE_VOLATILE (type)) { - if (flag || need_pre_space) + if (did_print_modifier || need_pre_space) fprintf_filtered (stream, " "); fprintf_filtered (stream, "volatile"); - flag = 1; + did_print_modifier = 1; } - if (flag && need_post_space) + address_space_id = address_space_int_to_name (TYPE_FLAGS (type)); + if (address_space_id) + { + if (did_print_modifier || need_pre_space) + fprintf_filtered (stream, " "); + fprintf_filtered (stream, "@%s", address_space_id); + did_print_modifier = 1; + } + + if (did_print_modifier && need_post_space) fprintf_filtered (stream, " "); } @@ -655,7 +666,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show, if (show <= 0 && TYPE_NAME (type) != NULL) { - c_type_print_cv_qualifier (type, stream, 0, 1); + c_type_print_modifier (type, stream, 0, 1); fputs_filtered (TYPE_NAME (type), stream); return; } @@ -675,7 +686,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show, break; case TYPE_CODE_STRUCT: - c_type_print_cv_qualifier (type, stream, 0, 1); + c_type_print_modifier (type, stream, 0, 1); /* Note TYPE_CODE_STRUCT and TYPE_CODE_CLASS have the same value, * so we use another means for distinguishing them. */ @@ -708,7 +719,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show, goto struct_union; case TYPE_CODE_UNION: - c_type_print_cv_qualifier (type, stream, 0, 1); + c_type_print_modifier (type, stream, 0, 1); fprintf_filtered (stream, "union "); struct_union: @@ -1023,7 +1034,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show, break; case TYPE_CODE_ENUM: - c_type_print_cv_qualifier (type, stream, 0, 1); + c_type_print_modifier (type, stream, 0, 1); /* HP C supports sized enums */ if (hp_som_som_object_present) switch (TYPE_LENGTH (type)) @@ -1104,7 +1115,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show, template <class T1, class T2> class " and then merges with the struct/union/class code to print the rest of the definition. */ - c_type_print_cv_qualifier (type, stream, 0, 1); + c_type_print_modifier (type, stream, 0, 1); fprintf_filtered (stream, "template <"); for (i = 0; i < TYPE_NTEMPLATE_ARGS (type); i++) { @@ -1139,7 +1150,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show, is no type name, then complain. */ if (TYPE_NAME (type) != NULL) { - c_type_print_cv_qualifier (type, stream, 0, 1); + c_type_print_modifier (type, stream, 0, 1); fputs_filtered (TYPE_NAME (type), stream); } else |