Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] arc: Write correct "eret" value during register collection
@ 2020-11-12 13:43 Shahab Vahedi via Gdb-patches
  2020-11-12 14:36 ` Tom Tromey
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Shahab Vahedi via Gdb-patches @ 2020-11-12 13:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: Shahab Vahedi, Shahab Vahedi, Francois Bedard

From: Shahab Vahedi <shahab@synopsys.com>

In collect_register() function of arc-linux-tdep.c, the "eret"
(exception return) register value was not being reported correctly.
This patch fixes that.

Background:
When asked for the "pc" value, we have to update the "eret" register
with GDB's STOP_PC.  The "eret" instructs the kernel code where to
jump back when an instruction has stopped due to a breakpoint.  This
is how collect_register() was doing so:

--------------8<--------------
  if (regnum == gdbarch_pc_regnum (gdbarch))
    regnum = ARC_ERET_REGNUM;
  regcache->raw_collect (regnum, buf + arc_linux_core_reg_offsets[regnum]);
-------------->8--------------

Root cause:
Although this is using the correct offset (ERET register's), it is also
changing the REGNUM itself.  Therefore, raw_collect (regnum, ...) is
not reading from "pc" anymore.

gdb/ChangeLog:

	* arc-linux-tdep.c (collect_register): Use "eret" value while
	still writing to "pc" register cache.
---
 gdb/arc-linux-tdep.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c
index 9ff5f1214a1..3530c7cbdd8 100644
--- a/gdb/arc-linux-tdep.c
+++ b/gdb/arc-linux-tdep.c
@@ -319,9 +319,13 @@ static void
 collect_register (const struct regcache *regcache, struct gdbarch *gdbarch,
 		  int regnum, gdb_byte *buf)
 {
+  int offset;
+
   /* Skip non-existing registers.  */
-  if ((arc_linux_core_reg_offsets[regnum] == ARC_OFFSET_NO_REGISTER))
+  if (arc_linux_core_reg_offsets[regnum] == ARC_OFFSET_NO_REGISTER)
     return;
+  else
+    offset = arc_linux_core_reg_offsets[ARC_ERET_REGNUM];
 
   /* The address where the execution has stopped is in pseudo-register
      STOP_PC.  However, when kernel code is returning from the exception,
@@ -332,8 +336,8 @@ collect_register (const struct regcache *regcache, struct gdbarch *gdbarch,
      the program will continue at the address after the current instruction.
      */
   if (regnum == gdbarch_pc_regnum (gdbarch))
-    regnum = ARC_ERET_REGNUM;
-  regcache->raw_collect (regnum, buf + arc_linux_core_reg_offsets[regnum]);
+    offset = arc_linux_core_reg_offsets[ARC_ERET_REGNUM];
+  regcache->raw_collect (regnum, buf + offset);
 }
 
 void
-- 
2.29.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-12-05  8:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 13:43 [PATCH] arc: Write correct "eret" value during register collection Shahab Vahedi via Gdb-patches
2020-11-12 14:36 ` Tom Tromey
2020-11-12 15:46   ` Shahab Vahedi via Gdb-patches
2020-11-12 15:42 ` [PATCH v2] " Shahab Vahedi via Gdb-patches
2020-11-12 15:43   ` Tom Tromey
2020-11-12 16:05 ` [PUSHED] " Shahab Vahedi via Gdb-patches
2020-12-04 10:57 ` [PUSHED gdb-10-branch] " Shahab Vahedi via Gdb-patches
2020-12-04 14:10   ` Joel Brobecker
2020-12-04 14:44     ` Shahab Vahedi via Gdb-patches
2020-12-04 14:53       ` Joel Brobecker
2020-12-04 15:38         ` Shahab Vahedi via Gdb-patches
2020-12-05  8:12           ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox