X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fc-typeprint.c;h=04f8127f2a8cea8f69a327a04611d6c9b31e4fe2;hb=dbc98a8b6eb97ea7315e04103cdfec5add47f3c4;hp=f7a305cead02c7074877162ea9445190dd5996e2;hpb=b1d61bc9d188010bf897f8155a76fb76ab99775f;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index f7a305cead..04f8127f2a 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -33,16 +33,9 @@ #include "typeprint.h" #include "cp-abi.h" #include "jv-lang.h" - #include "gdb_string.h" #include -static void cp_type_print_method_args (struct type *mtype, char *prefix, - char *varstring, int staticp, - struct ui_file *stream); - -static void cp_type_print_derivation_info (struct ui_file *, struct type *); - static void c_type_print_varspec_prefix (struct type *, struct ui_file *, int, int, int); @@ -50,9 +43,6 @@ static void c_type_print_varspec_prefix (struct type *, struct ui_file *, int, static void c_type_print_modifier (struct type *, struct ui_file *, int, int); - - - /* LEVEL is the depth to indent lines by. */ void @@ -229,7 +219,7 @@ cp_type_print_method_args (struct type *mtype, char *prefix, char *varstring, between a trailing qualifier and a field, variable, or function name. */ -void +static void c_type_print_varspec_prefix (struct type *type, struct ui_file *stream, int show, int passed_a_ptr, int need_post_space) { @@ -321,10 +311,12 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream, } } -/* Print out "const" and "volatile" attributes. +/* Print out "const" and "volatile" attributes, + and address space id if present. TYPE is a pointer to the type being printed out. STREAM is the output destination. - NEED_SPACE = 1 indicates an initial white space is needed */ + NEED_PRE_SPACE = 1 indicates an initial white space is needed. + NEED_POST_SPACE = 1 indicates a final white space is needed. */ static void c_type_print_modifier (struct type *type, struct ui_file *stream, @@ -425,11 +417,11 @@ c_type_print_args (struct type *type, struct ui_file *stream, fprintf_filtered (stream, ")"); } - /* Return true iff the j'th overloading of the i'th method of TYPE is a type conversion operator, like `operator int () { ... }'. When listing a class's methods, we don't print the return type of such operators. */ + static int is_type_conversion_operator (struct type *type, int i, int j) { @@ -478,7 +470,6 @@ is_type_conversion_operator (struct type *type, int i, int j) return 0; } - /* Given a C++ qualified identifier QID, strip off the qualifiers, yielding the unqualified name. The return value is a pointer into the original string. @@ -486,6 +477,7 @@ is_type_conversion_operator (struct type *type, int i, int j) It's a pity we don't have this information in some more structured form. Even the author of this function feels that writing little parsers like this everywhere is stupid. */ + static char * remove_qualifiers (char *qid) { @@ -561,7 +553,6 @@ remove_qualifiers (char *qid) return qid; } - /* Print any array sizes, function arguments or close parentheses needed after the variable name (to describe its type). Args work like c_type_print_varspec_prefix. */ @@ -581,19 +572,20 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream, switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: - if (passed_a_ptr) - fprintf_filtered (stream, ")"); + { + LONGEST low_bound, high_bound; - fprintf_filtered (stream, "["); - if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0 - && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type)) - fprintf_filtered (stream, "%d", - (TYPE_LENGTH (type) - / TYPE_LENGTH (TYPE_TARGET_TYPE (type)))); - fprintf_filtered (stream, "]"); + if (passed_a_ptr) + fprintf_filtered (stream, ")"); - c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, - 0, 0); + fprintf_filtered (stream, "["); + if (get_array_bounds (type, &low_bound, &high_bound)) + fprintf_filtered (stream, "%d", (int) (high_bound - low_bound + 1)); + fprintf_filtered (stream, "]"); + + c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, + 0, 0); + } break; case TYPE_CODE_MEMBERPTR: @@ -716,6 +708,13 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show, switch (TYPE_CODE (type)) { case TYPE_CODE_TYPEDEF: + /* If we get here, the typedef doesn't have a name, and we couldn't + resolve TYPE_TARGET_TYPE. Not much we can do. */ + gdb_assert (TYPE_NAME (type) == NULL); + gdb_assert (TYPE_TARGET_TYPE (type) == NULL); + fprintf_filtered (stream, _("")); + break; + case TYPE_CODE_ARRAY: case TYPE_CODE_PTR: case TYPE_CODE_MEMBERPTR: @@ -768,7 +767,8 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show, cp_type_print_derivation_info (stream, type); fprintf_filtered (stream, "{\n"); - if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0)) + if (TYPE_NFIELDS (type) == 0 && TYPE_NFN_FIELDS (type) == 0 + && TYPE_TYPEDEF_FIELD_COUNT (type) == 0) { if (TYPE_STUB (type)) fprintfi_filtered (level + 4, stream, _("\n")); @@ -1058,6 +1058,29 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show, } } + /* Print typedefs defined in this class. */ + + if (TYPE_TYPEDEF_FIELD_COUNT (type) != 0) + { + if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0) + fprintf_filtered (stream, "\n"); + + for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); i++) + { + struct type *target = TYPE_TYPEDEF_FIELD_TYPE (type, i); + + /* Dereference the typedef declaration itself. */ + gdb_assert (TYPE_CODE (target) == TYPE_CODE_TYPEDEF); + target = TYPE_TARGET_TYPE (target); + + print_spaces_filtered (level + 4, stream); + fprintf_filtered (stream, "typedef "); + c_print_type (target, TYPE_TYPEDEF_FIELD_NAME (type, i), + stream, show - 1, level + 4); + fprintf_filtered (stream, ";\n"); + } + } + fprintfi_filtered (level, stream, "}"); if (TYPE_LOCALTYPE_PTR (type) && show >= 0)