NULL);
}
+/* Make a '_Atomic'-qualified version of TYPE. */
+
+struct type *
+make_atomic_type (struct type *type)
+{
+ return make_qualified_type (type,
+ (TYPE_INSTANCE_FLAGS (type)
+ | TYPE_INSTANCE_FLAG_ATOMIC),
+ NULL);
+}
+
/* Replace the contents of ntype with the type *type. This changes the
contents, rather than the pointer for TYPE_MAIN_TYPE (ntype); thus
the changes are propogated to all types in the TYPE_CHAIN.
return 1;
}
+/* Assuming that TYPE is a discrete type and VAL is a valid integer
+ representation of a value of this type, save the corresponding
+ position number in POS.
+
+ Its differs from VAL only in the case of enumeration types. In
+ this case, the position number of the value of the first listed
+ enumeration literal is zero; the position number of the value of
+ each subsequent enumeration literal is one more than that of its
+ predecessor in the list.
+
+ Return 1 if the operation was successful. Return zero otherwise,
+ in which case the value of POS is unmodified.
+*/
+
+int
+discrete_position (struct type *type, LONGEST val, LONGEST *pos)
+{
+ if (TYPE_CODE (type) == TYPE_CODE_ENUM)
+ {
+ int i;
+
+ for (i = 0; i < TYPE_NFIELDS (type); i += 1)
+ {
+ if (val == TYPE_FIELD_ENUMVAL (type, i))
+ {
+ *pos = i;
+ return 1;
+ }
+ }
+ /* Invalid enumeration value. */
+ return 0;
+ }
+ else
+ {
+ *pos = val;
+ return 1;
+ }
+}
+
/* Create an array type using either a blank type supplied in
RESULT_TYPE, or creating a new type, inheriting the objfile from
RANGE_TYPE.
{
case TYPE_CODE_METHODPTR:
case TYPE_CODE_MEMBERPTR:
+ if (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE)
+ return NULL;
gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_SELF_TYPE);
return TYPE_MAIN_TYPE (type)->type_specific.self_type;
case TYPE_CODE_METHOD:
+ if (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE)
+ return NULL;
gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_FUNC);
return TYPE_MAIN_TYPE (type)->type_specific.func_stuff->self_type;
default:
lookup_struct_elt_type (struct type *type, const char *name, int noerr)
{
int i;
- char *typename;
+ char *type_name;
for (;;)
{
if (TYPE_CODE (type) != TYPE_CODE_STRUCT
&& TYPE_CODE (type) != TYPE_CODE_UNION)
{
- typename = type_to_string (type);
- make_cleanup (xfree, typename);
- error (_("Type %s is not a structure or union type."), typename);
+ type_name = type_to_string (type);
+ make_cleanup (xfree, type_name);
+ error (_("Type %s is not a structure or union type."), type_name);
}
#if 0
I.e. when doing "ptype bell->bar" for "struct foo { int bar; int
foo; } bell;" Disabled by fnf. */
{
- char *typename;
+ char *type_name;
- typename = type_name_no_tag (type);
- if (typename != NULL && strcmp (typename, name) == 0)
+ type_name = type_name_no_tag (type);
+ if (type_name != NULL && strcmp (type_name, name) == 0)
return type;
}
#endif
return NULL;
}
- typename = type_to_string (type);
- make_cleanup (xfree, typename);
- error (_("Type %s has no component named %s."), typename, name);
+ type_name = type_to_string (type);
+ make_cleanup (xfree, type_name);
+ error (_("Type %s has no component named %s."), type_name, name);
}
/* Store in *MAX the largest number representable by unsigned integer type
int
internal_type_vptr_fieldno (struct type *type)
{
+ CHECK_TYPEDEF (type);
gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT
|| TYPE_CODE (type) == TYPE_CODE_UNION);
if (!HAVE_CPLUS_STRUCT (type))
void
set_type_vptr_fieldno (struct type *type, int fieldno)
{
+ CHECK_TYPEDEF (type);
gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT
|| TYPE_CODE (type) == TYPE_CODE_UNION);
if (!HAVE_CPLUS_STRUCT (type))
struct type *
internal_type_vptr_basetype (struct type *type)
{
+ CHECK_TYPEDEF (type);
gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT
|| TYPE_CODE (type) == TYPE_CODE_UNION);
gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_CPLUS_STUFF);
void
set_type_vptr_basetype (struct type *type, struct type *basetype)
{
+ CHECK_TYPEDEF (type);
gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT
|| TYPE_CODE (type) == TYPE_CODE_UNION);
if (!HAVE_CPLUS_STRUCT (type))
else
elt_type = TYPE_TARGET_TYPE (type);
- return create_array_type (copy_type (type),
- elt_type,
- range_type);
+ return create_array_type_with_stride (copy_type (type),
+ elt_type, range_type,
+ TYPE_FIELD_BITSIZE (type, 0));
}
/* Resolve dynamic bounds of members of the union TYPE to static
" (invalid location kind)"));
pinfo.type = check_typedef (TYPE_FIELD_TYPE (type, i));
+ pinfo.valaddr = addr_stack->valaddr;
pinfo.addr = addr_stack->addr;
pinfo.next = addr_stack;
TYPE_LENGTH (resolved_type)
= (resolved_type_bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
+ /* The Ada language uses this field as a cache for static fixed types: reset
+ it as RESOLVED_TYPE must have its own static fixed type. */
+ TYPE_TARGET_TYPE (resolved_type) = NULL;
+
return resolved_type;
}
{
struct type *real_type = check_typedef (type);
struct type *resolved_type = type;
- const struct dynamic_prop *prop;
+ struct dynamic_prop *prop;
CORE_ADDR value;
if (!is_dynamic_type_internal (real_type, top_level))
struct property_addr_info pinfo;
pinfo.type = check_typedef (TYPE_TARGET_TYPE (type));
- pinfo.addr = read_memory_typed_address (addr_stack->addr, type);
+ pinfo.valaddr = NULL;
+ if (addr_stack->valaddr != NULL)
+ pinfo.addr = extract_typed_address (addr_stack->valaddr, type);
+ else
+ pinfo.addr = read_memory_typed_address (addr_stack->addr, type);
pinfo.next = addr_stack;
resolved_type = copy_type (type);
/* Resolve data_location attribute. */
prop = TYPE_DATA_LOCATION (resolved_type);
- if (dwarf2_evaluate_property (prop, addr_stack, &value))
+ if (prop != NULL && dwarf2_evaluate_property (prop, addr_stack, &value))
{
- TYPE_DATA_LOCATION_ADDR (resolved_type) = value;
- TYPE_DATA_LOCATION_KIND (resolved_type) = PROP_CONST;
+ TYPE_DYN_PROP_ADDR (prop) = value;
+ TYPE_DYN_PROP_KIND (prop) = PROP_CONST;
}
- else
- TYPE_DATA_LOCATION (resolved_type) = NULL;
return resolved_type;
}
/* See gdbtypes.h */
struct type *
-resolve_dynamic_type (struct type *type, CORE_ADDR addr)
+resolve_dynamic_type (struct type *type, const gdb_byte *valaddr,
+ CORE_ADDR addr)
{
- struct property_addr_info pinfo = {check_typedef (type), addr, NULL};
+ struct property_addr_info pinfo
+ = {check_typedef (type), valaddr, addr, NULL};
return resolve_dynamic_type_internal (type, &pinfo, 1);
}
+/* See gdbtypes.h */
+
+struct dynamic_prop *
+get_dyn_prop (enum dynamic_prop_node_kind prop_kind, const struct type *type)
+{
+ struct dynamic_prop_list *node = TYPE_DYN_PROP_LIST (type);
+
+ while (node != NULL)
+ {
+ if (node->prop_kind == prop_kind)
+ return &node->prop;
+ node = node->next;
+ }
+ return NULL;
+}
+
+/* See gdbtypes.h */
+
+void
+add_dyn_prop (enum dynamic_prop_node_kind prop_kind, struct dynamic_prop prop,
+ struct type *type, struct objfile *objfile)
+{
+ struct dynamic_prop_list *temp;
+
+ gdb_assert (TYPE_OBJFILE_OWNED (type));
+
+ temp = obstack_alloc (&objfile->objfile_obstack,
+ sizeof (struct dynamic_prop_list));
+ temp->prop_kind = prop_kind;
+ temp->prop = prop;
+ temp->next = TYPE_DYN_PROP_LIST (type);
+
+ TYPE_DYN_PROP_LIST (type) = temp;
+}
+
+
/* Find the real type of TYPE. This function returns the real type,
after removing all layers of typedefs, and completing opaque or stub
types. Completion changes the TYPE argument, but stripping of
{
struct ui_file *saved_gdb_stderr;
struct type *type = NULL; /* Initialize to keep gcc happy. */
- volatile struct gdb_exception except;
/* Suppress error messages. */
saved_gdb_stderr = gdb_stderr;
gdb_stderr = ui_file_new ();
/* Call parse_and_eval_type() without fear of longjmp()s. */
- TRY_CATCH (except, RETURN_MASK_ERROR)
+ TRY
{
type = parse_and_eval_type (p, length);
}
-
- if (except.reason < 0)
- type = builtin_type (gdbarch)->builtin_void;
+ CATCH (except, RETURN_MASK_ERROR)
+ {
+ type = builtin_type (gdbarch)->builtin_void;
+ }
+ END_CATCH
/* Stop suppressing error messages. */
ui_file_delete (gdb_stderr);
}
/* If we read one argument and it was ``void'', don't count it. */
- if (strncmp (argtypetext, "(void)", 6) == 0)
+ if (startswith (argtypetext, "(void)"))
argcount -= 1;
/* We need one extra slot, for the THIS pointer. */
Therefore the only thing we need to handle here are v2 operator
names. */
- if (found_stub && strncmp (TYPE_FN_FIELD_PHYSNAME (f, 0), "_Z", 2) != 0)
+ if (found_stub && !startswith (TYPE_FN_FIELD_PHYSNAME (f, 0), "_Z"))
{
int ret;
char dem_opname[256];
distance_to_ancestor (A, D, 1) = -1. */
static int
-distance_to_ancestor (struct type *base, struct type *dclass, int public)
+distance_to_ancestor (struct type *base, struct type *dclass, int is_public)
{
int i;
int d;
for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
{
- if (public && ! BASETYPE_VIA_PUBLIC (dclass, i))
+ if (is_public && ! BASETYPE_VIA_PUBLIC (dclass, i))
continue;
- d = distance_to_ancestor (base, TYPE_BASECLASS (dclass, i), public);
+ d = distance_to_ancestor (base, TYPE_BASECLASS (dclass, i), is_public);
if (d >= 0)
return 1 + d;
}
int
types_deeply_equal (struct type *type1, struct type *type2)
{
- volatile struct gdb_exception except;
+ struct gdb_exception except = exception_none;
int result = 0;
struct bcache *cache;
VEC (type_equality_entry_d) *worklist = NULL;
entry.type2 = type2;
VEC_safe_push (type_equality_entry_d, worklist, &entry);
- TRY_CATCH (except, RETURN_MASK_ALL)
+ /* check_types_worklist calls several nested helper functions, some
+ of which can raise a GDB exception, so we just check and rethrow
+ here. If there is a GDB exception, a comparison is not capable
+ (or trusted), so exit. */
+ TRY
{
result = check_types_worklist (&worklist, cache);
}
- /* check_types_worklist calls several nested helper functions,
- some of which can raise a GDB Exception, so we just check
- and rethrow here. If there is a GDB exception, a comparison
- is not capable (or trusted), so exit. */
+ CATCH (ex, RETURN_MASK_ALL)
+ {
+ except = ex;
+ }
+ END_CATCH
+
bcache_xfree (cache);
VEC_free (type_equality_entry_d, worklist);
+
/* Rethrow if there was a problem. */
if (except.reason < 0)
throw_exception (except);
{
struct type *descriptive_type = TYPE_DESCRIPTIVE_TYPE (type);
- recursive_dump_type (descriptive_type, spaces + 2);
+ if (descriptive_type == NULL)
+ printfi_filtered (spaces + 2, "no descriptive type\n");
+ else
+ {
+ printfi_filtered (spaces + 2, "descriptive type\n");
+ recursive_dump_type (descriptive_type, spaces + 4);
+ }
}
static struct obstack dont_print_type_obstack;
{
puts_filtered (" TYPE_FLAG_RESTRICT");
}
+ if (TYPE_ATOMIC (type))
+ {
+ puts_filtered (" TYPE_FLAG_ATOMIC");
+ }
puts_filtered ("\n");
printfi_filtered (spaces, "flags");
struct type_pair
{
- struct type *old, *new;
+ struct type *old, *newobj;
};
static hashval_t
dummy_obstack_deallocate);
}
+/* Recursively copy (deep copy) a dynamic attribute list of a type. */
+
+static struct dynamic_prop_list *
+copy_dynamic_prop_list (struct obstack *objfile_obstack,
+ struct dynamic_prop_list *list)
+{
+ struct dynamic_prop_list *copy = list;
+ struct dynamic_prop_list **node_ptr = ©
+
+ while (*node_ptr != NULL)
+ {
+ struct dynamic_prop_list *node_copy;
+
+ node_copy = obstack_copy (objfile_obstack, *node_ptr,
+ sizeof (struct dynamic_prop_list));
+ node_copy->prop = (*node_ptr)->prop;
+ *node_ptr = node_copy;
+
+ node_ptr = &node_copy->next;
+ }
+
+ return copy;
+}
+
/* Recursively copy (deep copy) TYPE, if it is associated with
OBJFILE. Return a new type allocated using malloc, a saved type if
we have already visited TYPE (using COPIED_TYPES), or TYPE if it is
pair.old = type;
slot = htab_find_slot (copied_types, &pair, INSERT);
if (*slot != NULL)
- return ((struct type_pair *) *slot)->new;
+ return ((struct type_pair *) *slot)->newobj;
new_type = alloc_type_arch (get_type_arch (type));
stored
= obstack_alloc (&objfile->objfile_obstack, sizeof (struct type_pair));
stored->old = type;
- stored->new = new_type;
+ stored->newobj = new_type;
*slot = stored;
/* Copy the common fields of types. For the main type, we simply
*TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
}
- /* Copy the data location information. */
- if (TYPE_DATA_LOCATION (type) != NULL)
- {
- TYPE_DATA_LOCATION (new_type)
- = TYPE_ALLOC (new_type, sizeof (struct dynamic_prop));
- memcpy (TYPE_DATA_LOCATION (new_type), TYPE_DATA_LOCATION (type),
- sizeof (struct dynamic_prop));
- }
+ if (TYPE_DYN_PROP_LIST (type) != NULL)
+ TYPE_DYN_PROP_LIST (new_type)
+ = copy_dynamic_prop_list (&objfile->objfile_obstack,
+ TYPE_DYN_PROP_LIST (type));
+
/* Copy pointers to other types. */
if (TYPE_TARGET_TYPE (type))
TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type),
sizeof (struct main_type));
- if (TYPE_DATA_LOCATION (type) != NULL)
- {
- TYPE_DATA_LOCATION (new_type)
- = TYPE_ALLOC (new_type, sizeof (struct dynamic_prop));
- memcpy (TYPE_DATA_LOCATION (new_type), TYPE_DATA_LOCATION (type),
- sizeof (struct dynamic_prop));
- }
+ if (TYPE_DYN_PROP_LIST (type) != NULL)
+ TYPE_DYN_PROP_LIST (new_type)
+ = copy_dynamic_prop_list (&TYPE_OBJFILE (type) -> objfile_obstack,
+ TYPE_DYN_PROP_LIST (type));
return new_type;
}