From 0abe8a8992948559d225ff120095e42a1a6a36f4 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Tue, 5 Sep 2017 09:54:53 +0100 Subject: 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 ... ... 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 * 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 * linux-x86-tdesc.c: Don't include . (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) : New field. : 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. --- gdb/target-descriptions.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gdb/target-descriptions.c') diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index f0ced66..6135e0d 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -1750,7 +1750,8 @@ tdesc_add_enum_value (struct tdesc_type *type, int value, /* 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) { struct tdesc_feature *new_feature = new tdesc_feature (name); @@ -2202,8 +2203,10 @@ public: printf_unfiltered ("{\n"); printf_unfiltered (" struct tdesc_feature *feature;\n"); - printf_unfiltered ("\n feature = tdesc_create_feature (result, \"%s\");\n", - e->name); + + printf_unfiltered + ("\n feature = tdesc_create_feature (result, \"%s\", \"%s\");\n", + e->name, lbasename (m_filename_after_features.c_str ())); } void visit_post (const tdesc_feature *e) override -- cgit v1.1