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-11-22 13:12 UTC (History)
38 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)
Comment 4 Madison Wilson 2021-08-09 09:35:03 UTC Comment hidden (spam)
Comment 5 Ucel Sani 2021-08-10 11:44:18 UTC Comment hidden (spam)
Comment 6 Kenneth 2021-08-20 15:56:10 UTC Comment hidden (spam)
Comment 7 Kenneth 2021-08-20 15:56:50 UTC Comment hidden (spam)
Comment 8 Kate 2021-08-23 05:22:33 UTC Comment hidden (spam)
Comment 9 james rohan 2021-09-02 11:06:15 UTC Comment hidden (spam)
Comment 10 Kim Olsun 2021-09-05 07:36:43 UTC Comment hidden (spam)
Comment 11 james robin 2021-09-06 09:08:26 UTC Comment hidden (spam)
Comment 13 Mehmet gelisin 2021-09-10 19:36:54 UTC Comment hidden (spam)
Comment 14 Jari Littlenen 2021-09-14 12:54:22 UTC Comment hidden (spam)
Comment 15 johnmartin 2021-09-20 08:21:20 UTC Comment hidden (spam)
Comment 16 johnmartin 2021-09-20 08:22:00 UTC Comment hidden (spam)
Comment 17 atifarif503 2021-09-22 09:08:06 UTC Comment hidden (spam)
Comment 18 atifarif503 2021-09-22 09:08:34 UTC Comment hidden (spam)
Comment 19 diheto 2021-09-22 10:18:59 UTC Comment hidden (spam)
Comment 21 Steve Anderson 2021-10-04 07:54:57 UTC Comment hidden (spam)
Comment 22 Gulsen Engin 2021-10-09 11:00:19 UTC Comment hidden (spam)
Comment 23 svitvitraga 2021-10-09 17:51:53 UTC Comment hidden (spam)
Comment 25 Mikematics 2021-10-16 00:06:21 UTC Comment hidden (spam)
Comment 26 Kyle Scott 2021-10-18 08:09:46 UTC Comment hidden (spam)
Comment 27 Canerkin 2021-10-18 19:58:10 UTC Comment hidden (spam)
Comment 28 progonsaytu 2021-10-19 07:14:35 UTC Comment hidden (spam)
Comment 29 bart 2021-10-19 13:34:30 UTC Comment hidden (spam)
Comment 30 peterverbaarschot 2021-10-19 13:49:43 UTC Comment hidden (spam)
Comment 31 glassmtech 2021-10-24 10:02:32 UTC Comment hidden (spam)
Comment 32 Adam Plier 2021-10-27 06:50:37 UTC Comment hidden (spam)
Comment 33 Jamie 2021-10-28 09:09:48 UTC Comment hidden (spam)
Comment 34 Jordan Prest 2021-11-02 09:50:07 UTC Comment hidden (spam)
Comment 35 Tyler 2021-11-03 07:52:54 UTC Comment hidden (spam)
Comment 36 Justin Louie 2021-11-05 09:28:48 UTC Comment hidden (spam)
Comment 37 paneki 2021-11-06 21:13:17 UTC Comment hidden (spam)
Comment 38 Marulee 2021-11-08 11:49:54 UTC Comment hidden (spam)
Comment 39 Erwan 2021-11-12 11:41:45 UTC Comment hidden (spam)
Comment 40 brickpavingcl 2021-11-14 20:01:51 UTC Comment hidden (spam)
Comment 41 Prince 2021-11-16 12:40:44 UTC Comment hidden (spam)
Comment 42 tesaso8237@funboxcn.comxecana8007@funboxcn.com 2021-11-16 19:08:18 UTC Comment hidden (spam)
Comment 43 tesaso8237@funboxcn.comxecana8007@funboxcn.com 2021-11-16 19:15:45 UTC Comment hidden (spam)
Comment 44 Henry Kim 2021-11-22 13:12:59 UTC Comment hidden (spam)