diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2009-07-31 14:39:12 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@de.ibm.com> | 2009-07-31 14:39:12 +0000 |
commit | e35359c551b7ae1fb3bf1cdff1c58f3abafa07fb (patch) | |
tree | 6d9fbcaaa4c4ba6e30b644179b3c6d13164a8505 /gdb/target-descriptions.c | |
parent | 3a1bae8e7f6b90879682cbcd7391cb8493efb9a1 (diff) | |
download | gdb-e35359c551b7ae1fb3bf1cdff1c58f3abafa07fb.zip gdb-e35359c551b7ae1fb3bf1cdff1c58f3abafa07fb.tar.gz gdb-e35359c551b7ae1fb3bf1cdff1c58f3abafa07fb.tar.bz2 |
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/target-descriptions.c')
-rw-r--r-- | gdb/target-descriptions.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 024257b..b8bb48f 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -158,6 +158,10 @@ typedef struct tdesc_feature } *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 @@ -169,6 +173,9 @@ struct target_desc 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; @@ -326,6 +333,28 @@ target_current_description (void) 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; +} /* Direct accessors for target descriptions. */ @@ -1156,6 +1185,8 @@ free_target_description (void *arg) } VEC_free (property_s, target_desc->properties); + VEC_free (arch_p, target_desc->compatible); + xfree (target_desc); } @@ -1166,6 +1197,30 @@ make_cleanup_free_target_description (struct target_desc *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) { @@ -1257,6 +1312,7 @@ static void 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; @@ -1313,6 +1369,16 @@ maint_print_c_tdesc_cmd (char *args, int from_tty) 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++) { |