#include "event-top.h"
#include "bfd.h"
#include "symtab.h"
+#include "gdbarch.h"
#include "gdbtypes.h"
#include "expression.h"
#include "value.h"
did_print_modifier = 1;
}
- address_space_id
- = address_space_type_instance_flags_to_name (type->arch (),
- type->instance_flags ());
- if (address_space_id)
+ address_space_id = nullptr;
+
+ if (TYPE_CODE_SPACE (type))
+ address_space_id = "code";
+ else if (TYPE_DATA_SPACE (type))
+ address_space_id = "data";
+ else if (gdbarch_address_class_id_to_name_p (type->arch ()))
+ address_space_id
+ = gdbarch_address_class_id_to_name (type->arch (),
+ TYPE_ADDRESS_CLASS (type));
+
+ if (address_space_id != nullptr)
{
if (did_print_modifier || need_pre_space)
gdb_printf (stream, " ");
return create_function_type (return_type, nparams, param_types);
}
-/* Identify address space identifier by name -- return a
- type_instance_flags. */
-
-type_instance_flags
-address_space_name_to_type_instance_flags (struct gdbarch *gdbarch,
- const char *space_identifier)
-{
- /* Check for known address space delimiters. */
- if (streq (space_identifier, "code"))
- return TYPE_INSTANCE_FLAG_CODE_SPACE;
- else if (streq (space_identifier, "data"))
- return TYPE_INSTANCE_FLAG_DATA_SPACE;
-
- unsigned int aclass;
- if (gdbarch_address_class_name_to_id_p (gdbarch)
- && gdbarch_address_class_name_to_id (gdbarch,
- space_identifier,
- aclass))
- {
- return (enum type_instance_flag_value) (aclass << 4);
- }
- else
- error (_("Unknown address space specifier: \"%s\""), space_identifier);
-}
-
-/* Identify address space identifier by type_instance_flags and return
- the string version of the address space name. */
-
-const char *
-address_space_type_instance_flags_to_name (struct gdbarch *gdbarch,
- type_instance_flags space_flag)
-{
- if (space_flag & TYPE_INSTANCE_FLAG_CODE_SPACE)
- return "code";
- else if (space_flag & TYPE_INSTANCE_FLAG_DATA_SPACE)
- return "data";
-
- unsigned int aclass = TYPE_ADDRESS_CLASS_FROM_INSTANCE_FLAGS (space_flag);
-
- if (gdbarch_address_class_id_to_name_p (gdbarch))
- return gdbarch_address_class_id_to_name (gdbarch, aclass);
- else
- return NULL;
-}
-
/* Create a new type with instance flags NEW_FLAGS, based on TYPE.
If STORAGE is non-NULL, create the new type instance there.
extern void replace_type (struct type *, struct type *);
-extern type_instance_flags address_space_name_to_type_instance_flags
- (struct gdbarch *, const char *);
-
-extern const char *address_space_type_instance_flags_to_name
- (struct gdbarch *, type_instance_flags);
-
extern struct type *make_type_with_address_space
(struct type *type, type_instance_flags space_identifier);
with_test_prefix "C" {
gdb_test "p *(@somerandomqualifiername int *) 0x12345678" \
- "Unknown address space specifier: \"somerandomqualifiername\""
+ "Unknown address space/class specifier: \"somerandomqualifiername\""
}
gdb_test_no_output "set language c++"
with_test_prefix "C++" {
gdb_test "p *(@somerandomqualifiername int *) 0x12345678" \
- "Unknown address space specifier: \"somerandomqualifiername\""
+ "Unknown address space/class specifier: \"somerandomqualifiername\""
}
#include "type-stack.h"
#include "gdbtypes.h"
+#include "gdbarch.h"
/* See type-stack.h. */
Otherwise, simply push this on the top of the stack. */
int slot = (!m_elements.empty ()) ? 1 : 0;
- insert_into (slot, tp_space_identifier);
- insert_into (slot,
- address_space_name_to_type_instance_flags (gdbarch,
- string));
+ /* Check for Harvard address space delimiters and
+ architecture-specific address classes. */
+ if (streq (string, "code"))
+ {
+ insert_into (slot, tp_harvard_aspace_identifier);
+ insert_into (slot, TYPE_INSTANCE_FLAG_CODE_SPACE);
+ }
+ else if (streq (string, "data"))
+ {
+ insert_into (slot, tp_harvard_aspace_identifier);
+ insert_into (slot, TYPE_INSTANCE_FLAG_DATA_SPACE);
+ }
+ else if (unsigned int aclass = 0;
+ gdbarch_address_class_name_to_id_p (gdbarch)
+ && gdbarch_address_class_name_to_id (gdbarch,
+ string,
+ aclass))
+ {
+ insert_into (slot, tp_aclass_identifier);
+ insert_into (slot, (enum type_instance_flag_value) (aclass << 4));
+ }
+ else
+ error (_("Unknown address space/class specifier: \"%s\""), string);
}
/* See type-stack.h. */
case tp_volatile:
make_volatile = 1;
break;
- case tp_space_identifier:
+ case tp_harvard_aspace_identifier:
+ make_addr_space = (enum type_instance_flag_value) pop_int ();
+ break;
+ case tp_aclass_identifier:
make_addr_space = (enum type_instance_flag_value) pop_int ();
break;
case tp_atomic:
tp_function_with_arguments,
tp_const,
tp_volatile,
- /* An address space identifier. The address space is also pushed on
+ /* An Harvard address space identifier (i.e. "code" or "data"). The
+ address space is also pushed on the stack. */
+ tp_harvard_aspace_identifier,
+ /* An address class identifier. The address class is also pushed on
the stack. */
- tp_space_identifier,
+ tp_aclass_identifier,
tp_atomic,
tp_restrict,
/* A separate type stack, which is also pushed onto this type
accept an integer argument are allowed. */
void push (enum type_pieces tp, int n)
{
- gdb_assert (tp == tp_array || tp == tp_space_identifier || tp == tp_kind);
+ gdb_assert (tp == tp_array || tp == tp_harvard_aspace_identifier
+ || tp == tp_aclass_identifier || tp == tp_kind);
type_stack_elt elt;
elt.int_val = n;
m_elements.push_back (elt);
type_stack_elt elt = m_elements.back ();
m_elements.pop_back ();
type_pieces tp = elt.piece;
- gdb_assert (tp == tp_array || tp == tp_space_identifier || tp == tp_kind);
+ gdb_assert (tp == tp_array || tp == tp_harvard_aspace_identifier
+ || tp == tp_aclass_identifier || tp == tp_kind);
elt = m_elements.back ();
m_elements.pop_back ();
return elt.int_val;
return elt.stack_val;
}
- /* Insert a tp_space_identifier and the corresponding address space
- value into the stack. STRING is the name of an address space, as
- recognized by address_space_name_to_type_instance_flags. If the
- stack is empty, the new elements are simply pushed. If the stack
- is not empty, this function assumes that the first item on the
- stack is a tp_pointer, and the new values are inserted above the
- first item. */
+ /* Insert an address space or address class identifier and the
+ corresponding id value into the stack. STRING is the name of a
+ Harvard address space ("code" or "data"), or the name of an
+ address class as recognized by gdbarch_address_class_name_to_id.
+ If the stack is empty, the new elements are simply pushed. If
+ the stack is not empty, this function assumes that the first item
+ on the stack is a tp_pointer, and the new values are inserted
+ above the first item. */
void insert (struct gdbarch *gdbarch, const char *string);
{
return (tp == tp_array || tp == tp_kind || tp == tp_type_stack
|| tp == tp_function_with_arguments
- || tp == tp_space_identifier);
+ || tp == tp_harvard_aspace_identifier
+ || tp == tp_aclass_identifier);
}