Initialize gdb::optional empty payload to quiet false -Wmaybe-uninitialized warnings
[deliverable/binutils-gdb.git] / gdb / xml-tdesc.c
index aa58385df9fe6d4bcd0b44edecedfe1214b4e3ed..d24c5ad88b591a481ee71ddf623e8566faebff2a 100644 (file)
@@ -1,6 +1,6 @@
 /* XML target description support for GDB.
 
-   Copyright (C) 2006-2016 Free Software Foundation, Inc.
+   Copyright (C) 2006-2017 Free Software Foundation, Inc.
 
    Contributed by CodeSourcery.
 
@@ -382,13 +382,19 @@ tdesc_start_field (struct gdb_xml_parser *parser,
     {
       struct tdesc_type *t = data->current_type;
 
+      /* Older versions of gdb can't handle elided end values.
+         Stick with that for now, to help ensure backward compatibility.
+        E.g., If a newer gdbserver is talking to an older gdb.  */
+      if (end == -1)
+       gdb_xml_error (parser, _("Missing end value"));
+
       if (data->current_type_size == 0)
        gdb_xml_error (parser,
                       _("Bitfields must live in explicitly sized types"));
 
       if (field_type_id != NULL
          && strcmp (field_type_id, "bool") == 0
-         && !(start == end || end == -1))
+         && start != end)
        {
          gdb_xml_error (parser,
                         _("Boolean fields must be one bit in size"));
@@ -400,29 +406,20 @@ tdesc_start_field (struct gdb_xml_parser *parser,
                         "64 bits (unsupported)"),
                       field_name);
 
-      if (end != -1)
-       {
-         /* Assume that the bit numbering in XML is "lsb-zero".  Most
-            architectures other than PowerPC use this ordering.  In the
-            future, we can add an XML tag to indicate "msb-zero"
-            numbering.  */
-         if (start > end)
-           gdb_xml_error (parser, _("Bitfield \"%s\" has start after end"),
-                          field_name);
-         if (end >= data->current_type_size * TARGET_CHAR_BIT)
-           gdb_xml_error (parser,
-                          _("Bitfield \"%s\" does not fit in struct"));
-       }
+      /* Assume that the bit numbering in XML is "lsb-zero".  Most
+        architectures other than PowerPC use this ordering.  In the
+        future, we can add an XML tag to indicate "msb-zero" numbering.  */
+      if (start > end)
+       gdb_xml_error (parser, _("Bitfield \"%s\" has start after end"),
+                      field_name);
+      if (end >= data->current_type_size * TARGET_CHAR_BIT)
+       gdb_xml_error (parser, _("Bitfield \"%s\" does not fit in struct"),
+                      field_name);
 
-      if (end == -1)
-       {
-         if (field_type != NULL)
-           tdesc_add_typed_bitfield (t, field_name, start, start, field_type);
-         else
-           tdesc_add_flag (t, start, field_name);
-       }
-      else if (field_type != NULL)
+      if (field_type != NULL)
        tdesc_add_typed_bitfield (t, field_name, start, end, field_type);
+      else if (start == end)
+       tdesc_add_flag (t, start, field_name);
       else
        tdesc_add_bitfield (t, field_name, start, end);
     }
@@ -697,7 +694,6 @@ file_read_description_xml (const char *filename)
   struct target_desc *tdesc;
   char *tdesc_str;
   struct cleanup *back_to;
-  char *dirname;
 
   tdesc_str = xml_fetch_content_from_file (filename, NULL);
   if (tdesc_str == NULL)
@@ -708,11 +704,8 @@ file_read_description_xml (const char *filename)
 
   back_to = make_cleanup (xfree, tdesc_str);
 
-  dirname = ldirname (filename);
-  if (dirname != NULL)
-    make_cleanup (xfree, dirname);
-
-  tdesc = tdesc_parse_xml (tdesc_str, xml_fetch_content_from_file, dirname);
+  tdesc = tdesc_parse_xml (tdesc_str, xml_fetch_content_from_file,
+                          (void *) ldirname (filename).c_str ());
   do_cleanups (back_to);
 
   return tdesc;
This page took 0.024732 seconds and 4 git commands to generate.