unsigned int aclass
= gdbarch_address_class_dwarf_to_id (gdbarch, byte_size,
addr_class);
- type_instance_flags type_flags
- = (enum type_instance_flag_value) (aclass << 4);
- gdb_assert ((type_flags & ~TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
- == 0);
- type = make_type_with_address_space (type, type_flags);
+ type = make_type_with_address_class (type, aclass);
}
else if (type->length () != byte_size)
{
return ntype;
}
-/* Make an address-space-delimited variant of a type -- a type that
+/* Make a Harvard-address-space-delimited variant of a type -- a type that
is identical to the one supplied except that it has an address
space attribute attached to it (such as "code" or "data").
representations. */
struct type *
-make_type_with_address_space (struct type *type,
- type_instance_flags space_flag)
+make_type_with_harvard_address_space (struct type *type,
+ enum harvard_address_space aspace)
{
- type_instance_flags new_flags = ((type->instance_flags ()
- & ~(TYPE_INSTANCE_FLAG_CODE_SPACE
- | TYPE_INSTANCE_FLAG_DATA_SPACE
- | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL))
- | space_flag);
+ type_instance_flags new_flags
+ = (enum type_instance_flag_value) (aspace << 2);
- return make_qualified_type (type, new_flags, NULL);
+ gdb_assert ((new_flags & ~(TYPE_INSTANCE_FLAG_CODE_SPACE
+ | TYPE_INSTANCE_FLAG_DATA_SPACE)) == 0);
+ new_flags |= (type->instance_flags ()
+ & ~(TYPE_INSTANCE_FLAG_CODE_SPACE
+ | TYPE_INSTANCE_FLAG_DATA_SPACE));
+
+ return make_qualified_type (type, new_flags, nullptr);
+}
+
+/* Make an address-class-delimited variant of a type -- a type that is
+ identical to the one supplied except that it has an address class
+ attribute attached to it. The address class attribute is
+ architecture specific. It may denote an alternately sized pointer
+ or a pointer with alternate representation. */
+
+struct type *
+make_type_with_address_class (struct type *type,
+ unsigned int address_class)
+{
+ type_instance_flags new_flags
+ = (enum type_instance_flag_value) (address_class << 4);
+
+ gdb_assert ((new_flags & ~TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL) == 0);
+
+ new_flags |= (type->instance_flags ()
+ & ~TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL);
+
+ return make_qualified_type (type, new_flags, nullptr);
}
/* See gdbtypes.h. */
};
+/* Enum encoded in instance flags of a type to denote which Harvard
+ address space the type refers to.
+
+ Harvard architectures have separate instruction and data address
+ spaces (and perhaps others). GDB usually defines a flat address
+ space that is a superset of the architecture's two (or more)
+ address spaces, but this is an extension of the architecture's
+ model.
+
+ If using HARVARD_ASPACE_CODE, an object of the corresponding type
+ resides in instruction memory, even if its address (in the extended
+ flat address space) does not reflect this.
+
+ Similarly, if using HARVARD_ASPACE_DATA, then an object of the
+ corresponding type resides in the data memory space, even if this
+ is not indicated by its (flat address space) address.
+
+ If using HARVARD_ASPACE_NONE, the default space for functions /
+ methods is instruction space, and for data objects is data
+ memory. */
+
+enum harvard_address_space
+{
+ HARVARD_ASPACE_NONE = 0,
+ HARVARD_ASPACE_CODE = 1,
+ HARVARD_ASPACE_DATA = 2,
+};
+
/* Some bits for the type's instance_flags word. See the macros
below for documentation on each bit. */
(((t)->dyn_prop (DYN_PROP_BYTE_SIZE) != nullptr) \
|| ((t)->dyn_prop (DYN_PROP_BIT_SIZE) != nullptr))
-/* Instruction-space delimited type. This is for Harvard architectures
- which have separate instruction and data address spaces (and perhaps
- others).
-
- GDB usually defines a flat address space that is a superset of the
- architecture's two (or more) address spaces, but this is an extension
- of the architecture's model.
-
- If TYPE_INSTANCE_FLAG_CODE_SPACE is set, an object of the corresponding type
- resides in instruction memory, even if its address (in the extended
- flat address space) does not reflect this.
-
- Similarly, if TYPE_INSTANCE_FLAG_DATA_SPACE is set, then an object of the
- corresponding type resides in the data memory space, even if
- this is not indicated by its (flat address space) address.
-
- If neither flag is set, the default space for functions / methods
- is instruction space, and for data objects is data memory. */
+/* See enum harvard_address_space above. */
#define TYPE_CODE_SPACE(t) \
((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CODE_SPACE) != 0)
extern void replace_type (struct type *, struct type *);
-extern struct type *make_type_with_address_space
- (struct type *type, type_instance_flags space_identifier);
+extern struct type *make_type_with_harvard_address_space
+ (struct type *type, enum harvard_address_space aspace);
+
+extern struct type *make_type_with_address_class
+ (struct type *type, unsigned int address_class);
/* Implement direct support for MEMBER_TYPE in GNU C++.
TO_TYPE is the type of the member. DOMAIN is the type of the aggregate that
t->set_name ("gdb_gnu_v3_abi_vtable");
INIT_CPLUS_SPECIFIC (t);
- result = make_type_with_address_space (t, TYPE_INSTANCE_FLAG_CODE_SPACE);
+ result = make_type_with_harvard_address_space (t, HARVARD_ASPACE_CODE);
vtable_type_gdbarch_data.set (arch, result);
return result;
}
}
gdb_assert (val_type != nullptr);
- val_type = make_type_with_address_space (val_type, flags);
+
+ if ((flags & TYPE_INSTANCE_FLAG_CODE_SPACE) != 0)
+ val_type = make_type_with_harvard_address_space (val_type,
+ HARVARD_ASPACE_CODE);
+ else if ((flags & TYPE_INSTANCE_FLAG_DATA_SPACE) != 0)
+ val_type = make_type_with_harvard_address_space (val_type,
+ HARVARD_ASPACE_DATA);
+
+ unsigned int aclass
+ = (unsigned int) (flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL) >> 4;
+ if (aclass != 0)
+ val_type = make_type_with_address_class (val_type, aclass);
return val_type;
}
if (streq (string, "code"))
{
insert_into (slot, tp_harvard_aspace_identifier);
- insert_into (slot, TYPE_INSTANCE_FLAG_CODE_SPACE);
+ insert_into (slot, HARVARD_ASPACE_CODE);
}
else if (streq (string, "data"))
{
insert_into (slot, tp_harvard_aspace_identifier);
- insert_into (slot, TYPE_INSTANCE_FLAG_DATA_SPACE);
+ insert_into (slot, HARVARD_ASPACE_DATA);
}
else if (unsigned int aclass = 0;
gdbarch_address_class_name_to_id_p (gdbarch)
aclass))
{
insert_into (slot, tp_aclass_identifier);
- insert_into (slot, (enum type_instance_flag_value) (aclass << 4));
+ insert_into (slot, aclass);
}
else
error (_("Unknown address space/class specifier: \"%s\""), string);
int done = 0;
int make_const = 0;
int make_volatile = 0;
- type_instance_flags make_addr_space = 0;
+ harvard_address_space make_harvard_aspace = HARVARD_ASPACE_NONE;
+ int make_address_class = 0;
bool make_restrict = false;
bool make_atomic = false;
int array_size;
make_volatile = 1;
break;
case tp_harvard_aspace_identifier:
- make_addr_space = (enum type_instance_flag_value) pop_int ();
+ make_harvard_aspace = (harvard_address_space) pop_int ();
break;
case tp_aclass_identifier:
- make_addr_space = (enum type_instance_flag_value) pop_int ();
+ make_address_class = pop_int ();
break;
case tp_atomic:
make_atomic = true;
follow_type = make_cv_type (TYPE_CONST (follow_type),
make_volatile,
follow_type);
- if (make_addr_space)
- follow_type = make_type_with_address_space (follow_type,
- make_addr_space);
+ if (make_harvard_aspace != HARVARD_ASPACE_NONE)
+ follow_type
+ = make_type_with_harvard_address_space (follow_type,
+ make_harvard_aspace);
+ if (make_address_class != 0)
+ follow_type
+ = make_type_with_address_class (follow_type,
+ make_address_class);
if (make_restrict)
follow_type = make_restrict_type (follow_type);
if (make_atomic)
follow_type = make_atomic_type (follow_type);
make_const = make_volatile = 0;
- make_addr_space = 0;
+ make_harvard_aspace = HARVARD_ASPACE_NONE;
+ make_address_class = 0;
make_restrict = make_atomic = false;
break;
case tp_array: