]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Aarch64: Make CPSR a 32-bit register again in the target description
authorPedro Alves <palves@redhat.com>
Wed, 1 Oct 2014 09:06:45 +0000 (10:06 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 1 Oct 2014 09:06:45 +0000 (10:06 +0100)
This reverts commit a4d9ba85 - 'AARCH64: Change cpsr type to be
64bit.'.

Even though Linux's ptrace exposes CPSR as 64-bit, CPSR is really
32-bit, and basing GDB's fundamentals on a particular OS's ptrace(2)
implementation is a bad idea.

In addition, while that commit intended to fix big endian Aarch64, it
ended up breaking floating point debugging against GDBserver, for both
big and little endian, because it changed the CPSR to be 64-bit in the
features/aarch64-core.xml file, but missed regenerating the
regformats/aarch64.dat file.  If we generate it now, we see this:

  diff --git c/gdb/regformats/aarch64.dat w/gdb/regformats/aarch64.dat
  index afe1028..0d32183 100644
  --- c/gdb/regformats/aarch64.dat
  +++ w/gdb/regformats/aarch64.dat
  @@ -35,7 +35,7 @@ expedite:x29,sp,pc
   64:x30
   64:sp
   64:pc
  -32:cpsr
  +64:cpsr
   128:v0
   128:v1
   128:v2

IOW, that commit left regformats/aarch64.dat still considering CPSR as
32-bits.  regformats/aarch64.dat is used by GDBserver for its internal
regcache layout, and for the g/G packet register block.  See the
generated aarch64.c file in GDBserver's build dir.

So the target description xml file that GDBserver reports to GDB is
now claiming that CPSR is 64-bit, but what GDBserver actually puts in
the g/G register packets is 32-bits.  Because GDB thinks CPSR is
64-bit (because that's what the XML description says), GDB will be
reading the remaining 32-bit bits of CPSR out of v0 (the register
immediately afterwards), and then all the registers that follow CPSR
in the register packet end up wrong in GDB, because they're being read
from the wrong offsets...

gdb/
2014-10-01  Pedro Alves  <palves@redhat.com>

* features/aarch64-core.xml (cpsr): Change back to 32-bit.
* features/aarch64.c: Regenerate.

gdb/ChangeLog
gdb/features/aarch64-core.xml
gdb/features/aarch64.c

index c967a93dcb97d19380e4c56408214fff65e2814c..46bc965a86ee8f291a34c1b90803347818c72a5f 100644 (file)
@@ -1,3 +1,8 @@
+2014-10-01  Pedro Alves  <palves@redhat.com>
+
+       * features/aarch64-core.xml (cpsr): Change back to 32-bit.
+       * features/aarch64.c: Regenerate.
+
 2014-09-30  Don Breazeal  <donb@codesourcery.com>
 
        * inf-ptrace.c (inf_ptrace_follow_fork): Remove target-independent
index dbec6dc94425a3ca9ece125819cfeca464714c25..9b45a220dd088eaa2e4058f5f75bd06060d52fd2 100644 (file)
@@ -42,5 +42,5 @@
   <reg name="sp" bitsize="64" type="data_ptr"/>
 
   <reg name="pc" bitsize="64" type="code_ptr"/>
-  <reg name="cpsr" bitsize="64"/>
+  <reg name="cpsr" bitsize="32"/>
 </feature>
index 31a148e36375f588cc7a6ac4418466f3f7a33050..1e9a99d3e948bdc64e99f3280e5061892b055b4e 100644 (file)
@@ -50,7 +50,7 @@ initialize_tdesc_aarch64 (void)
   tdesc_create_reg (feature, "x30", 30, 1, NULL, 64, "int");
   tdesc_create_reg (feature, "sp", 31, 1, NULL, 64, "data_ptr");
   tdesc_create_reg (feature, "pc", 32, 1, NULL, 64, "code_ptr");
-  tdesc_create_reg (feature, "cpsr", 33, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "cpsr", 33, 1, NULL, 32, "int");
 
   feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.fpu");
   field_type = tdesc_named_type (feature, "ieee_double");