]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix gdbserver <library-list> and its #FIXED version="1.0"
authorJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 10 Jun 2015 16:29:05 +0000 (18:29 +0200)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 10 Jun 2015 16:30:10 +0000 (18:30 +0200)
While reimplementing <library-list/> I found from expat-2.0.1-11.fc15.x86_64:

warning: while parsing target library list (at line 1): Required attribute "version" of <library-list-svr4> not specified

I believe the same bug has to apply for existing FSF gdbserver but I do not
have any <library-list/> platform to test it (I did not try to build MinGW).

features/library-list.dtd:
<!ATTLIST library-list  version CDATA   #FIXED  "1.0">

http://www.xml.com/pub/a/98/10/guide0.html?page=3 says:

In this case, the attribute is not required, but if it occurs, it must
have the specified value.

Which would suggest gdbserver is right but solib-target.c is wrong.  One could
also make gdbserver explicit for the version (if those 14 bytes are not of
a concern).

gdb/ChangeLog
2015-06-10  Jan Kratochvil  <jan.kratochvil@redhat.com>

* solib-target.c (library_list_start_list): Do not dereference
variable version in its initialization.  Make the VERSION check handle
NULL.
(library_list_attributes): Make "version" GDB_XML_AF_OPTIONAL.

gdb/gdbserver/ChangeLog
2015-06-10  Jan Kratochvil  <jan.kratochvil@redhat.com>

* server.c (handle_qxfer_libraries): Set `version' attribute for
<library-list>.

gdb/ChangeLog
gdb/gdbserver/ChangeLog
gdb/gdbserver/server.c
gdb/solib-target.c

index 55b7d4f0905aeb6785b83bcb02812b20e09f646d..83845f4c809019b636aef8383785e7cf75818873 100644 (file)
@@ -1,3 +1,10 @@
+2015-06-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * solib-target.c (library_list_start_list): Do not dereference
+       variable version in its initialization.  Make the VERSION check handle
+       NULL.
+       (library_list_attributes): Make "version" GDB_XML_AF_OPTIONAL.
+
 2015-06-10  Gary Benson <gbenson@redhat.com>
 
        * NEWS: Announce support for direct access of executable and
index 5c3e44f720e8130099d6127fb82318e11d866c57..5d5f0a435afd1ce48fcc181a6600e82a0684afbe 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * server.c (handle_qxfer_libraries): Set `version' attribute for
+       <library-list>.
+
 2015-06-10  Gary Benson  <gbenson@redhat.com>
 
        * target.h (struct target_ops) <multifs_open>: New field.
index 70fbefbd65d23273a98d11cb637c215a5347493d..01b9c962635286ab8946aaa8baad529641613df1 100644 (file)
@@ -1291,7 +1291,7 @@ handle_qxfer_libraries (const char *annex,
   if (document == NULL)
     return -1;
 
-  strcpy (document, "<library-list>\n");
+  strcpy (document, "<library-list version=\"1.0\">\n");
   p = document + strlen (document);
 
   for_each_inferior_with_data (&all_dlls, emit_dll_description, &p);
index bd8f58ad8c7b72e06d471cb812c99ffc4a4752b9..891e5729ab1f8bf0af466e6898e5688a3a9b7fd0 100644 (file)
@@ -146,12 +146,18 @@ library_list_start_list (struct gdb_xml_parser *parser,
                         const struct gdb_xml_element *element,
                         void *user_data, VEC(gdb_xml_value_s) *attributes)
 {
-  char *version = xml_find_attribute (attributes, "version")->value;
+  struct gdb_xml_value *version = xml_find_attribute (attributes, "version");
 
-  if (strcmp (version, "1.0") != 0)
-    gdb_xml_error (parser,
-                  _("Library list has unsupported version \"%s\""),
-                  version);
+  /* #FIXED attribute may be omitted, Expat returns NULL in such case.  */
+  if (version)
+    {
+      const char *string = version->value;
+
+      if (strcmp (string, "1.0") != 0)
+       gdb_xml_error (parser,
+                      _("Library list has unsupported version \"%s\""),
+                      version);
+    }
 }
 
 /* Discard the constructed library list.  */
@@ -210,7 +216,7 @@ static const struct gdb_xml_element library_list_children[] = {
 };
 
 static const struct gdb_xml_attribute library_list_attributes[] = {
-  { "version", GDB_XML_AF_NONE, NULL, NULL },
+  { "version", GDB_XML_AF_OPTIONAL, NULL, NULL },
   { NULL, GDB_XML_AF_NONE, NULL, NULL }
 };