ChangeLog:

* features/gdb-target.dtd (target): Accept optional
	<compatible> elements.
	(compatible): Define element.

	* target-descriptions.h (tdesc_compatible_p): New.
	(tdesc_add_compatible): New.
	* target-descriptions.c (arch_p): New VEC_P type.
	(struct target_desc): New member compatible.
	(free_target_description): Handle it.
	(maint_print_c_tdesc_cmd): Likewise.
	(tdesc_compatible_p): New function.
	(tdesc_add_compatible): New function.

	* xml-tdesc.c (tdesc_end_compatible): New function.
	(target_children): Handle <compatible> element.

	* arch-utils.c (choose_architecture_for_target): Accept target
	description instead of BFD architecture as input.  Query target
	description for compatible architectures.
	(gdbarch_info_fill): Update call.

	* NEWS: Mention <compatible> element of target descriptions.

doc/ChangeLog:

	* gdb.texinfo (Target Descriptions): Document <compatible> element.
This commit is contained in:
Ulrich Weigand
2009-07-31 14:39:12 +00:00
parent 3a1bae8e7f
commit e35359c551
9 changed files with 182 additions and 13 deletions

View File

@@ -320,15 +320,24 @@ set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
}
/* Given SELECTED, a currently selected BFD architecture, and
FROM_TARGET, a BFD architecture reported by the target description,
return what architecture to use. Either may be NULL; if both are
specified, we use the more specific. If the two are obviously
incompatible, warn the user. */
TARGET_DESC, the current target description, return what
architecture to use.
SELECTED may be NULL, in which case we return the architecture
associated with TARGET_DESC. If SELECTED specifies a variant
of the architecture associtated with TARGET_DESC, return the
more specific of the two.
If SELECTED is a different architecture, but it is accepted as
compatible by the target, we can use the target architecture.
If SELECTED is obviously incompatible, warn the user. */
static const struct bfd_arch_info *
choose_architecture_for_target (const struct bfd_arch_info *selected,
const struct bfd_arch_info *from_target)
choose_architecture_for_target (const struct target_desc *target_desc,
const struct bfd_arch_info *selected)
{
const struct bfd_arch_info *from_target = tdesc_architecture (target_desc);
const struct bfd_arch_info *compat1, *compat2;
if (selected == NULL)
@@ -358,6 +367,11 @@ choose_architecture_for_target (const struct bfd_arch_info *selected,
if (compat1 == NULL && compat2 == NULL)
{
/* BFD considers the architectures incompatible. Check our target
description whether it accepts SELECTED as compatible anyway. */
if (tdesc_compatible_p (target_desc, selected))
return from_target;
warning (_("Selected architecture %s is not compatible "
"with reported target architecture %s"),
selected->printable_name, from_target->printable_name);
@@ -685,7 +699,7 @@ gdbarch_info_fill (struct gdbarch_info *info)
/* From the target. */
if (info->target_desc != NULL)
info->bfd_arch_info = choose_architecture_for_target
(info->bfd_arch_info, tdesc_architecture (info->target_desc));
(info->target_desc, info->bfd_arch_info);
/* From the default. */
if (info->bfd_arch_info == NULL)
info->bfd_arch_info = default_bfd_arch;