diff mbox series

[v2,15/17] target/m68k: hack around the FPU register support (HACK!)

Message ID 20200414200631.12799-16-alex.bennee@linaro.org
State New
Headers show
Series more randome fixes (user, pie, docker and gdbstub) | expand

Commit Message

Alex Bennée April 14, 2020, 8:06 p.m. UTC
Attempting to attach to the gdbstub causes GDB to complain:

  warning: Register "fp0" has an unsupported size (80 bits)
  warning: Register "fp1" has an unsupported size (80 bits)
  warning: Register "fp2" has an unsupported size (80 bits)
  warning: Register "fp3" has an unsupported size (80 bits)
  warning: Register "fp4" has an unsupported size (80 bits)
  warning: Register "fp5" has an unsupported size (80 bits)
  warning: Register "fp6" has an unsupported size (80 bits)
  warning: Register "fp7" has an unsupported size (80 bits)
  Remote 'g' packet reply is too long (expected 148 bytes, got 164 bytes): 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000$
  00000000000000000000408009f000000000800003407fffffffffffffffffff7fffffffffffffffffff7fffffffffffffffffff7fffffffffffffffffff7fffffffffffffffffff7fffffffffffffffffff7fffffff$
  fffffffffff7fffffffffffffffffff000000000000000000000000

and then subsequently fail. The root problem seems to be this is an
undefined size register for the target description. There does exist a
floatformats_m68881_ext in GDB but setting "m68881_ext" also fails as
the only "weird" tdesc types gdb seems to understand are:

  { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
  { "i387_ext", TDESC_TYPE_I387_EXT }

So present the register as a i386_ext as some sort of hack. The values
are garbage but at least we can continue to connect. Perhaps we should
just delete the code because I don't think this ever worked with
upstream tools.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Cc: Laurent Vivier <laurent@vivier.eu>
---
 target/m68k/helper.c | 11 +++++------
 gdb-xml/m68k-fp.xml  | 16 ++++++++--------
 2 files changed, 13 insertions(+), 14 deletions(-)

-- 
2.20.1
diff mbox series

Patch

diff --git a/target/m68k/helper.c b/target/m68k/helper.c
index 79b0b10ea9b..80069adb8cc 100644
--- a/target/m68k/helper.c
+++ b/target/m68k/helper.c
@@ -109,9 +109,8 @@  static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n)
 static int m68k_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int n)
 {
     if (n < 8) {
-        int len = gdb_get_reg16(mem_buf, env->fregs[n].l.upper);
-        len += gdb_get_reg16(mem_buf, 0);
-        len += gdb_get_reg64(mem_buf, env->fregs[n].l.lower);
+        int len = gdb_get_reg64(mem_buf, cpu_to_le64(env->fregs[n].l.lower));
+        len += gdb_get_reg16(mem_buf, cpu_to_le16(env->fregs[n].l.upper));
         return len;
     }
     switch (n) {
@@ -128,9 +127,9 @@  static int m68k_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int n)
 static int m68k_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n)
 {
     if (n < 8) {
-        env->fregs[n].l.upper = lduw_be_p(mem_buf);
-        env->fregs[n].l.lower = ldq_be_p(mem_buf + 4);
-        return 12;
+        env->fregs[n].l.lower = le64_to_cpu(* (uint64_t *) mem_buf);
+        env->fregs[n].l.upper = le16_to_cpu(* (uint16_t *) (mem_buf + 8));
+        return 10;
     }
     switch (n) {
     case 8: /* fpcontrol */
diff --git a/gdb-xml/m68k-fp.xml b/gdb-xml/m68k-fp.xml
index 64290d16306..8eb55af2860 100644
--- a/gdb-xml/m68k-fp.xml
+++ b/gdb-xml/m68k-fp.xml
@@ -6,14 +6,14 @@ 
      notice and this notice are preserved.  -->
 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
 <feature name="org.gnu.gdb.coldfire.fp">
-  <reg name="fp0" bitsize="96" type="float" group="float"/>
-  <reg name="fp1" bitsize="96" type="float" group="float"/>
-  <reg name="fp2" bitsize="96" type="float" group="float"/>
-  <reg name="fp3" bitsize="96" type="float" group="float"/>
-  <reg name="fp4" bitsize="96" type="float" group="float"/>
-  <reg name="fp5" bitsize="96" type="float" group="float"/>
-  <reg name="fp6" bitsize="96" type="float" group="float"/>
-  <reg name="fp7" bitsize="96" type="float" group="float"/>
+  <reg name="fp0" bitsize="80" type="i387_ext" group="float"/>
+  <reg name="fp1" bitsize="80" type="i387_ext" group="float"/>
+  <reg name="fp2" bitsize="80" type="i387_ext" group="float"/>
+  <reg name="fp3" bitsize="80" type="i387_ext" group="float"/>
+  <reg name="fp4" bitsize="80" type="i387_ext" group="float"/>
+  <reg name="fp5" bitsize="80" type="i387_ext" group="float"/>
+  <reg name="fp6" bitsize="80" type="i387_ext" group="float"/>
+  <reg name="fp7" bitsize="80" type="i387_ext" group="float"/>
 
   <reg name="fpcontrol" bitsize="32" group="float"/>
   <reg name="fpstatus" bitsize="32" group="float"/>,