/* Support for printing C and C++ types for GDB, the GNU debugger.
Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
- 1999, 2000, 2001, 2002, 2003, 2006, 2007, 2008
+ 1999, 2000, 2001, 2002, 2003, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
This file is part of GDB.
c_type_print_base (type, stream, show, level);
code = TYPE_CODE (type);
if ((varstring != NULL && *varstring != '\0')
- ||
/* Need a space if going to print stars or brackets;
but not if we will print just a type name. */
- ((show > 0 || TYPE_NAME (type) == 0)
- &&
- (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
- || code == TYPE_CODE_METHOD
- || code == TYPE_CODE_ARRAY
- || code == TYPE_CODE_MEMBERPTR
- || code == TYPE_CODE_METHODPTR
- || code == TYPE_CODE_REF)))
+ || ((show > 0 || TYPE_NAME (type) == 0)
+ && (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
+ || code == TYPE_CODE_METHOD
+ || code == TYPE_CODE_ARRAY
+ || code == TYPE_CODE_MEMBERPTR
+ || code == TYPE_CODE_METHODPTR
+ || code == TYPE_CODE_REF)))
fputs_filtered (" ", stream);
need_post_space = (varstring != NULL && strcmp (varstring, "") != 0);
c_type_print_varspec_prefix (type, stream, show, 0, need_post_space);
}
}
+/* Print a typedef using C syntax. TYPE is the underlying type.
+ NEW_SYMBOL is the symbol naming the type. STREAM is the stream on
+ which to print. */
+
+void
+c_print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream)
+{
+ CHECK_TYPEDEF (type);
+ fprintf_filtered (stream, "typedef ");
+ type_print (type, "", stream, 0);
+ if (TYPE_NAME ((SYMBOL_TYPE (new_symbol))) == 0
+ || strcmp (TYPE_NAME ((SYMBOL_TYPE (new_symbol))),
+ SYMBOL_LINKAGE_NAME (new_symbol)) != 0)
+ fprintf_filtered (stream, " %s", SYMBOL_PRINT_NAME (new_symbol));
+ fprintf_filtered (stream, ";\n");
+}
+
/* If TYPE is a derived type, then print out derivation information.
Print only the actual base classes of this type, not the base classes
of the base classes. I.E. for the derivation hierarchy:
did_print_modifier = 1;
}
- address_space_id = address_space_int_to_name (TYPE_INSTANCE_FLAGS (type));
+ address_space_id = address_space_int_to_name (get_type_arch (type),
+ TYPE_INSTANCE_FLAGS (type));
if (address_space_id)
{
if (did_print_modifier || need_pre_space)
fprintf_filtered (stream, "[");
if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
- && TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
+ && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
fprintf_filtered (stream, "%d",
(TYPE_LENGTH (type)
/ TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
* tag for unnamed struct/union/enum's, which we don't
* want to print.
*/
- if (TYPE_TAG_NAME (type) != NULL &&
- strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
+ if (TYPE_TAG_NAME (type) != NULL
+ && strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
{
fputs_filtered (TYPE_TAG_NAME (type), stream);
if (show > 0)
}
else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
{
+ struct type *basetype;
+ int vptr_fieldno;
+
cp_type_print_derivation_info (stream, type);
fprintf_filtered (stream, "{\n");
masquerading as a class, if all members are public, there's
no need for a "public:" label. */
- if ((TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_CLASS) ||
- (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_TEMPLATE))
+ if ((TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_CLASS)
+ || (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_TEMPLATE))
{
QUIT;
len = TYPE_NFIELDS (type);
}
}
}
- else if ((TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_STRUCT) ||
- (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_UNION))
+ else if ((TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_STRUCT)
+ || (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_UNION))
{
QUIT;
len = TYPE_NFIELDS (type);
QUIT;
len = TYPE_FN_FIELDLIST_LENGTH (type, j);
for (i = 0; i < len; i++)
- if (TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, j), i) ||
- TYPE_FN_FIELD_PROTECTED (TYPE_FN_FIELDLIST1 (type, j), i))
+ if (TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, j), i)
+ || TYPE_FN_FIELD_PROTECTED (TYPE_FN_FIELDLIST1 (type, j), i))
{
need_access_label = 1;
break;
do not print the field that it occupies. */
len = TYPE_NFIELDS (type);
+ vptr_fieldno = get_vptr_fieldno (type, &basetype);
for (i = TYPE_N_BASECLASSES (type); i < len; i++)
{
QUIT;
- /* Don't print out virtual function table. */
- if (strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0
- && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
+
+ /* If we have a virtual table pointer, omit it. Even if
+ virtual table pointers are not specifically marked in
+ the debug info, they should be artificial. */
+ if ((type == basetype && i == vptr_fieldno)
+ || TYPE_FIELD_ARTIFICIAL (type, i))
continue;
/* If this is a C++ class we can print the various C++ section
}
print_spaces_filtered (level + 4, stream);
- if (TYPE_FIELD_STATIC (type, i))
- {
- fprintf_filtered (stream, "static ");
- }
+ if (field_is_static (&TYPE_FIELD (type, i)))
+ fprintf_filtered (stream, "static ");
c_print_type (TYPE_FIELD_TYPE (type, i),
TYPE_FIELD_NAME (type, i),
stream, show - 1, level + 4);
- if (!TYPE_FIELD_STATIC (type, i)
+ if (!field_is_static (&TYPE_FIELD (type, i))
&& TYPE_FIELD_PACKED (type, i))
{
/* It is a bitfield. This code does not attempt
TYPE_FN_FIELD_PHYSNAME (f, j));
break;
}
- else if (!is_constructor && /* constructors don't have declared types */
- !is_full_physname_constructor && /* " " */
- !is_type_conversion_operator (type, i, j))
+ else if (!is_constructor /* constructors don't have declared types */
+ && !is_full_physname_constructor /* " " */
+ && !is_type_conversion_operator (type, i, j))
{
type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
"", stream, -1);
TYPE_LOCALTYPE_FILE (type),
TYPE_LOCALTYPE_LINE (type));
}
- if (TYPE_CODE (type) == TYPE_CODE_TEMPLATE)
- goto go_back;
break;
case TYPE_CODE_ENUM:
"{unnamed struct}"/"{unnamed union}"/"{unnamed enum}"
tag for unnamed struct/union/enum's, which we don't
want to print. */
- if (TYPE_TAG_NAME (type) != NULL &&
- strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
+ if (TYPE_TAG_NAME (type) != NULL
+ && strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
{
fputs_filtered (TYPE_TAG_NAME (type), stream);
if (show > 0)
fprintf_filtered (stream, ", ");
}
fprintf_filtered (stream, "> class ");
- /* Yuck, factor this out to a subroutine so we can call
- it and return to the point marked with the "goback:" label... - RT */
goto struct_union;
- go_back:
- if (TYPE_NINSTANTIATIONS (type) > 0)
- {
- fprintf_filtered (stream, _("\ntemplate instantiations:\n"));
- for (i = 0; i < TYPE_NINSTANTIATIONS (type); i++)
- {
- fprintf_filtered (stream, " ");
- c_type_print_base (TYPE_INSTANTIATION (type, i), stream, 0, level);
- if (i < TYPE_NINSTANTIATIONS (type) - 1)
- fprintf_filtered (stream, "\n");
- }
- }
- break;
case TYPE_CODE_NAMESPACE:
fputs_filtered ("namespace ", stream);