aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog25
-rw-r--r--gdb/NEWS6
-rw-r--r--gdb/arch-utils.c28
-rw-r--r--gdb/doc/ChangeLog4
-rw-r--r--gdb/doc/gdb.texinfo34
-rw-r--r--gdb/features/gdb-target.dtd8
-rw-r--r--gdb/target-descriptions.c66
-rw-r--r--gdb/target-descriptions.h8
-rw-r--r--gdb/xml-tdesc.c16
9 files changed, 182 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 05bddd2..422b4ad 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,30 @@
2009-07-31 Ulrich Weigand <uweigand@de.ibm.com>
+ * 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.
+
+2009-07-31 Ulrich Weigand <uweigand@de.ibm.com>
+
* breakpoint.c (remove_breakpoints): If removing one breakpoint
location fails, still continue to remove other locations.
(remove_hw_watchpoints): Likewise.
diff --git a/gdb/NEWS b/gdb/NEWS
index 1e359a0..eccc56f 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -203,6 +203,12 @@ add new commands to existing prefixes, e.g. "target".
"Target Description Format" section in the user manual for more
information.
+* Target descriptions can now describe "compatible" architectures
+to indicate that the target can execute applications for a different
+architecture in addition to those for the main target architecture.
+See the "Target Description Format" section in the user manual for
+more information.
+
* New commands (for set/show, see "New options" below)
find [/size-char] [/max-count] start-address, end-address|+search-space-size,
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index f075922..5cf4afd 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;
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index a544bc1..7afbca0 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2009-07-31 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * gdb.texinfo (Target Descriptions): Document <compatible> element.
+
2009-07-28 Daniel Jacobowitz <dan@codesourcery.com>
* gdb.texinfo (ARM Features): Document org.gnu.gdb.arm.vfp and
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 3bb35b6..586f459 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -30807,6 +30807,7 @@ are explained further below.
<target version="1.0">
@r{[}@var{architecture}@r{]}
@r{[}@var{osabi}@r{]}
+ @r{[}@var{compatible}@r{]}
@r{[}@var{feature}@dots{}@r{]}
</target>
@end smallexample
@@ -30858,9 +30859,8 @@ An @samp{<architecture>} element has this form:
<architecture>@var{arch}</architecture>
@end smallexample
-@var{arch} is an architecture name from the same selection
-accepted by @code{set architecture} (@pxref{Targets, ,Specifying a
-Debugging Target}).
+@var{arch} is one of the architectures from the set accepted by
+@code{set architecture} (@pxref{Targets, ,Specifying a Debugging Target}).
@subsection OS ABI
@cindex @code{<osabi>}
@@ -30877,6 +30877,34 @@ An @samp{<osabi>} element has this form:
@var{abi-name} is an OS ABI name from the same selection accepted by
@w{@code{set osabi}} (@pxref{ABI, ,Configuring the Current ABI}).
+@subsection Compatible Architecture
+@cindex @code{<compatible>}
+
+This optional field was introduced in @value{GDBN} version 7.0.
+Previous versions of @value{GDBN} ignore it.
+
+A @samp{<compatible>} element has this form:
+
+@smallexample
+ <compatible>@var{arch}</compatible>
+@end smallexample
+
+@var{arch} is one of the architectures from the set accepted by
+@code{set architecture} (@pxref{Targets, ,Specifying a Debugging Target}).
+
+A @samp{<compatible>} element is used to specify that the target
+is able to run binaries in some other than the main target architecture
+given by the @samp{<architecture>} element. For example, on the
+Cell Broadband Engine, the main architecture is @code{powerpc:common}
+or @code{powerpc:common64}, but the system is able to run binaries
+in the @code{spu} architecture as well. The way to describe this
+capability with @samp{<compatible>} is as follows:
+
+@smallexample
+ <architecture>powerpc:common</architecture>
+ <compatible>spu</compatible>
+@end smallexample
+
@subsection Features
@cindex <feature>
diff --git a/gdb/features/gdb-target.dtd b/gdb/features/gdb-target.dtd
index ff5d3d5..d6e7109 100644
--- a/gdb/features/gdb-target.dtd
+++ b/gdb/features/gdb-target.dtd
@@ -6,10 +6,10 @@
<!-- The root element of a GDB target description is <target>. -->
-<!-- The osabi element was added post GDB 6.8. The version wasn't
- bumped, since older GDBs silently ignore unknown elements. -->
+<!-- The osabi and compatible elements were added post GDB 6.8. The version
+ wasn't bumped, since older GDBs silently ignore unknown elements. -->
-<!ELEMENT target (architecture?, osabi?, feature*)>
+<!ELEMENT target (architecture?, osabi?, compatible*, feature*)>
<!ATTLIST target
version CDATA #FIXED "1.0">
@@ -17,6 +17,8 @@
<!ELEMENT osabi (#PCDATA)>
+<!ELEMENT compatible (#PCDATA)>
+
<!ELEMENT feature ((vector | union)*, reg*)>
<!ATTLIST feature
name ID #REQUIRED>
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++)
{
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index 899f119..3880260 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -134,6 +134,12 @@ const struct bfd_arch_info *tdesc_architecture
enum gdb_osabi tdesc_osabi (const struct target_desc *);
+/* Return non-zero if this target description is compatible
+ with the given BFD architecture. */
+
+int tdesc_compatible_p (const struct target_desc *,
+ const struct bfd_arch_info *);
+
/* Return the string value of a property named KEY, or NULL if the
property was not specified. */
@@ -186,6 +192,8 @@ void set_tdesc_architecture (struct target_desc *,
void set_tdesc_osabi (struct target_desc *, enum gdb_osabi osabi);
void set_tdesc_property (struct target_desc *,
const char *key, const char *value);
+void tdesc_add_compatible (struct target_desc *,
+ const struct bfd_arch_info *);
struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc,
const char *name);
diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c
index 5fd8a41..4fa7843 100644
--- a/gdb/xml-tdesc.c
+++ b/gdb/xml-tdesc.c
@@ -124,6 +124,20 @@ tdesc_end_osabi (struct gdb_xml_parser *parser,
set_tdesc_osabi (data->tdesc, osabi);
}
+/* Handle the end of a <compatible> element and its value. */
+
+static void
+tdesc_end_compatible (struct gdb_xml_parser *parser,
+ const struct gdb_xml_element *element,
+ void *user_data, const char *body_text)
+{
+ struct tdesc_parsing_data *data = user_data;
+ const struct bfd_arch_info *arch;
+
+ arch = bfd_scan_arch (body_text);
+ tdesc_add_compatible (data->tdesc, arch);
+}
+
/* Handle the start of a <target> element. */
static void
@@ -334,6 +348,8 @@ static const struct gdb_xml_element target_children[] = {
NULL, tdesc_end_arch },
{ "osabi", NULL, NULL, GDB_XML_EF_OPTIONAL,
NULL, tdesc_end_osabi },
+ { "compatible", NULL, NULL, GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
+ NULL, tdesc_end_compatible },
{ "feature", feature_attributes, feature_children,
GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
tdesc_start_feature, NULL },