summaryrefslogtreecommitdiff
path: root/gdb/arch-utils.c
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2009-07-31 14:39:10 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2009-07-31 14:39:10 +0000
commit1e37dcb00c3db78fec2c9ccaf9fc17cd45f4b3ed (patch)
treea9011a38d5cbd0e30e24570dc98cf625fba02548 /gdb/arch-utils.c
parentf45cf4e6321c1029757d6d51baeabc7ff2da516e (diff)
downloadgdb-1e37dcb00c3db78fec2c9ccaf9fc17cd45f4b3ed.tar.gz
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.
Diffstat (limited to 'gdb/arch-utils.c')
-rw-r--r--gdb/arch-utils.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index f075922bf04..5cf4afd4f4c 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -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;