} *tdesc_feature_p;
DEF_VEC_P(tdesc_feature_p);
+/* A compatible architecture from a target description. */
+typedef const struct bfd_arch_info *arch_p;
+DEF_VEC_P(arch_p);
+
/* A target description. */
struct target_desc
/* The architecture reported by the target, if any. */
const struct bfd_arch_info *arch;
+ /* The osabi reported by the target, if any; GDB_OSABI_UNKNOWN
+ otherwise. */
+ enum gdb_osabi osabi;
+
+ /* The list of compatible architectures reported by the target. */
+ VEC(arch_p) *compatible;
+
/* Any architecture-specific properties specified by the target. */
VEC(property_s) *properties;
return NULL;
}
+
+/* Return non-zero if this target description is compatible
+ with the given BFD architecture. */
+
+int
+tdesc_compatible_p (const struct target_desc *target_desc,
+ const struct bfd_arch_info *arch)
+{
+ const struct bfd_arch_info *compat;
+ int ix;
+
+ for (ix = 0; VEC_iterate (arch_p, target_desc->compatible, ix, compat);
+ ix++)
+ {
+ if (compat == arch
+ || arch->compatible (arch, compat)
+ || compat->compatible (compat, arch))
+ return 1;
+ }
+
+ return 0;
+}
\f
/* Direct accessors for target descriptions. */
{
return target_desc->arch;
}
+
+/* Return the OSABI associated with this target description, or
+ GDB_OSABI_UNKNOWN if no osabi was specified. */
+
+enum gdb_osabi
+tdesc_osabi (const struct target_desc *target_desc)
+{
+ return target_desc->osabi;
+}
+
\f
/* Return 1 if this target description includes any registers. */
{
/* Predefined types. */
case TDESC_TYPE_INT8:
- return builtin_type_int8;
+ return builtin_type (gdbarch)->builtin_int8;
case TDESC_TYPE_INT16:
- return builtin_type_int16;
+ return builtin_type (gdbarch)->builtin_int16;
case TDESC_TYPE_INT32:
- return builtin_type_int32;
+ return builtin_type (gdbarch)->builtin_int32;
case TDESC_TYPE_INT64:
- return builtin_type_int64;
+ return builtin_type (gdbarch)->builtin_int64;
case TDESC_TYPE_INT128:
- return builtin_type_int128;
+ return builtin_type (gdbarch)->builtin_int128;
case TDESC_TYPE_UINT8:
- return builtin_type_uint8;
+ return builtin_type (gdbarch)->builtin_uint8;
case TDESC_TYPE_UINT16:
- return builtin_type_uint16;
+ return builtin_type (gdbarch)->builtin_uint16;
case TDESC_TYPE_UINT32:
- return builtin_type_uint32;
+ return builtin_type (gdbarch)->builtin_uint32;
case TDESC_TYPE_UINT64:
- return builtin_type_uint64;
+ return builtin_type (gdbarch)->builtin_uint64;
case TDESC_TYPE_UINT128:
- return builtin_type_uint128;
+ return builtin_type (gdbarch)->builtin_uint128;
case TDESC_TYPE_CODE_PTR:
return builtin_type (gdbarch)->builtin_func_ptr;
return builtin_type (gdbarch)->builtin_data_ptr;
case TDESC_TYPE_IEEE_SINGLE:
- return builtin_type_ieee_single;
+ return arch_float_type (gdbarch, -1, "builtin_type_ieee_single",
+ floatformats_ieee_single);
case TDESC_TYPE_IEEE_DOUBLE:
- return builtin_type_ieee_double;
+ return arch_float_type (gdbarch, -1, "builtin_type_ieee_double",
+ floatformats_ieee_double);
case TDESC_TYPE_ARM_FPA_EXT:
- return builtin_type_arm_ext;
+ return arch_float_type (gdbarch, -1, "builtin_type_arm_ext",
+ floatformats_arm_ext);
/* Types defined by a target feature. */
case TDESC_TYPE_VECTOR:
struct tdesc_type_field *f;
int ix;
- type = init_composite_type (NULL, TYPE_CODE_UNION);
+ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
TYPE_NAME (type) = xstrdup (tdesc_type->name);
for (ix = 0;
return 1;
}
+/* Search FEATURE for a register named NAME, but do not assign a fixed
+ register number to it. */
+
+int
+tdesc_unnumbered_register (const struct tdesc_feature *feature,
+ const char *name)
+{
+ struct tdesc_reg *reg = tdesc_find_register_early (feature, name);
+
+ if (reg == NULL)
+ return 0;
+
+ return 1;
+}
+
/* Search FEATURE for a register whose name is in NAMES and assign
REGNO to it. */
return "";
}
-static struct type *
+struct type *
tdesc_register_type (struct gdbarch *gdbarch, int regno)
{
struct tdesc_arch_reg *arch_reg = tdesc_find_arch_register (gdbarch, regno);
if (reg == NULL)
/* Return "int0_t", since "void" has a misleading size of one. */
- return builtin_type_int0;
+ return builtin_type (gdbarch)->builtin_int0;
if (arch_reg->type == NULL)
{
if (regno >= num_regs && regno < num_regs + num_pseudo_regs)
{
struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
- gdb_assert (data->pseudo_register_reggroup_p != NULL);
- return data->pseudo_register_reggroup_p (gdbarch, regno, reggroup);
+ if (data->pseudo_register_reggroup_p != NULL)
+ return data->pseudo_register_reggroup_p (gdbarch, regno, reggroup);
+ /* Otherwise fall through to the default reggroup_p. */
}
ret = tdesc_register_in_reggroup_p (gdbarch, regno, reggroup);
}
VEC_free (property_s, target_desc->properties);
+ VEC_free (arch_p, target_desc->compatible);
+
xfree (target_desc);
}
return make_cleanup (free_target_description, target_desc);
}
+void
+tdesc_add_compatible (struct target_desc *target_desc,
+ const struct bfd_arch_info *compatible)
+{
+ const struct bfd_arch_info *compat;
+ int ix;
+
+ /* If this instance of GDB is compiled without BFD support for the
+ compatible architecture, simply ignore it -- we would not be able
+ to handle it anyway. */
+ if (compatible == NULL)
+ return;
+
+ for (ix = 0; VEC_iterate (arch_p, target_desc->compatible, ix, compat);
+ ix++)
+ if (compat == compatible)
+ internal_error (__FILE__, __LINE__,
+ _("Attempted to add duplicate "
+ "compatible architecture \"%s\""),
+ compatible->printable_name);
+
+ VEC_safe_push (arch_p, target_desc->compatible, compatible);
+}
+
void
set_tdesc_property (struct target_desc *target_desc,
const char *key, const char *value)
{
target_desc->arch = arch;
}
+
+void
+set_tdesc_osabi (struct target_desc *target_desc, enum gdb_osabi osabi)
+{
+ target_desc->osabi = osabi;
+}
\f
static struct cmd_list_element *tdesc_set_cmdlist, *tdesc_show_cmdlist;
maint_print_c_tdesc_cmd (char *args, int from_tty)
{
const struct target_desc *tdesc;
+ const struct bfd_arch_info *compatible;
const char *filename, *inp;
char *function, *outp;
struct property *prop;
printf_unfiltered ("\n");
}
+ for (ix = 0; VEC_iterate (arch_p, tdesc->compatible, ix, compatible);
+ ix++)
+ {
+ printf_unfiltered
+ (" tdesc_add_compatible (result, bfd_scan_arch (\"%s\"));\n",
+ compatible->printable_name);
+ }
+ if (ix)
+ printf_unfiltered ("\n");
+
for (ix = 0; VEC_iterate (property_s, tdesc->properties, ix, prop);
ix++)
{