diff options
Diffstat (limited to 'meta/recipes-devtools/gdb/gdb/0014-arc-Take-into-account-the-REGNUM-in-supply-collect-g.patch')
-rw-r--r-- | meta/recipes-devtools/gdb/gdb/0014-arc-Take-into-account-the-REGNUM-in-supply-collect-g.patch | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gdb/gdb/0014-arc-Take-into-account-the-REGNUM-in-supply-collect-g.patch b/meta/recipes-devtools/gdb/gdb/0014-arc-Take-into-account-the-REGNUM-in-supply-collect-g.patch new file mode 100644 index 0000000000..a7256065cc --- /dev/null +++ b/meta/recipes-devtools/gdb/gdb/0014-arc-Take-into-account-the-REGNUM-in-supply-collect-g.patch | |||
@@ -0,0 +1,104 @@ | |||
1 | From 5eb97d5e92ad23ee81cebc1ebd5eafe0aa55fc17 Mon Sep 17 00:00:00 2001 | ||
2 | From: Shahab Vahedi <shahab@synopsys.com> | ||
3 | Date: Tue, 10 Nov 2020 19:34:57 +0100 | ||
4 | Subject: [PATCH 3/4] arc: Take into account the REGNUM in supply/collect gdb | ||
5 | hooks | ||
6 | |||
7 | All the arc_linux_supply_*() target operations and the | ||
8 | arc_linux_collect_v2_regset() in arc-linux-tdep.c were | ||
9 | supplying/collecting all the registers in regcache as if the | ||
10 | REGNUM was set to -1. | ||
11 | |||
12 | The more efficient behavior is to examine the REGNUM and act | ||
13 | accordingly. That is what this patch does. | ||
14 | |||
15 | gdb/ChangeLog: | ||
16 | |||
17 | * arc-linux-tdep.c (supply_register): New. | ||
18 | (arc_linux_supply_gregset, arc_linux_supply_v2_regset, | ||
19 | arc_linux_collect_v2_regset): Consider REGNUM. | ||
20 | |||
21 | Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=46023bbe81355230b4e7b76d3084337823d02362] | ||
22 | |||
23 | Signed-off-by: Shahab Vahedi <shahab@synopsys.com> | ||
24 | Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> | ||
25 | --- | ||
26 | gdb/arc-linux-tdep.c | 41 ++++++++++++++++++++++++++++++++--------- | ||
27 | 1 file changed, 32 insertions(+), 9 deletions(-) | ||
28 | |||
29 | diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c | ||
30 | index 17bb3e7b276..e83d82b6f5c 100644 | ||
31 | --- a/gdb/arc-linux-tdep.c | ||
32 | +++ b/gdb/arc-linux-tdep.c | ||
33 | @@ -535,6 +535,18 @@ arc_linux_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) | ||
34 | } | ||
35 | } | ||
36 | |||
37 | +/* Populate REGCACHE with register REGNUM from BUF. */ | ||
38 | + | ||
39 | +static void | ||
40 | +supply_register (struct regcache *regcache, int regnum, const gdb_byte *buf) | ||
41 | +{ | ||
42 | + /* Skip non-existing registers. */ | ||
43 | + if ((arc_linux_core_reg_offsets[regnum] == ARC_OFFSET_NO_REGISTER)) | ||
44 | + return; | ||
45 | + | ||
46 | + regcache->raw_supply (regnum, buf + arc_linux_core_reg_offsets[regnum]); | ||
47 | +} | ||
48 | + | ||
49 | void | ||
50 | arc_linux_supply_gregset (const struct regset *regset, | ||
51 | struct regcache *regcache, | ||
52 | @@ -545,9 +557,14 @@ arc_linux_supply_gregset (const struct regset *regset, | ||
53 | |||
54 | const bfd_byte *buf = (const bfd_byte *) gregs; | ||
55 | |||
56 | - for (int reg = 0; reg <= ARC_LAST_REGNUM; reg++) | ||
57 | - if (arc_linux_core_reg_offsets[reg] != ARC_OFFSET_NO_REGISTER) | ||
58 | - regcache->raw_supply (reg, buf + arc_linux_core_reg_offsets[reg]); | ||
59 | + /* regnum == -1 means writing all the registers. */ | ||
60 | + if (regnum == -1) | ||
61 | + for (int reg = 0; reg <= ARC_LAST_REGNUM; reg++) | ||
62 | + supply_register (regcache, reg, buf); | ||
63 | + else if (regnum <= ARC_LAST_REGNUM) | ||
64 | + supply_register (regcache, regnum, buf); | ||
65 | + else | ||
66 | + gdb_assert_not_reached ("Invalid regnum in arc_linux_supply_gregset."); | ||
67 | } | ||
68 | |||
69 | void | ||
70 | @@ -558,9 +575,12 @@ arc_linux_supply_v2_regset (const struct regset *regset, | ||
71 | const bfd_byte *buf = (const bfd_byte *) v2_regs; | ||
72 | |||
73 | /* user_regs_arcv2 is defined in linux arch/arc/include/uapi/asm/ptrace.h. */ | ||
74 | - regcache->raw_supply (ARC_R30_REGNUM, buf); | ||
75 | - regcache->raw_supply (ARC_R58_REGNUM, buf + REGOFF (1)); | ||
76 | - regcache->raw_supply (ARC_R59_REGNUM, buf + REGOFF (2)); | ||
77 | + if (regnum == -1 || regnum == ARC_R30_REGNUM) | ||
78 | + regcache->raw_supply (ARC_R30_REGNUM, buf); | ||
79 | + if (regnum == -1 || regnum == ARC_R58_REGNUM) | ||
80 | + regcache->raw_supply (ARC_R58_REGNUM, buf + REGOFF (1)); | ||
81 | + if (regnum == -1 || regnum == ARC_R59_REGNUM) | ||
82 | + regcache->raw_supply (ARC_R59_REGNUM, buf + REGOFF (2)); | ||
83 | } | ||
84 | |||
85 | /* Populate BUF with register REGNUM from the REGCACHE. */ | ||
86 | @@ -618,9 +638,12 @@ arc_linux_collect_v2_regset (const struct regset *regset, | ||
87 | { | ||
88 | bfd_byte *buf = (bfd_byte *) v2_regs; | ||
89 | |||
90 | - regcache->raw_collect (ARC_R30_REGNUM, buf); | ||
91 | - regcache->raw_collect (ARC_R58_REGNUM, buf + REGOFF (1)); | ||
92 | - regcache->raw_collect (ARC_R59_REGNUM, buf + REGOFF (2)); | ||
93 | + if (regnum == -1 || regnum == ARC_R30_REGNUM) | ||
94 | + regcache->raw_collect (ARC_R30_REGNUM, buf); | ||
95 | + if (regnum == -1 || regnum == ARC_R58_REGNUM) | ||
96 | + regcache->raw_collect (ARC_R58_REGNUM, buf + REGOFF (1)); | ||
97 | + if (regnum == -1 || regnum == ARC_R59_REGNUM) | ||
98 | + regcache->raw_collect (ARC_R59_REGNUM, buf + REGOFF (2)); | ||
99 | } | ||
100 | |||
101 | /* Linux regset definitions. */ | ||
102 | -- | ||
103 | 2.16.2 | ||
104 | |||