diff mbox

[2/2] Fix backward compatibility in target feature specs

Message ID f46d042ef767542c7e05399546e5@google.com
State New
Headers show

Commit Message

Doug Evans Aug. 8, 2016, 8:29 p.m. UTC
Hi.

Per discussion here:

https://sourceware.org/ml/gdb-patches/2016-08/msg00103.html

this patch restores making "end" a required spec,
and defaults single bit fields to type "bool".

This also fixes a typo in 32bit-mpx.xml,
and adds a specific type to the "preserved" and "enabled" fields
to minimize changes in the generated files.

I think the size of _bndcfgu is wrong in 32bit-mpx.xml,
but fixing that is the topic of a separate patch.

2016-08-08  Doug Evans  <dje@google.com>

	* features/aarch64-core.xml (cpsr_flags): Elide "type" and specify
	"end" in all fields.
	* features/aarch64.c: Regenerate.
	* features/i386/32bit-mpx.xml (_bndcfgu): Specify type of "preserved"
	and "enabled" fields. Correct size of "enabled" field.
	* features/i386/64bit-mpx.xml (_bndcfgu): Specify type of "preserved"
	and "enabled" fields.
	* features/i386/i386-avx-mpx-linux.c: Regenerate.
	* features/i386/i386-avx-mpx.c: Regenerate.
	* features/i386/i386-avx512-linux.c: Regenerate.
	* features/i386/i386-avx512.c: Regenerate.
	* features/i386/i386-mpx-linux.c: Regenerate.
	* features/i386/i386-mpx.c: Regenerate.
	* xml-tdesc.c (tdesc_start_field): Require "end" spec.  Single bit
	fields default to "bool" type.
diff mbox

Patch

diff --git a/gdb/features/aarch64-core.xml b/gdb/features/aarch64-core.xml
index 8f96296..7ff064d 100644
--- a/gdb/features/aarch64-core.xml
+++ b/gdb/features/aarch64-core.xml
@@ -44,23 +44,23 @@ 
    <reg name="pc" bitsize="64" type="code_ptr"/>

    <flags id="cpsr_flags" size="4">
-    <field name="SP" start="0" type="bool"/>
+    <field name="SP" start="0" end="0"/>
      <field name="" start="1" end="1"/>
      <field name="EL" start="2" end="3"/>
-    <field name="nRW" start="4" type="bool"/>
+    <field name="nRW" start="4" end="4"/>
      <field name="" start="5" end="5"/>
-    <field name="F" start="6" type="bool"/>
-    <field name="I" start="7" type="bool"/>
-    <field name="A" start="8" type="bool"/>
-    <field name="D" start="9" type="bool"/>
+    <field name="F" start="6" end="6"/>
+    <field name="I" start="7" end="7"/>
+    <field name="A" start="8" end="8"/>
+    <field name="D" start="9" end="9"/>

-    <field name="IL" start="20" type="bool"/>
-    <field name="SS" start="21" type="bool"/>
+    <field name="IL" start="20" end="20"/>
+    <field name="SS" start="21" end="21"/>

-    <field name="V" start="28" type="bool"/>
-    <field name="C" start="29" type="bool"/>
-    <field name="Z" start="30" type="bool"/>
-    <field name="N" start="31" type="bool"/>
+    <field name="V" start="28" end="28"/>
+    <field name="C" start="29" end="29"/>
+    <field name="Z" start="30" end="30"/>
+    <field name="N" start="31" end="31"/>
    </flags>
    <reg name="cpsr" bitsize="32" type="cpsr_flags"/>

diff --git a/gdb/features/aarch64.c b/gdb/features/aarch64.c
index cec6956..e9eaed8 100644
--- a/gdb/features/aarch64.c
+++ b/gdb/features/aarch64.c
@@ -19,10 +19,10 @@  initialize_tdesc_aarch64 (void)
    feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.core");
    type = tdesc_create_flags (feature, "cpsr_flags", 4);
    tdesc_add_flag (type, 0, "SP");
-  tdesc_add_bitfield (type, "", 1, 1);
+  tdesc_add_flag (type, 1, "");
    tdesc_add_bitfield (type, "EL", 2, 3);
    tdesc_add_flag (type, 4, "nRW");
-  tdesc_add_bitfield (type, "", 5, 5);
+  tdesc_add_flag (type, 5, "");
    tdesc_add_flag (type, 6, "F");
    tdesc_add_flag (type, 7, "I");
    tdesc_add_flag (type, 8, "A");
diff --git a/gdb/features/i386/32bit-mpx.xml  
b/gdb/features/i386/32bit-mpx.xml
index b1c0615..8d319cf 100644
--- a/gdb/features/i386/32bit-mpx.xml
+++ b/gdb/features/i386/32bit-mpx.xml
@@ -25,8 +25,10 @@ 
    <struct id="_bndcfgu" size="8">
      <field name="base" start="12" end="31" />
      <field name="reserved" start="2" end="11"/>
-    <field name="preserved" start="1" end="1"/>
-    <field name="enabled" start="0" end="1"/>
+    <!-- Explicitly set the type here, otherwise it defaults to bool.
+         Perhaps this should be uint32, but the container type has size  
8.  -->
+    <field name="preserved" start="1" end="1" type="uint64"/>
+    <field name="enabled" start="0" end="0" type="uint64"/>
    </struct>

     <union id="cfgu">
diff --git a/gdb/features/i386/64bit-mpx.xml  
b/gdb/features/i386/64bit-mpx.xml
index 279b537..877cc0f 100644
--- a/gdb/features/i386/64bit-mpx.xml
+++ b/gdb/features/i386/64bit-mpx.xml
@@ -25,8 +25,9 @@ 
    <struct id="_bndcfgu" size="8">
      <field name="base" start="12" end="63"/>
      <field name="reserved" start="2" end="11"/>
-    <field name="preserved" start="1" end="1"/>
-    <field name="enabled" start="0" end="0"/>
+    <!-- Explicitly set the type here, otherwise it defaults to bool.  -->
+    <field name="preserved" start="1" end="1" type="uint64"/>
+    <field name="enabled" start="0" end="0" type="uint64"/>
    </struct>

     <union id="cfgu">
diff --git a/gdb/features/i386/i386-avx-mpx-linux.c  
b/gdb/features/i386/i386-avx-mpx-linux.c
index 941f2b3..4b27bfc 100644
--- a/gdb/features/i386/i386-avx-mpx-linux.c
+++ b/gdb/features/i386/i386-avx-mpx-linux.c
@@ -168,7 +168,7 @@  initialize_tdesc_i386_avx_mpx_linux (void)
    tdesc_add_bitfield (type, "base", 12, 31);
    tdesc_add_bitfield (type, "reserved", 2, 11);
    tdesc_add_bitfield (type, "preserved", 1, 1);
-  tdesc_add_bitfield (type, "enabled", 0, 1);
+  tdesc_add_bitfield (type, "enabled", 0, 0);

    type = tdesc_create_union (feature, "cfgu");
    field_type = tdesc_named_type (feature, "data_ptr");
diff --git a/gdb/features/i386/i386-avx-mpx.c  
b/gdb/features/i386/i386-avx-mpx.c
index d822aac..b27b40a 100644
--- a/gdb/features/i386/i386-avx-mpx.c
+++ b/gdb/features/i386/i386-avx-mpx.c
@@ -163,7 +163,7 @@  initialize_tdesc_i386_avx_mpx (void)
    tdesc_add_bitfield (type, "base", 12, 31);
    tdesc_add_bitfield (type, "reserved", 2, 11);
    tdesc_add_bitfield (type, "preserved", 1, 1);
-  tdesc_add_bitfield (type, "enabled", 0, 1);
+  tdesc_add_bitfield (type, "enabled", 0, 0);

    type = tdesc_create_union (feature, "cfgu");
    field_type = tdesc_named_type (feature, "data_ptr");
diff --git a/gdb/features/i386/i386-avx512-linux.c  
b/gdb/features/i386/i386-avx512-linux.c
index 47a3319..0d3ab22 100644
--- a/gdb/features/i386/i386-avx512-linux.c
+++ b/gdb/features/i386/i386-avx512-linux.c
@@ -168,7 +168,7 @@  initialize_tdesc_i386_avx512_linux (void)
    tdesc_add_bitfield (type, "base", 12, 31);
    tdesc_add_bitfield (type, "reserved", 2, 11);
    tdesc_add_bitfield (type, "preserved", 1, 1);
-  tdesc_add_bitfield (type, "enabled", 0, 1);
+  tdesc_add_bitfield (type, "enabled", 0, 0);

    type = tdesc_create_union (feature, "cfgu");
    field_type = tdesc_named_type (feature, "data_ptr");
diff --git a/gdb/features/i386/i386-avx512.c  
b/gdb/features/i386/i386-avx512.c
index 6e8cb55..1cb68a1 100644
--- a/gdb/features/i386/i386-avx512.c
+++ b/gdb/features/i386/i386-avx512.c
@@ -163,7 +163,7 @@  initialize_tdesc_i386_avx512 (void)
    tdesc_add_bitfield (type, "base", 12, 31);
    tdesc_add_bitfield (type, "reserved", 2, 11);
    tdesc_add_bitfield (type, "preserved", 1, 1);
-  tdesc_add_bitfield (type, "enabled", 0, 1);
+  tdesc_add_bitfield (type, "enabled", 0, 0);

    type = tdesc_create_union (feature, "cfgu");
    field_type = tdesc_named_type (feature, "data_ptr");
diff --git a/gdb/features/i386/i386-mpx-linux.c  
b/gdb/features/i386/i386-mpx-linux.c
index 298b7ff..43ea192 100644
--- a/gdb/features/i386/i386-mpx-linux.c
+++ b/gdb/features/i386/i386-mpx-linux.c
@@ -158,7 +158,7 @@  initialize_tdesc_i386_mpx_linux (void)
    tdesc_add_bitfield (type, "base", 12, 31);
    tdesc_add_bitfield (type, "reserved", 2, 11);
    tdesc_add_bitfield (type, "preserved", 1, 1);
-  tdesc_add_bitfield (type, "enabled", 0, 1);
+  tdesc_add_bitfield (type, "enabled", 0, 0);

    type = tdesc_create_union (feature, "cfgu");
    field_type = tdesc_named_type (feature, "data_ptr");
diff --git a/gdb/features/i386/i386-mpx.c b/gdb/features/i386/i386-mpx.c
index c19af55..e832d2e 100644
--- a/gdb/features/i386/i386-mpx.c
+++ b/gdb/features/i386/i386-mpx.c
@@ -153,7 +153,7 @@  initialize_tdesc_i386_mpx (void)
    tdesc_add_bitfield (type, "base", 12, 31);
    tdesc_add_bitfield (type, "reserved", 2, 11);
    tdesc_add_bitfield (type, "preserved", 1, 1);
-  tdesc_add_bitfield (type, "enabled", 0, 1);
+  tdesc_add_bitfield (type, "enabled", 0, 0);

    type = tdesc_create_union (feature, "cfgu");
    field_type = tdesc_named_type (feature, "data_ptr");
diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c
index aa58385..eeaf79b 100644
--- a/gdb/xml-tdesc.c
+++ b/gdb/xml-tdesc.c
@@ -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"));

-      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);
      }