This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/3] gdbserver: xtensa: add call0 support


Correctly handle a0- registers on requests from remote gdb. This fixes

  'Register 1 is not available'

and subsequent assertion in the remote gdb connecting to the gdbserver:

  'findvar.c:291: internal-error: value_of_register_lazy:
    Assertion `frame_id_p(get_frame_id (frame))' failed.'

The register structure is the same for windowed and call0 ABIs because
currently linux kernel internally requires windowed registers, so they
are always present.

2017-01-18  Max Filippov  <jcmvbkbc@gmail.com>
gdb/gdbserver/
	* linux-xtensa-low.c (C0_NREGS): New definition.
	(xtensa_fill_gregset): Call collect_register for all registers in
	a0_regnum..a0_regnum + C0_NREGS range.
	(xtensa_store_gregset): Call supply_register for all registers in
	a0_regnum..a0_regnum + C0_NREGS range.
---
 gdb/gdbserver/linux-xtensa-low.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gdb/gdbserver/linux-xtensa-low.c b/gdb/gdbserver/linux-xtensa-low.c
index 98c0bf2..73fbfe2 100644
--- a/gdb/gdbserver/linux-xtensa-low.c
+++ b/gdb/gdbserver/linux-xtensa-low.c
@@ -39,12 +39,15 @@ enum regnum {
 	R_A0 = 64
 };
 
+#define C0_NREGS 16
+
 static void
 xtensa_fill_gregset (struct regcache *regcache, void *buf)
 {
   elf_greg_t* rset = (elf_greg_t*)buf;
   const struct target_desc *tdesc = regcache->tdesc;
   int ar0_regnum;
+  int a0_regnum;
   char *ptr;
   int i;
 
@@ -72,6 +75,17 @@ xtensa_fill_gregset (struct regcache *regcache, void *buf)
   collect_register_by_name (regcache, "ps", (char*)&rset[R_PS]);
   collect_register_by_name (regcache, "windowbase", (char*)&rset[R_WB]);
   collect_register_by_name (regcache, "windowstart", (char*)&rset[R_WS]);
+
+  a0_regnum = find_regno (tdesc, "a0");
+  ptr = (char *)&rset[R_A0 + 4 * rset[R_WB]];
+
+  for (i = a0_regnum; i < a0_regnum + C0_NREGS; i++)
+    {
+      if (4 * rset[R_WB] + i - a0_regnum == XCHAL_NUM_AREGS)
+	ptr = (char *)&rset[R_A0];
+      collect_register (regcache, i, ptr);
+      ptr += register_size (tdesc, i);
+    }
 }
 
 static void
@@ -80,6 +94,7 @@ xtensa_store_gregset (struct regcache *regcache, const void *buf)
   const elf_greg_t* rset = (const elf_greg_t*)buf;
   const struct target_desc *tdesc = regcache->tdesc;
   int ar0_regnum;
+  int a0_regnum;
   char *ptr;
   int i;
 
@@ -94,6 +109,17 @@ xtensa_store_gregset (struct regcache *regcache, const void *buf)
       ptr += register_size (tdesc, i);
     }
 
+  a0_regnum = find_regno (tdesc, "a0");
+  ptr = (char *)&rset[R_A0 + (4 * rset[R_WB]) % XCHAL_NUM_AREGS];
+
+  for (i = a0_regnum; i < a0_regnum + C0_NREGS; i++)
+    {
+      if (4 * rset[R_WB] + i - a0_regnum == XCHAL_NUM_AREGS)
+	ptr = (char *)&rset[R_A0];
+      supply_register (regcache, i, ptr);
+      ptr += register_size (tdesc, i);
+    }
+
   /* Loop registers, if hardware has it.  */
 
 #if XCHAL_HAVE_LOOPS
-- 
2.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]