aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2009-07-20 18:51:42 +0000
committerPedro Alves <palves@redhat.com>2009-07-20 18:51:42 +0000
commit08d1664121e7855d2477854ff1473e82d1731044 (patch)
treee7c913ae91c6d24a95ecc2994a4e6e711da41bab /gdb
parenta156a290642281359c8dc0c949fdd942826455a1 (diff)
downloadgdb-08d1664121e7855d2477854ff1473e82d1731044.zip
gdb-08d1664121e7855d2477854ff1473e82d1731044.tar.gz
gdb-08d1664121e7855d2477854ff1473e82d1731044.tar.bz2
2009-07-20 Pedro Alves <pedro@codesourcery.com>
* features/gdb-target.dtd (target): Accept an optional 'osabi' element. (osabi): Define element. * features/mips-linux.xml (target): Add an osabi subelement set to GNU/Linux. * regformats/regdat.sh (xmlarch, xmlosabi): New variables. Don't write the architecture into $xmltarget. Store it in $xmlarch. Handle the 'osabi' type. Handle outputting the osabi element of the target description. * regformats/reg-x86-64-linux.dat (osabi): Set to GNU/Linux. * regformats/reg-i386-linux.dat (osabi): Set to GNU/Linux. * target-descriptions.h (tdesc_osabi, set_tdesc_osabi): Declare. * target-descriptions.c (struct target_desc) <osabi>: New field. (tdesc_osabi): New function. (set_tdesc_osabi): New function. * xml-tdesc.c: Include osabi.h. (tdesc_end_osabi): New. (target_children): Parse "osabi" elements. * arch-utils.c (gdbarch_info_fill): Try to get the osabi from the target description if the user didn't override it or it is not extractable from the bfd. If that still fails, fallback to the configured in default. * osabi.h (osabi_from_tdesc_string): Declare. * osabi.c (osabi_from_tdesc_string): New. (gdbarch_lookup_osabi): Return GDB_OSABI_UNKNOWN instead of GDB_OSABI_DEFAULT. * NEWS: Mention that target descriptions can now describe the target OS ABI. 2009-07-20 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Target Description Format): Mention the new <osabi> optional element. (subsection OS ABI): New subsection.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog33
-rw-r--r--gdb/NEWS4
-rw-r--r--gdb/arch-utils.c7
-rw-r--r--gdb/doc/ChangeLog6
-rw-r--r--gdb/doc/gdb.texinfo19
-rw-r--r--gdb/features/gdb-target.dtd7
-rw-r--r--gdb/features/mips-linux.xml1
-rw-r--r--gdb/osabi.c38
-rw-r--r--gdb/osabi.h4
-rw-r--r--gdb/regformats/reg-i386-linux.dat1
-rw-r--r--gdb/regformats/reg-x86-64-linux.dat1
-rwxr-xr-xgdb/regformats/regdat.sh20
-rw-r--r--gdb/target-descriptions.c20
-rw-r--r--gdb/target-descriptions.h6
-rw-r--r--gdb/xml-tdesc.c21
15 files changed, 175 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 28a37db..fccad0b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,36 @@
+2009-07-20 Pedro Alves <pedro@codesourcery.com>
+
+ * features/gdb-target.dtd (target): Accept an optional 'osabi'
+ element.
+ (osabi): Define element.
+ * features/mips-linux.xml (target): Add an osabi subelement set to
+ GNU/Linux.
+ * regformats/regdat.sh (xmlarch, xmlosabi): New variables. Don't
+ write the architecture into $xmltarget. Store it in $xmlarch.
+ Handle the 'osabi' type. Handle outputting the osabi element of
+ the target description.
+ * regformats/reg-x86-64-linux.dat (osabi): Set to GNU/Linux.
+ * regformats/reg-i386-linux.dat (osabi): Set to GNU/Linux.
+
+ * target-descriptions.h (tdesc_osabi, set_tdesc_osabi): Declare.
+ * target-descriptions.c (struct target_desc) <osabi>: New field.
+ (tdesc_osabi): New function.
+ (set_tdesc_osabi): New function.
+ * xml-tdesc.c: Include osabi.h.
+ (tdesc_end_osabi): New.
+ (target_children): Parse "osabi" elements.
+ * arch-utils.c (gdbarch_info_fill): Try to get the osabi from the
+ target description if the user didn't override it or it is not
+ extractable from the bfd. If that still fails, fallback to the
+ configured in default.
+ * osabi.h (osabi_from_tdesc_string): Declare.
+ * osabi.c (osabi_from_tdesc_string): New.
+ (gdbarch_lookup_osabi): Return GDB_OSABI_UNKNOWN instead of
+ GDB_OSABI_DEFAULT.
+
+ * NEWS: Mention that target descriptions can now describe the
+ target OS ABI.
+
2009-07-20 Mike Frysinger <vapier@gentoo.org>
* configure.ac (AC_CHECK_FUNCS): Check for pipe.
diff --git a/gdb/NEWS b/gdb/NEWS
index 22757d9..7dcc8fc 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -194,6 +194,10 @@ add new commands to existing prefixes, e.g. "target".
visible changes; see "New commands" and also "Removed commands"
below.
+* Target descriptions can now describe the target OS ABI. 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 188dc9b..458aa06 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -710,8 +710,15 @@ gdbarch_info_fill (struct gdbarch_info *info)
info->byte_order_for_code = info->byte_order;
/* "(gdb) set osabi ...". Handled by gdbarch_lookup_osabi. */
+ /* From the manual override, or from file. */
if (info->osabi == GDB_OSABI_UNINITIALIZED)
info->osabi = gdbarch_lookup_osabi (info->abfd);
+ /* From the target. */
+ if (info->osabi == GDB_OSABI_UNKNOWN && info->target_desc != NULL)
+ info->osabi = tdesc_osabi (info->target_desc);
+ /* From the configured default. */
+ if (info->osabi == GDB_OSABI_UNKNOWN)
+ info->osabi = GDB_OSABI_DEFAULT;
/* Must have at least filled in the architecture. */
gdb_assert (info->bfd_arch_info != NULL);
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 01fb199..c0279a7 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,9 @@
+2009-07-20 Pedro Alves <pedro@codesourcery.com>
+
+ * gdb.texinfo (Target Description Format): Mention the new <osabi>
+ optional element.
+ (subsection OS ABI): New subsection.
+
2009-07-14 Stan Shebs <stan@codesourcery.com>
* gdb.texinfo (Tracepoint Conditions): New section.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 71ae4b5..c3693fa 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -30781,7 +30781,8 @@ their targets, we also describe the grammar here.
Target descriptions can identify the architecture of the remote target
and (for some architectures) provide information about custom register
-sets. @value{GDBN} can use this information to autoconfigure for your
+sets. They can also identify the OS ABI of the remote target.
+@value{GDBN} can use this information to autoconfigure for your
target, or to warn you if you connect to an unsupported target.
Here is a simple target description:
@@ -30805,6 +30806,7 @@ are explained further below.
<!DOCTYPE target SYSTEM "gdb-target.dtd">
<target version="1.0">
@r{[}@var{architecture}@r{]}
+ @r{[}@var{osabi}@r{]}
@r{[}@var{feature}@dots{}@r{]}
</target>
@end smallexample
@@ -30860,6 +30862,21 @@ An @samp{<architecture>} element has this form:
accepted by @code{set architecture} (@pxref{Targets, ,Specifying a
Debugging Target}).
+@subsection OS ABI
+@cindex @code{<osabi>}
+
+This optional field was introduced in @value{GDBN} version 7.0.
+Previous versions of @value{GDBN} ignore it.
+
+An @samp{<osabi>} element has this form:
+
+@smallexample
+ <osabi>@var{abi-name}</osabi>
+@end smallexample
+
+@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 Features
@cindex <feature>
diff --git a/gdb/features/gdb-target.dtd b/gdb/features/gdb-target.dtd
index 2b195de..ff5d3d5 100644
--- a/gdb/features/gdb-target.dtd
+++ b/gdb/features/gdb-target.dtd
@@ -6,12 +6,17 @@
<!-- The root element of a GDB target description is <target>. -->
-<!ELEMENT target (architecture?, feature*)>
+<!-- The osabi element was added post GDB 6.8. The version wasn't
+ bumped, since older GDBs silently ignore unknown elements. -->
+
+<!ELEMENT target (architecture?, osabi?, feature*)>
<!ATTLIST target
version CDATA #FIXED "1.0">
<!ELEMENT architecture (#PCDATA)>
+<!ELEMENT osabi (#PCDATA)>
+
<!ELEMENT feature ((vector | union)*, reg*)>
<!ATTLIST feature
name ID #REQUIRED>
diff --git a/gdb/features/mips-linux.xml b/gdb/features/mips-linux.xml
index 274f3d9..9772c82 100644
--- a/gdb/features/mips-linux.xml
+++ b/gdb/features/mips-linux.xml
@@ -8,6 +8,7 @@
<!DOCTYPE target SYSTEM "gdb-target.dtd">
<target>
<architecture>mips</architecture>
+ <osabi>GNU/Linux</osabi>
<xi:include href="mips-cpu.xml"/>
<xi:include href="mips-cp0.xml"/>
<xi:include href="mips-fpu.xml"/>
diff --git a/gdb/osabi.c b/gdb/osabi.c
index 778dedc..a8ecc8c 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -87,6 +87,30 @@ gdbarch_osabi_name (enum gdb_osabi osabi)
return gdb_osabi_names[GDB_OSABI_INVALID];
}
+/* Lookup the OS ABI corresponding to the specified target description
+ string. */
+
+enum gdb_osabi
+osabi_from_tdesc_string (const char *name)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE (gdb_osabi_names); i++)
+ if (strcmp (name, gdb_osabi_names[i]) == 0)
+ {
+ /* See note above: the name table matches the indices assigned
+ to enum gdb_osabi. */
+ enum gdb_osabi osabi = (enum gdb_osabi) i;
+
+ if (osabi == GDB_OSABI_INVALID)
+ return GDB_OSABI_UNKNOWN;
+ else
+ return osabi;
+ }
+
+ return GDB_OSABI_UNKNOWN;
+}
+
/* Handler for a given architecture/OS ABI pair. There should be only
one handler for a given OS ABI each architecture family. */
struct gdb_osabi_handler
@@ -205,10 +229,11 @@ gdbarch_lookup_osabi (bfd *abfd)
if (user_osabi_state == osabi_user)
return user_selected_osabi;
- /* If we don't have a binary, return the default OS ABI (if set) or
- unknown (otherwise). */
+ /* If we don't have a binary, just return unknown. The caller may
+ have other sources the OSABI can be extracted from, e.g., the
+ target description. */
if (abfd == NULL)
- return GDB_OSABI_DEFAULT;
+ return GDB_OSABI_UNKNOWN;
match = GDB_OSABI_UNKNOWN;
match_specific = 0;
@@ -269,12 +294,7 @@ gdbarch_lookup_osabi (bfd *abfd)
}
}
- /* If we didn't find a match, but a default was specified at configure
- time, return the default. */
- if (GDB_OSABI_DEFAULT != GDB_OSABI_UNKNOWN && match == GDB_OSABI_UNKNOWN)
- return GDB_OSABI_DEFAULT;
- else
- return match;
+ return match;
}
diff --git a/gdb/osabi.h b/gdb/osabi.h
index c1aa336..0b4a382 100644
--- a/gdb/osabi.h
+++ b/gdb/osabi.h
@@ -40,6 +40,10 @@ void gdbarch_register_osabi (enum bfd_architecture, unsigned long,
/* Lookup the OS ABI corresponding to the specified BFD. */
enum gdb_osabi gdbarch_lookup_osabi (bfd *);
+/* Lookup the OS ABI corresponding to the specified target description
+ string. */
+enum gdb_osabi osabi_from_tdesc_string (const char *text);
+
/* Initialize the gdbarch for the specified OS ABI variant. */
void gdbarch_init_osabi (struct gdbarch_info, struct gdbarch *);
diff --git a/gdb/regformats/reg-i386-linux.dat b/gdb/regformats/reg-i386-linux.dat
index 8ea3d11..33452ac 100644
--- a/gdb/regformats/reg-i386-linux.dat
+++ b/gdb/regformats/reg-i386-linux.dat
@@ -1,5 +1,6 @@
name:i386_linux
xmlarch:i386
+osabi:GNU/Linux
expedite:ebp,esp,eip
32:eax
32:ecx
diff --git a/gdb/regformats/reg-x86-64-linux.dat b/gdb/regformats/reg-x86-64-linux.dat
index 656f72a..6121db9 100644
--- a/gdb/regformats/reg-x86-64-linux.dat
+++ b/gdb/regformats/reg-x86-64-linux.dat
@@ -1,5 +1,6 @@
name:x86_64_linux
xmlarch:i386:x86-64
+osabi:GNU/Linux
expedite:rbp,rsp,rip
64:rax
64:rbx
diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index e75beea..b04df7f 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -128,6 +128,8 @@ offset=0
i=0
name=x
xmltarget=x
+xmlarch=x
+xmlosabi=x
expedite=x
exec < $1
while do_read
@@ -140,7 +142,10 @@ do
xmltarget="${entry}"
continue
elif test "${type}" = "xmlarch"; then
- xmltarget="@<target><architecture>${entry}</architecture></target>"
+ xmlarch="${entry}"
+ continue
+ elif test "${type}" = "osabi"; then
+ xmlosabi="${entry}"
continue
elif test "${type}" = "expedite"; then
expedite="${entry}"
@@ -159,7 +164,18 @@ echo "};"
echo
echo "const char *expedite_regs_${name}[] = { \"`echo ${expedite} | sed 's/,/", "/g'`\", 0 };"
if test "${xmltarget}" = x; then
- echo "const char *xmltarget_${name} = 0;"
+ if test "${xmlarch}" = x && test "${xmlosabi}" = x; then
+ echo "const char *xmltarget_${name} = 0;"
+ else
+ echo "const char *xmltarget_${name} = \"@<target>\\"
+ if test "${xmlarch}" != x; then
+ echo "<architecture>${xmlarch}</architecture>\\"
+ fi
+ if test "${xmlosabi}" != x; then
+ echo "<osabi>${xmlosabi}</osabi>\\"
+ fi
+ echo "</target>\";"
+ fi
else
echo "const char *xmltarget_${name} = \"${xmltarget}\";"
fi
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 741ea65..88cc7e0 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -165,6 +165,10 @@ 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;
+
/* Any architecture-specific properties specified by the target. */
VEC(property_s) *properties;
@@ -351,6 +355,16 @@ tdesc_architecture (const struct target_desc *target_desc)
{
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;
+}
+
/* Return 1 if this target description includes any registers. */
@@ -1161,6 +1175,12 @@ set_tdesc_architecture (struct target_desc *target_desc,
{
target_desc->arch = arch;
}
+
+void
+set_tdesc_osabi (struct target_desc *target_desc, enum gdb_osabi osabi)
+{
+ target_desc->osabi = osabi;
+}
static struct cmd_list_element *tdesc_set_cmdlist, *tdesc_show_cmdlist;
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index e6842d7..6553fc3 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -123,6 +123,11 @@ int tdesc_numbered_register_choices (const struct tdesc_feature *feature,
const struct bfd_arch_info *tdesc_architecture
(const struct target_desc *);
+/* 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 *);
+
/* Return the string value of a property named KEY, or NULL if the
property was not specified. */
@@ -167,6 +172,7 @@ struct target_desc *allocate_target_description (void);
struct cleanup *make_cleanup_free_target_description (struct target_desc *);
void set_tdesc_architecture (struct target_desc *,
const struct bfd_arch_info *);
+void set_tdesc_osabi (struct target_desc *, enum gdb_osabi osabi);
void set_tdesc_property (struct target_desc *,
const char *key, const char *value);
diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c
index 6987bee..5fd8a41 100644
--- a/gdb/xml-tdesc.c
+++ b/gdb/xml-tdesc.c
@@ -24,6 +24,7 @@
#include "target-descriptions.h"
#include "xml-support.h"
#include "xml-tdesc.h"
+#include "osabi.h"
#include "filenames.h"
@@ -105,6 +106,24 @@ tdesc_end_arch (struct gdb_xml_parser *parser,
set_tdesc_architecture (data->tdesc, arch);
}
+/* Handle the end of an <osabi> element and its value. */
+
+static void
+tdesc_end_osabi (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;
+ enum gdb_osabi osabi;
+
+ osabi = osabi_from_tdesc_string (body_text);
+ if (osabi == GDB_OSABI_UNKNOWN)
+ warning (_("Target description specified unknown osabi \"%s\""),
+ body_text);
+ else
+ set_tdesc_osabi (data->tdesc, osabi);
+}
+
/* Handle the start of a <target> element. */
static void
@@ -313,6 +332,8 @@ static const struct gdb_xml_attribute target_attributes[] = {
static const struct gdb_xml_element target_children[] = {
{ "architecture", NULL, NULL, GDB_XML_EF_OPTIONAL,
NULL, tdesc_end_arch },
+ { "osabi", NULL, NULL, GDB_XML_EF_OPTIONAL,
+ NULL, tdesc_end_osabi },
{ "feature", feature_attributes, feature_children,
GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
tdesc_start_feature, NULL },