summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gdb/gdb/0014-arc-Take-into-account-the-REGNUM-in-supply-collect-g.patch
diff options
context:
space:
mode:
authorAlexey Brodkin <abrodkin@synopsys.com>2021-06-15 09:00:33 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-06-17 13:41:56 +0100
commit3429acea0f4a0b59f233947defecdf919c7b1799 (patch)
treeb0a9032b54aaae1ae5ca32a01801ccd2c0258ddb /meta/recipes-devtools/gdb/gdb/0014-arc-Take-into-account-the-REGNUM-in-supply-collect-g.patch
parent0d7aa00663e1e41980afb24d0ada2d76e8723e2b (diff)
downloadopenembedded-core-contrib-3429acea0f4a0b59f233947defecdf919c7b1799.tar.gz
gdb: Add native GDB support for ARC
This adds support of so-called "native" GDB for ARC processors. It was submitted upstream a bit late for inclusion in v10.x, but already in the upstream "master" branch and will be an essential part of v11.1 whenever it happens. These are the changes from upstream "master": * https://sourceware.org/git?p=binutils-gdb.git;a=commit;h=b4e3cd0440109d0a5552d3313ccbd35c8103335b * https://sourceware.org/git?p=binutils-gdb.git;a=commit;h=d4af727286e3a9f177ba11677fbd3a012d36558a * https://sourceware.org/git?p=binutils-gdb.git;a=commit;h=46023bbe81355230b4e7b76d3084337823d02362 * https://sourceware.org/git?p=binutils-gdb.git;a=commit;h=04c9f85efcd8df5fc482ce97c0104cc7dd5d19e6 Thanks a bunch to Anton & Shahab who made it possible! Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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.patch104
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 @@
+From 5eb97d5e92ad23ee81cebc1ebd5eafe0aa55fc17 Mon Sep 17 00:00:00 2001
+From: Shahab Vahedi <shahab@synopsys.com>
+Date: Tue, 10 Nov 2020 19:34:57 +0100
+Subject: [PATCH 3/4] arc: Take into account the REGNUM in supply/collect gdb
+ hooks
+
+All the arc_linux_supply_*() target operations and the
+arc_linux_collect_v2_regset() in arc-linux-tdep.c were
+supplying/collecting all the registers in regcache as if the
+REGNUM was set to -1.
+
+The more efficient behavior is to examine the REGNUM and act
+accordingly. That is what this patch does.
+
+gdb/ChangeLog:
+
+ * arc-linux-tdep.c (supply_register): New.
+ (arc_linux_supply_gregset, arc_linux_supply_v2_regset,
+ arc_linux_collect_v2_regset): Consider REGNUM.
+
+Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=46023bbe81355230b4e7b76d3084337823d02362]
+
+Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
+Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
+---
+ gdb/arc-linux-tdep.c | 41 ++++++++++++++++++++++++++++++++---------
+ 1 file changed, 32 insertions(+), 9 deletions(-)
+
+diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c
+index 17bb3e7b276..e83d82b6f5c 100644
+--- a/gdb/arc-linux-tdep.c
++++ b/gdb/arc-linux-tdep.c
+@@ -535,6 +535,18 @@ arc_linux_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
+ }
+ }
+
++/* Populate REGCACHE with register REGNUM from BUF. */
++
++static void
++supply_register (struct regcache *regcache, int regnum, const gdb_byte *buf)
++{
++ /* Skip non-existing registers. */
++ if ((arc_linux_core_reg_offsets[regnum] == ARC_OFFSET_NO_REGISTER))
++ return;
++
++ regcache->raw_supply (regnum, buf + arc_linux_core_reg_offsets[regnum]);
++}
++
+ void
+ arc_linux_supply_gregset (const struct regset *regset,
+ struct regcache *regcache,
+@@ -545,9 +557,14 @@ arc_linux_supply_gregset (const struct regset *regset,
+
+ const bfd_byte *buf = (const bfd_byte *) gregs;
+
+- for (int reg = 0; reg <= ARC_LAST_REGNUM; reg++)
+- if (arc_linux_core_reg_offsets[reg] != ARC_OFFSET_NO_REGISTER)
+- regcache->raw_supply (reg, buf + arc_linux_core_reg_offsets[reg]);
++ /* regnum == -1 means writing all the registers. */
++ if (regnum == -1)
++ for (int reg = 0; reg <= ARC_LAST_REGNUM; reg++)
++ supply_register (regcache, reg, buf);
++ else if (regnum <= ARC_LAST_REGNUM)
++ supply_register (regcache, regnum, buf);
++ else
++ gdb_assert_not_reached ("Invalid regnum in arc_linux_supply_gregset.");
+ }
+
+ void
+@@ -558,9 +575,12 @@ arc_linux_supply_v2_regset (const struct regset *regset,
+ const bfd_byte *buf = (const bfd_byte *) v2_regs;
+
+ /* user_regs_arcv2 is defined in linux arch/arc/include/uapi/asm/ptrace.h. */
+- regcache->raw_supply (ARC_R30_REGNUM, buf);
+- regcache->raw_supply (ARC_R58_REGNUM, buf + REGOFF (1));
+- regcache->raw_supply (ARC_R59_REGNUM, buf + REGOFF (2));
++ if (regnum == -1 || regnum == ARC_R30_REGNUM)
++ regcache->raw_supply (ARC_R30_REGNUM, buf);
++ if (regnum == -1 || regnum == ARC_R58_REGNUM)
++ regcache->raw_supply (ARC_R58_REGNUM, buf + REGOFF (1));
++ if (regnum == -1 || regnum == ARC_R59_REGNUM)
++ regcache->raw_supply (ARC_R59_REGNUM, buf + REGOFF (2));
+ }
+
+ /* Populate BUF with register REGNUM from the REGCACHE. */
+@@ -618,9 +638,12 @@ arc_linux_collect_v2_regset (const struct regset *regset,
+ {
+ bfd_byte *buf = (bfd_byte *) v2_regs;
+
+- regcache->raw_collect (ARC_R30_REGNUM, buf);
+- regcache->raw_collect (ARC_R58_REGNUM, buf + REGOFF (1));
+- regcache->raw_collect (ARC_R59_REGNUM, buf + REGOFF (2));
++ if (regnum == -1 || regnum == ARC_R30_REGNUM)
++ regcache->raw_collect (ARC_R30_REGNUM, buf);
++ if (regnum == -1 || regnum == ARC_R58_REGNUM)
++ regcache->raw_collect (ARC_R58_REGNUM, buf + REGOFF (1));
++ if (regnum == -1 || regnum == ARC_R59_REGNUM)
++ regcache->raw_collect (ARC_R59_REGNUM, buf + REGOFF (2));
+ }
+
+ /* Linux regset definitions. */
+--
+2.16.2
+