aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog19
-rw-r--r--gdb/gdbserver/linux-x86-tdesc.c24
-rw-r--r--gdb/gdbserver/server.c10
-rw-r--r--gdb/gdbserver/tdesc.c62
-rw-r--r--gdb/gdbserver/tdesc.h34
5 files changed, 121 insertions, 28 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 20a0c97..595faf5 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,24 @@
2017-09-05 Yao Qi <yao.qi@linaro.org>
+ * linux-x86-tdesc.c: Don't include <inttypes.h>.
+ (i386_linux_read_description) [!IN_PROCESS_AGENT]: Call
+ set_tdesc_architecture and set_tdesc_osabi. Remove code setting
+ .xmltarget.
+ * server.c (get_features_xml): Call tdesc_get_features_xml.
+ * tdesc.c (set_tdesc_architecture): New function.
+ (set_tdesc_osabi): New function.
+ (tdesc_get_features_xml): New function.
+ (tdesc_create_feature): Add an argument.
+ * tdesc.h (struct target_desc) <features>: New field.
+ <arch, osabi>: New field.
+ (~target_desc): xfree features, arch, and osabi.
+ (target_desc::oerator==): Don't compare .xmltarget.
+ [!IN_PROCESS_AGENT] (set_tdesc_architecture): Declare.
+ (set_tdesc_osabi): Likewise.
+ (tdesc_get_features_xml): Likewise.
+
+2017-09-05 Yao Qi <yao.qi@linaro.org>
+
* linux-x86-tdesc.c: Include selftest.h.
(i386_tdesc_test): New function.
(initialize_low_tdesc): Call selftests::register_test.
diff --git a/gdb/gdbserver/linux-x86-tdesc.c b/gdb/gdbserver/linux-x86-tdesc.c
index 1f3dbaf..3f63d8e 100644
--- a/gdb/gdbserver/linux-x86-tdesc.c
+++ b/gdb/gdbserver/linux-x86-tdesc.c
@@ -21,7 +21,6 @@
#include "tdesc.h"
#include "linux-x86-tdesc.h"
#include "x86-xstate.h"
-#include <inttypes.h>
#if defined __i386__ || !defined IN_PROCESS_AGENT
#include "../features/i386/32bit-core.c"
@@ -145,6 +144,11 @@ i386_linux_read_description (uint64_t xcr0)
{
*tdesc = new target_desc ();
+#ifndef IN_PROCESS_AGENT
+ set_tdesc_architecture (*tdesc, "i386");
+ set_tdesc_osabi (*tdesc, "GNU/Linux");
+#endif
+
long regnum = 0;
if (xcr0 & X86_XSTATE_X87)
@@ -172,24 +176,6 @@ i386_linux_read_description (uint64_t xcr0)
#ifndef IN_PROCESS_AGENT
static const char *expedite_regs_i386[] = { "ebp", "esp", "eip", NULL };
(*tdesc)->expedite_regs = expedite_regs_i386;
-
- if (xcr0 & X86_XSTATE_PKRU)
- (*tdesc)->xmltarget = "i386-avx-mpx-avx512-pku-linux.xml";
- else if (xcr0 & X86_XSTATE_AVX512)
- (*tdesc)->xmltarget = "i386-avx-avx512-linux.xml";
- else if ((xcr0 & X86_XSTATE_AVX_MPX_MASK) == X86_XSTATE_AVX_MPX_MASK)
- (*tdesc)->xmltarget = "i386-avx-mpx-linux.xml";
- else if (xcr0 & X86_XSTATE_MPX)
- (*tdesc)->xmltarget = "i386-mpx-linux.xml";
- else if (xcr0 & X86_XSTATE_AVX)
- (*tdesc)->xmltarget = "i386-avx-linux.xml";
- else if (xcr0 & X86_XSTATE_SSE)
- (*tdesc)->xmltarget = "i386-linux.xml";
- else if (xcr0 & X86_XSTATE_X87)
- (*tdesc)->xmltarget = "i386-mmx-linux.xml";
- else
- internal_error (__FILE__, __LINE__,
- "unknown xcr0: %" PRIu64, xcr0);
#endif
}
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 7210d1f..56c6393 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -873,12 +873,14 @@ get_features_xml (const char *annex)
This variable is set up from the auto-generated
init_registers_... routine for the current target. */
- if (desc->xmltarget != NULL && strcmp (annex, "target.xml") == 0)
+ if (strcmp (annex, "target.xml") == 0)
{
- if (*desc->xmltarget == '@')
- return desc->xmltarget + 1;
+ const char *ret = tdesc_get_features_xml ((target_desc*) desc);
+
+ if (*ret == '@')
+ return ret + 1;
else
- annex = desc->xmltarget;
+ annex = ret;
}
#ifdef USE_XML
diff --git a/gdb/gdbserver/tdesc.c b/gdb/gdbserver/tdesc.c
index 4504c9b..0b5096b 100644
--- a/gdb/gdbserver/tdesc.c
+++ b/gdb/gdbserver/tdesc.c
@@ -61,6 +61,62 @@ current_target_desc (void)
return current_process ()->tdesc;
}
+
+void
+set_tdesc_architecture (struct target_desc *target_desc,
+ const char *name)
+{
+ target_desc->arch = xstrdup (name);
+}
+
+void
+set_tdesc_osabi (struct target_desc *target_desc, const char *name)
+{
+ target_desc->osabi = xstrdup (name);
+}
+
+/* Return a string which is of XML format, including XML target
+ description to be sent to GDB. */
+
+const char *
+tdesc_get_features_xml (target_desc *tdesc)
+{
+ /* Either .xmltarget or .features is not NULL. */
+ gdb_assert (tdesc->xmltarget != NULL
+ || (tdesc->features != NULL
+ && tdesc->arch != NULL
+ && tdesc->osabi != NULL));
+
+ if (tdesc->xmltarget == NULL)
+ {
+ std::string buffer ("@<?xml version=\"1.0\"?>");
+
+ buffer += "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">";
+ buffer += "<target>";
+ buffer += "<architecture>";
+ buffer += tdesc->arch;
+ buffer += "</architecture>";
+
+ buffer += "<osabi>";
+ buffer += tdesc->osabi;
+ buffer += "</osabi>";
+
+ char *xml;
+
+ for (int i = 0; VEC_iterate (char_ptr, tdesc->features, i, xml); i++)
+ {
+ buffer += "<xi:include href=\"";
+ buffer += xml;
+ buffer += "\"/>";
+ }
+
+ buffer += "</target>";
+
+ tdesc->xmltarget = xstrdup (buffer.c_str ());
+ }
+
+ return tdesc->xmltarget;
+}
#endif
struct tdesc_type
@@ -69,8 +125,12 @@ struct tdesc_type
/* See arch/tdesc.h. */
struct tdesc_feature *
-tdesc_create_feature (struct target_desc *tdesc, const char *name)
+tdesc_create_feature (struct target_desc *tdesc, const char *name,
+ const char *xml)
{
+#ifndef IN_PROCESS_AGENT
+ VEC_safe_push (char_ptr, tdesc->features, xstrdup (xml));
+#endif
return tdesc;
}
diff --git a/gdb/gdbserver/tdesc.h b/gdb/gdbserver/tdesc.h
index 49c82c6..fe3c78f 100644
--- a/gdb/gdbserver/tdesc.h
+++ b/gdb/gdbserver/tdesc.h
@@ -49,9 +49,21 @@ struct target_desc : tdesc_feature
/* Defines what to return when looking for the "target.xml" file in
response to qXfer:features:read. Its contents can either be
verbatim XML code (prefixed with a '@') or else the name of the
- actual XML file to be used in place of "target.xml". */
+ actual XML file to be used in place of "target.xml".
+
+ It can be NULL, then, its content is got from the following three
+ fields features, arch, and osabi in tdesc_get_features_xml. */
const char *xmltarget = NULL;
+ /* XML features in this target description. */
+ VEC (char_ptr) *features = NULL;
+
+ /* The value of <architecture> element in the XML, replying GDB. */
+ const char *arch = NULL;
+
+ /* The value of <osabi> element in the XML, replying GDB. */
+ const char *osabi = NULL;
+
public:
target_desc ()
: reg_defs (NULL), registers_size (0)
@@ -65,6 +77,15 @@ public:
for (i = 0; VEC_iterate (tdesc_reg_p, reg_defs, i, reg); i++)
xfree (reg);
VEC_free (tdesc_reg_p, reg_defs);
+
+ xfree ((char *) arch);
+ xfree ((char *) osabi);
+
+ char *f;
+
+ for (i = 0; VEC_iterate (char_ptr, features, i, f); i++)
+ xfree (f);
+ VEC_free (char_ptr, features);
}
bool operator== (const target_desc &other) const
@@ -96,9 +117,6 @@ public:
if (other.expedite_regs[i] != NULL)
return false;
- if (strcmp (xmltarget, other.xmltarget) != 0)
- return false;
-
return true;
}
@@ -123,4 +141,12 @@ void init_target_desc (struct target_desc *tdesc);
const struct target_desc *current_target_desc (void);
+#ifndef IN_PROCESS_AGENT
+void set_tdesc_architecture (struct target_desc *target_desc,
+ const char *name);
+void set_tdesc_osabi (struct target_desc *target_desc, const char *name);
+
+const char *tdesc_get_features_xml (struct target_desc *tdesc);
+#endif
+
#endif /* TDESC_H */