This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
MIPS/Linux: Register number overlap in target descriptions
- From: "Maciej W. Rozycki" <macro at mips dot com>
- To: gdb-patches at sourceware dot org
- Cc: "Maciej W. Rozycki" <macro at linux-mips dot org>
- Date: Tue, 4 Dec 2007 15:01:33 +0000 (GMT)
- Subject: MIPS/Linux: Register number overlap in target descriptions
Hello,
Due to the way target register numbers are assigned in the target
description (using the last number used plus one unless overridden) we
have two registers overlapping each other. Specifically, both "pc" and
"f0" are assigned 37 as their number, which happens because the
description of "f0" is provided after one of "cause", which specifies 36
explicitly and "pc" is assigned 37 likewise. I gather it breaks register
numbering as such too as there are places elsewhere in the code that refer
to some registers by number literally.
To rectify, the change specifies 38 for "f0" explicitly. For consistency
and to raise people's attention, I have similarly decided to specify 0 for
"r0".
Tested natively for mips-linux-gnu with no regressions.
2007-12-04 Maciej W. Rozycki <macro@mips.com>
* features/mips-cpu.xml: Specify "regnum" for "r0" explicitly.
* features/mips64-cpu.xml: Likewise.
* features/mips-fpu.xml: Specify "regnum" for "f0" explicitly.
* features/mips64-fpu.xml: Likewise.
* features/mips-linux.c: Regenerate.
* features/mips64-linux.c: Regenerate.
OK to apply?
Maciej
gdb-mips-tdesc.diff
Index: gdb/src/gdb/features/mips-cpu.xml
===================================================================
--- gdb.orig/src/gdb/features/mips-cpu.xml 2007-12-03 11:05:25.000000000 +0000
+++ gdb/src/gdb/features/mips-cpu.xml 2007-12-03 11:07:06.000000000 +0000
@@ -7,7 +7,7 @@
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.mips.cpu">
- <reg name="r0" bitsize="32"/>
+ <reg name="r0" bitsize="32" regnum="0"/>
<reg name="r1" bitsize="32"/>
<reg name="r2" bitsize="32"/>
<reg name="r3" bitsize="32"/>
Index: gdb/src/gdb/features/mips-fpu.xml
===================================================================
--- gdb.orig/src/gdb/features/mips-fpu.xml 2007-12-03 11:05:25.000000000 +0000
+++ gdb/src/gdb/features/mips-fpu.xml 2007-12-03 11:07:15.000000000 +0000
@@ -7,7 +7,7 @@
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.mips.fpu">
- <reg name="f0" bitsize="32" type="ieee_single"/>
+ <reg name="f0" bitsize="32" type="ieee_single" regnum="38"/>
<reg name="f1" bitsize="32" type="ieee_single"/>
<reg name="f2" bitsize="32" type="ieee_single"/>
<reg name="f3" bitsize="32" type="ieee_single"/>
Index: gdb/src/gdb/features/mips64-cpu.xml
===================================================================
--- gdb.orig/src/gdb/features/mips64-cpu.xml 2007-12-03 11:05:25.000000000 +0000
+++ gdb/src/gdb/features/mips64-cpu.xml 2007-12-03 11:06:01.000000000 +0000
@@ -7,7 +7,7 @@
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.mips.cpu">
- <reg name="r0" bitsize="64"/>
+ <reg name="r0" bitsize="64" regnum="0"/>
<reg name="r1" bitsize="64"/>
<reg name="r2" bitsize="64"/>
<reg name="r3" bitsize="64"/>
Index: gdb/src/gdb/features/mips64-fpu.xml
===================================================================
--- gdb.orig/src/gdb/features/mips64-fpu.xml 2007-12-03 11:05:25.000000000 +0000
+++ gdb/src/gdb/features/mips64-fpu.xml 2007-12-03 11:06:48.000000000 +0000
@@ -7,7 +7,7 @@
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.mips.fpu">
- <reg name="f0" bitsize="64" type="ieee_double"/>
+ <reg name="f0" bitsize="64" type="ieee_double" regnum="38"/>
<reg name="f1" bitsize="64" type="ieee_double"/>
<reg name="f2" bitsize="64" type="ieee_double"/>
<reg name="f3" bitsize="64" type="ieee_double"/>
Index: gdb/src/gdb/features/mips-linux.c
===================================================================
--- gdb.orig/src/gdb/features/mips-linux.c 2007-12-03 11:13:40.000000000 +0000
+++ gdb/src/gdb/features/mips-linux.c 2007-12-03 11:53:07.000000000 +0000
@@ -57,43 +57,43 @@
tdesc_create_reg (feature, "cause", 36, 1, NULL, 32, "int");
feature = tdesc_create_feature (result, "org.gnu.gdb.mips.fpu");
- tdesc_create_reg (feature, "f0", 37, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f1", 38, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f2", 39, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f3", 40, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f4", 41, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f5", 42, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f6", 43, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f7", 44, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f8", 45, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f9", 46, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f10", 47, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f11", 48, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f12", 49, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f13", 50, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f14", 51, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f15", 52, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f16", 53, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f17", 54, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f18", 55, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f19", 56, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f20", 57, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f21", 58, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f22", 59, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f23", 60, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f24", 61, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f25", 62, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f26", 63, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f27", 64, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f28", 65, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f29", 66, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f30", 67, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "f31", 68, 1, NULL, 32, "ieee_single");
- tdesc_create_reg (feature, "fcsr", 69, 1, "float", 32, "int");
- tdesc_create_reg (feature, "fir", 70, 1, "float", 32, "int");
+ tdesc_create_reg (feature, "f0", 38, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f1", 39, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f2", 40, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f3", 41, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f4", 42, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f5", 43, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f6", 44, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f7", 45, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f8", 46, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f9", 47, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f10", 48, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f11", 49, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f12", 50, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f13", 51, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f14", 52, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f15", 53, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f16", 54, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f17", 55, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f18", 56, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f19", 57, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f20", 58, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f21", 59, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f22", 60, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f23", 61, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f24", 62, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f25", 63, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f26", 64, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f27", 65, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f28", 66, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f29", 67, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f30", 68, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "f31", 69, 1, NULL, 32, "ieee_single");
+ tdesc_create_reg (feature, "fcsr", 70, 1, "float", 32, "int");
+ tdesc_create_reg (feature, "fir", 71, 1, "float", 32, "int");
feature = tdesc_create_feature (result, "org.gnu.gdb.mips.linux");
- tdesc_create_reg (feature, "restart", 71, 1, "system", 32, "int");
+ tdesc_create_reg (feature, "restart", 72, 1, "system", 32, "int");
tdesc_mips_linux = result;
}
Index: gdb/src/gdb/features/mips64-linux.c
===================================================================
--- gdb.orig/src/gdb/features/mips64-linux.c 2007-12-03 11:13:40.000000000 +0000
+++ gdb/src/gdb/features/mips64-linux.c 2007-12-03 11:53:07.000000000 +0000
@@ -57,43 +57,43 @@
tdesc_create_reg (feature, "cause", 36, 1, NULL, 64, "int");
feature = tdesc_create_feature (result, "org.gnu.gdb.mips.fpu");
- tdesc_create_reg (feature, "f0", 37, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f1", 38, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f2", 39, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f3", 40, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f4", 41, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f5", 42, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f6", 43, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f7", 44, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f8", 45, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f9", 46, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f10", 47, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f11", 48, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f12", 49, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f13", 50, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f14", 51, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f15", 52, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f16", 53, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f17", 54, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f18", 55, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f19", 56, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f20", 57, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f21", 58, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f22", 59, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f23", 60, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f24", 61, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f25", 62, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f26", 63, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f27", 64, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f28", 65, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f29", 66, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f30", 67, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "f31", 68, 1, NULL, 64, "ieee_double");
- tdesc_create_reg (feature, "fcsr", 69, 1, "float", 64, "int");
- tdesc_create_reg (feature, "fir", 70, 1, "float", 64, "int");
+ tdesc_create_reg (feature, "f0", 38, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f1", 39, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f2", 40, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f3", 41, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f4", 42, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f5", 43, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f6", 44, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f7", 45, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f8", 46, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f9", 47, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f10", 48, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f11", 49, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f12", 50, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f13", 51, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f14", 52, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f15", 53, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f16", 54, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f17", 55, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f18", 56, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f19", 57, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f20", 58, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f21", 59, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f22", 60, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f23", 61, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f24", 62, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f25", 63, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f26", 64, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f27", 65, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f28", 66, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f29", 67, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f30", 68, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "f31", 69, 1, NULL, 64, "ieee_double");
+ tdesc_create_reg (feature, "fcsr", 70, 1, "float", 64, "int");
+ tdesc_create_reg (feature, "fir", 71, 1, "float", 64, "int");
feature = tdesc_create_feature (result, "org.gnu.gdb.mips.linux");
- tdesc_create_reg (feature, "restart", 71, 1, "system", 64, "int");
+ tdesc_create_reg (feature, "restart", 72, 1, "system", 64, "int");
tdesc_mips64_linux = result;
}