Bug 27015 - ARC: "eret" value is collected from the wrong data in register cache
Summary: ARC: "eret" value is collected from the wrong data in register cache
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: tdep (show other bugs)
Version: HEAD
: P2 critical
Target Milestone: 10.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-04 15:04 UTC by Shahab
Modified: 2021-07-13 04:59 UTC (History)
4 users (show)

See Also:
Host: arc-snps-linux-gnu
Target: arc-snps-linux-gnu
Build: x86_64-pc-linux-gnu
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shahab 2020-12-04 15:04:10 UTC
Versions affected: HEAD and 10.1

--------------------------------

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

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() is 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.

Consequence:
This bug affects the "native ARC gdb" badly and causes kernel code to jump
to addresses after the breakpoint and not executing the "breakpoint"ed
instructions at all.  That "native ARC gdb" feature is not upstream yet and
is in review at the time of writing [1].

[1] Add native GNU/Linux support for ARC in GDB
https://sourceware.org/pipermail/gdb-patches/2020-November/173203.html
Comment 1 Shahab 2020-12-04 15:15:41 UTC
This PR was solved on master with this commit:

| commit 10c19fadfd45da5262d2f8b9624be71c274ff15d
| Author: Shahab Vahedi <shahab@synopsys.com>
| Date:   Thu Nov 12 12:50:33 2020 +0100
| Subject: arc: Write correct "eret" value during register collection

The patch above was also pushed to gdb-10-branch (on 04-Dec-2020) as:

| commit abaf3df98b69d66c779ff0896d66fea9cbb67481
| Author: Shahab Vahedi <shahab@synopsys.com>
| Date:   Thu Nov 12 12:50:33 2020 +0100
| Subject: arc: Write correct "eret" value during register collection
Comment 2 Ahmed Sayeed 2021-06-27 17:52:24 UTC Comment hidden (spam)
Comment 3 Sherry 2021-07-13 03:12:17 UTC Comment hidden (spam)