aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/tdesc.h
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2017-09-05 09:54:53 +0100
committerYao Qi <yao.qi@linaro.org>2017-09-05 09:54:53 +0100
commit0abe8a8992948559d225ff120095e42a1a6a36f4 (patch)
treeb04557a71db21b7d636d7bbf2285ee502ce8ea6e /gdb/gdbserver/tdesc.h
parent0a188386c032126045979b7fb7c238d715c81eb5 (diff)
downloadgdb-0abe8a8992948559d225ff120095e42a1a6a36f4.zip
gdb-0abe8a8992948559d225ff120095e42a1a6a36f4.tar.gz
gdb-0abe8a8992948559d225ff120095e42a1a6a36f4.tar.bz2
Dynamically composite xml in reply to GDB
GDBserver still uses pre-generated target descriptions in order to reply to GDB's query on target description (see xml-builtin-generated.c in GDBserver build directory). This patch teaches GDBserver to create XML contents according to the target descriptions rather than using pre-generated ones. First, change target feature c files to pass the feature xml file name to tdesc_create_feature, so that target description in GDBserver can record them, and create XML contents from these features in buffer, like ... <xi:include href="$FEATURE1_XML_NAME"/> <xi:include href="$FEATURE2_XML_NAME"/> ... and send this buffer back to GDB. Note that this patch reuses target_desc.xmltarget a little bit, which is to hold the XML contents dynamically generated in tdesc_get_features_xml. However, it is not xfree'ed in ~target_desc, because we can't tell it is from xstrdup or a literal string. Since we don't delete target_desc, there is no memory leak yet. After we change all target descriptions to the new style, target_desc.xmltarget is from xstrdup, then, we can safely xfree it in ~target_desc. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * arch/tdesc.h (tdesc_create_feature): Add an argument xml. * target-descriptions.c (tdesc_create_feature): Likewise, and adjust code. * features/i386/32bit-avx.c: Re-generated. * features/i386/32bit-avx512.c: Re-generated. * features/i386/32bit-core.c: Re-generated. * features/i386/32bit-linux.c: Re-generated. * features/i386/32bit-mpx.c: Re-generated. * features/i386/32bit-pkeys.c: Re-generated. * features/i386/32bit-sse.c: Re-generated. gdb/gdbserver: 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.
Diffstat (limited to 'gdb/gdbserver/tdesc.h')
-rw-r--r--gdb/gdbserver/tdesc.h34
1 files changed, 30 insertions, 4 deletions
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 */