summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gdb
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2021-11-03 18:30:23 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-07 10:56:26 +0000
commit7bfe8b2f8c5565a057ff903433fce87c569314ca (patch)
tree1485472000363adc4bda920f296621097e446e18 /meta/recipes-devtools/gdb
parenteec7affb53e406c72c20d10fc14d730ade1761b0 (diff)
downloadpoky-7bfe8b2f8c5565a057ff903433fce87c569314ca.tar.gz
gdb: Upgrade to 11.1
Drop backported patches Changes are here [1] [1] https://sourceware.org/pipermail/gdb-announce/2021/000129.html (From OE-Core rev: e1c421c0450212201ad9737bf203eac2bfcd37db) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/gdb')
-rw-r--r--meta/recipes-devtools/gdb/gdb-11.1.inc (renamed from meta/recipes-devtools/gdb/gdb-10.2.inc)14
-rw-r--r--meta/recipes-devtools/gdb/gdb-cross-canadian_11.1.bb (renamed from meta/recipes-devtools/gdb/gdb-cross-canadian_10.2.bb)0
-rw-r--r--meta/recipes-devtools/gdb/gdb-cross_11.1.bb (renamed from meta/recipes-devtools/gdb/gdb-cross_10.2.bb)0
-rw-r--r--meta/recipes-devtools/gdb/gdb/0001-make-man-install-relative-to-DESTDIR.patch20
-rw-r--r--meta/recipes-devtools/gdb/gdb/0002-mips-linux-nat-Define-_ABIO32-if-not-defined.patch8
-rw-r--r--meta/recipes-devtools/gdb/gdb/0003-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch10
-rw-r--r--meta/recipes-devtools/gdb/gdb/0004-Add-support-for-Renesas-SH-sh4-architecture.patch39
-rw-r--r--meta/recipes-devtools/gdb/gdb/0005-Dont-disable-libreadline.a-when-using-disable-static.patch12
-rw-r--r--meta/recipes-devtools/gdb/gdb/0006-use-asm-sgidefs.h.patch8
-rw-r--r--meta/recipes-devtools/gdb/gdb/0007-Change-order-of-CFLAGS.patch (renamed from meta/recipes-devtools/gdb/gdb/0008-Change-order-of-CFLAGS.patch)12
-rw-r--r--meta/recipes-devtools/gdb/gdb/0008-resolve-restrict-keyword-conflict.patch (renamed from meta/recipes-devtools/gdb/gdb/0009-resolve-restrict-keyword-conflict.patch)8
-rw-r--r--meta/recipes-devtools/gdb/gdb/0009-Fix-invalid-sigprocmask-call.patch (renamed from meta/recipes-devtools/gdb/gdb/0010-Fix-invalid-sigprocmask-call.patch)8
-rw-r--r--meta/recipes-devtools/gdb/gdb/0010-gdbserver-ctrl-c-handling.patch (renamed from meta/recipes-devtools/gdb/gdb/0011-gdbserver-ctrl-c-handling.patch)10
-rw-r--r--meta/recipes-devtools/gdb/gdb/0012-arc-Add-support-for-signal-handlers.patch218
-rw-r--r--meta/recipes-devtools/gdb/gdb/0013-arc-Add-support-for-signal-frames-for-Linux-targets.patch232
-rw-r--r--meta/recipes-devtools/gdb/gdb/0014-arc-Take-into-account-the-REGNUM-in-supply-collect-g.patch104
-rw-r--r--meta/recipes-devtools/gdb/gdb/0015-gdb-Add-native-support-for-ARC-in-GNU-Linux.patch414
-rw-r--r--meta/recipes-devtools/gdb/gdb_11.1.bb (renamed from meta/recipes-devtools/gdb/gdb_10.2.bb)0
18 files changed, 73 insertions, 1044 deletions
diff --git a/meta/recipes-devtools/gdb/gdb-10.2.inc b/meta/recipes-devtools/gdb/gdb-11.1.inc
index 0d275075e6..686627926d 100644
--- a/meta/recipes-devtools/gdb/gdb-10.2.inc
+++ b/meta/recipes-devtools/gdb/gdb-11.1.inc
@@ -11,13 +11,9 @@ SRC_URI = "${GNU_MIRROR}/gdb/gdb-${PV}.tar.xz \
11 file://0004-Add-support-for-Renesas-SH-sh4-architecture.patch \ 11 file://0004-Add-support-for-Renesas-SH-sh4-architecture.patch \
12 file://0005-Dont-disable-libreadline.a-when-using-disable-static.patch \ 12 file://0005-Dont-disable-libreadline.a-when-using-disable-static.patch \
13 file://0006-use-asm-sgidefs.h.patch \ 13 file://0006-use-asm-sgidefs.h.patch \
14 file://0008-Change-order-of-CFLAGS.patch \ 14 file://0007-Change-order-of-CFLAGS.patch \
15 file://0009-resolve-restrict-keyword-conflict.patch \ 15 file://0008-resolve-restrict-keyword-conflict.patch \
16 file://0010-Fix-invalid-sigprocmask-call.patch \ 16 file://0009-Fix-invalid-sigprocmask-call.patch \
17 file://0011-gdbserver-ctrl-c-handling.patch \ 17 file://0010-gdbserver-ctrl-c-handling.patch \
18 file://0012-arc-Add-support-for-signal-handlers.patch \
19 file://0013-arc-Add-support-for-signal-frames-for-Linux-targets.patch \
20 file://0014-arc-Take-into-account-the-REGNUM-in-supply-collect-g.patch \
21 file://0015-gdb-Add-native-support-for-ARC-in-GNU-Linux.patch \
22 " 18 "
23SRC_URI[sha256sum] = "aaa1223d534c9b700a8bec952d9748ee1977513f178727e1bee520ee000b4f29" 19SRC_URI[sha256sum] = "cccfcc407b20d343fb320d4a9a2110776dd3165118ffd41f4b1b162340333f94"
diff --git a/meta/recipes-devtools/gdb/gdb-cross-canadian_10.2.bb b/meta/recipes-devtools/gdb/gdb-cross-canadian_11.1.bb
index 301035940c..301035940c 100644
--- a/meta/recipes-devtools/gdb/gdb-cross-canadian_10.2.bb
+++ b/meta/recipes-devtools/gdb/gdb-cross-canadian_11.1.bb
diff --git a/meta/recipes-devtools/gdb/gdb-cross_10.2.bb b/meta/recipes-devtools/gdb/gdb-cross_11.1.bb
index 50cf159fdb..50cf159fdb 100644
--- a/meta/recipes-devtools/gdb/gdb-cross_10.2.bb
+++ b/meta/recipes-devtools/gdb/gdb-cross_11.1.bb
diff --git a/meta/recipes-devtools/gdb/gdb/0001-make-man-install-relative-to-DESTDIR.patch b/meta/recipes-devtools/gdb/gdb/0001-make-man-install-relative-to-DESTDIR.patch
index 84d178332d..824b96f6af 100644
--- a/meta/recipes-devtools/gdb/gdb/0001-make-man-install-relative-to-DESTDIR.patch
+++ b/meta/recipes-devtools/gdb/gdb/0001-make-man-install-relative-to-DESTDIR.patch
@@ -1,22 +1,22 @@
1From e5126c7167e26f865990dc5f86344602603aa8c6 Mon Sep 17 00:00:00 2001 1From a6d3df9d84463ec500d9d01558ab8a17e824e9e5 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 2 Mar 2015 02:27:55 +0000 3Date: Mon, 2 Mar 2015 02:27:55 +0000
4Subject: [PATCH 01/11] make man install relative to DESTDIR 4Subject: [PATCH 01/10] make man install relative to DESTDIR
5 5
6Upstream-Status: Pending 6Upstream-Status: Pending
7 7
8Signed-off-by: Khem Raj <raj.khem@gmail.com> 8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9--- 9---
10 sim/common/Makefile.in | 2 +- 10 sim/common/Make-common.in | 2 +-
11 1 file changed, 1 insertion(+), 1 deletion(-) 11 1 file changed, 1 insertion(+), 1 deletion(-)
12 12
13diff --git a/sim/common/Makefile.in b/sim/common/Makefile.in 13diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
14index f713fcaa35b..7c553709d3f 100644 14index 8c2cacea1e5..4a52eef2203 100644
15--- a/sim/common/Makefile.in 15--- a/sim/common/Make-common.in
16+++ b/sim/common/Makefile.in 16+++ b/sim/common/Make-common.in
17@@ -35,7 +35,7 @@ tooldir = $(libdir)/$(target_alias) 17@@ -63,7 +63,7 @@ tooldir = $(libdir)/$(target_alias)
18 datarootdir = @datarootdir@
19 datadir = @datadir@ 18 datadir = @datadir@
19 datarootdir = @datarootdir@
20 mandir = @mandir@ 20 mandir = @mandir@
21-man1dir = $(mandir)/man1 21-man1dir = $(mandir)/man1
22+man1dir = $(DESTDIR)$(mandir)/man1 22+man1dir = $(DESTDIR)$(mandir)/man1
@@ -24,5 +24,5 @@ index f713fcaa35b..7c553709d3f 100644
24 includedir = @includedir@ 24 includedir = @includedir@
25 25
26-- 26--
272.29.2 272.33.1
28 28
diff --git a/meta/recipes-devtools/gdb/gdb/0002-mips-linux-nat-Define-_ABIO32-if-not-defined.patch b/meta/recipes-devtools/gdb/gdb/0002-mips-linux-nat-Define-_ABIO32-if-not-defined.patch
index f830993d5e..591c9bfa3f 100644
--- a/meta/recipes-devtools/gdb/gdb/0002-mips-linux-nat-Define-_ABIO32-if-not-defined.patch
+++ b/meta/recipes-devtools/gdb/gdb/0002-mips-linux-nat-Define-_ABIO32-if-not-defined.patch
@@ -1,7 +1,7 @@
1From 0680242c9a3a0149a23e63034ecb4404de2293dd Mon Sep 17 00:00:00 2001 1From 7f1f25eaaace289bc33c5aaa1c5fe9e04e719651 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 23 Mar 2016 06:30:09 +0000 3Date: Wed, 23 Mar 2016 06:30:09 +0000
4Subject: [PATCH 02/11] mips-linux-nat: Define _ABIO32 if not defined 4Subject: [PATCH 02/10] mips-linux-nat: Define _ABIO32 if not defined
5 5
6This helps building gdb on mips64 on musl, since 6This helps building gdb on mips64 on musl, since
7musl does not provide sgidefs.h this define is 7musl does not provide sgidefs.h this define is
@@ -16,7 +16,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
16 1 file changed, 4 insertions(+) 16 1 file changed, 4 insertions(+)
17 17
18diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c 18diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
19index 38ff461a35b..4337795bac8 100644 19index b21c7cb2ea6..6614b4de31e 100644
20--- a/gdb/mips-linux-nat.c 20--- a/gdb/mips-linux-nat.c
21+++ b/gdb/mips-linux-nat.c 21+++ b/gdb/mips-linux-nat.c
22@@ -41,6 +41,10 @@ 22@@ -41,6 +41,10 @@
@@ -31,5 +31,5 @@ index 38ff461a35b..4337795bac8 100644
31 class mips_linux_nat_target final : public linux_nat_trad_target 31 class mips_linux_nat_target final : public linux_nat_trad_target
32 { 32 {
33-- 33--
342.29.2 342.33.1
35 35
diff --git a/meta/recipes-devtools/gdb/gdb/0003-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch b/meta/recipes-devtools/gdb/gdb/0003-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch
index cbe1779db7..09ea533b00 100644
--- a/meta/recipes-devtools/gdb/gdb/0003-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch
+++ b/meta/recipes-devtools/gdb/gdb/0003-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch
@@ -1,7 +1,7 @@
1From afbb66c244b1ae0aaaa90d88d3cd484f741c614f Mon Sep 17 00:00:00 2001 1From 0cb233ec3951582fa1a051a16bfd644ef4969df5 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 30 Apr 2016 18:32:14 -0700 3Date: Sat, 30 Apr 2016 18:32:14 -0700
4Subject: [PATCH 03/11] ppc/ptrace: Define pt_regs uapi_pt_regs on !GLIBC 4Subject: [PATCH 03/10] ppc/ptrace: Define pt_regs uapi_pt_regs on !GLIBC
5 systems 5 systems
6 6
7Upstream-Status: Pending 7Upstream-Status: Pending
@@ -13,7 +13,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
13 2 files changed, 12 insertions(+) 13 2 files changed, 12 insertions(+)
14 14
15diff --git a/gdb/nat/ppc-linux.h b/gdb/nat/ppc-linux.h 15diff --git a/gdb/nat/ppc-linux.h b/gdb/nat/ppc-linux.h
16index d937a65b69c..1fd54b4a0e0 100644 16index e712a9a5713..76bbcca0928 100644
17--- a/gdb/nat/ppc-linux.h 17--- a/gdb/nat/ppc-linux.h
18+++ b/gdb/nat/ppc-linux.h 18+++ b/gdb/nat/ppc-linux.h
19@@ -18,7 +18,13 @@ 19@@ -18,7 +18,13 @@
@@ -31,7 +31,7 @@ index d937a65b69c..1fd54b4a0e0 100644
31 31
32 /* This sometimes isn't defined. */ 32 /* This sometimes isn't defined. */
33diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc 33diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc
34index 337d555aee7..5d518f37268 100644 34index db9a88219ea..151e4183bb1 100644
35--- a/gdbserver/linux-ppc-low.cc 35--- a/gdbserver/linux-ppc-low.cc
36+++ b/gdbserver/linux-ppc-low.cc 36+++ b/gdbserver/linux-ppc-low.cc
37@@ -23,7 +23,13 @@ 37@@ -23,7 +23,13 @@
@@ -49,5 +49,5 @@ index 337d555aee7..5d518f37268 100644
49 #include "arch/ppc-linux-common.h" 49 #include "arch/ppc-linux-common.h"
50 #include "arch/ppc-linux-tdesc.h" 50 #include "arch/ppc-linux-tdesc.h"
51-- 51--
522.29.2 522.33.1
53 53
diff --git a/meta/recipes-devtools/gdb/gdb/0004-Add-support-for-Renesas-SH-sh4-architecture.patch b/meta/recipes-devtools/gdb/gdb/0004-Add-support-for-Renesas-SH-sh4-architecture.patch
index 561cfff943..37d633c9a8 100644
--- a/meta/recipes-devtools/gdb/gdb/0004-Add-support-for-Renesas-SH-sh4-architecture.patch
+++ b/meta/recipes-devtools/gdb/gdb/0004-Add-support-for-Renesas-SH-sh4-architecture.patch
@@ -1,7 +1,7 @@
1From 26e406962cf7298837b350b979afff0ac34ecb0b Mon Sep 17 00:00:00 2001 1From d86ff49710210fb10d149121fa9a04c7cf41cb8b Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 2 Mar 2015 02:31:12 +0000 3Date: Mon, 2 Mar 2015 02:31:12 +0000
4Subject: [PATCH 04/11] Add support for Renesas SH (sh4) architecture. 4Subject: [PATCH 04/10] Add support for Renesas SH (sh4) architecture.
5 5
6gdb (7.4-1~cvs20111117.2) experimental; urgency=low 6gdb (7.4-1~cvs20111117.2) experimental; urgency=low
7 . 7 .
@@ -14,7 +14,7 @@ Upstream-Status: Pending
14Signed-off-by: Khem Raj <raj.khem@gmail.com> 14Signed-off-by: Khem Raj <raj.khem@gmail.com>
15--- 15---
16 gdb/Makefile.in | 2 + 16 gdb/Makefile.in | 2 +
17 gdb/configure.host | 1 + 17 gdb/configure.host | 2 +
18 gdb/sh-linux-tdep.c | 519 +++++++++++++++++++++++++++ 18 gdb/sh-linux-tdep.c | 519 +++++++++++++++++++++++++++
19 gdb/sh-tdep.c | 52 +-- 19 gdb/sh-tdep.c | 52 +--
20 gdb/sh-tdep.h | 49 +++ 20 gdb/sh-tdep.h | 49 +++
@@ -24,15 +24,15 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
24 gdb/testsuite/gdb.base/annota3.c | 4 + 24 gdb/testsuite/gdb.base/annota3.c | 4 +
25 gdb/testsuite/gdb.base/sigall.c | 3 + 25 gdb/testsuite/gdb.base/sigall.c | 3 +
26 gdb/testsuite/gdb.base/signals.c | 4 + 26 gdb/testsuite/gdb.base/signals.c | 4 +
27 11 files changed, 617 insertions(+), 28 deletions(-) 27 11 files changed, 618 insertions(+), 28 deletions(-)
28 28
29diff --git a/gdb/Makefile.in b/gdb/Makefile.in 29diff --git a/gdb/Makefile.in b/gdb/Makefile.in
30index 4808357e651..a009004ab05 100644 30index b8729ed7b2e..ae5c05e1dbe 100644
31--- a/gdb/Makefile.in 31--- a/gdb/Makefile.in
32+++ b/gdb/Makefile.in 32+++ b/gdb/Makefile.in
33@@ -2273,6 +2273,8 @@ ALLDEPFILES = \ 33@@ -2284,6 +2284,8 @@ ALLDEPFILES = \
34 sh-nbsd-nat.c \ 34 sh-netbsd-nat.c \
35 sh-nbsd-tdep.c \ 35 sh-netbsd-tdep.c \
36 sh-tdep.c \ 36 sh-tdep.c \
37+ sh-linux-tdep.c \ 37+ sh-linux-tdep.c \
38+ sh-linux-nat.c \ 38+ sh-linux-nat.c \
@@ -40,19 +40,20 @@ index 4808357e651..a009004ab05 100644
40 solib-aix.c \ 40 solib-aix.c \
41 solib-svr4.c \ 41 solib-svr4.c \
42diff --git a/gdb/configure.host b/gdb/configure.host 42diff --git a/gdb/configure.host b/gdb/configure.host
43index ce528237291..5b5173a71aa 100644 43index e94a19b0332..08b8478b56b 100644
44--- a/gdb/configure.host 44--- a/gdb/configure.host
45+++ b/gdb/configure.host 45+++ b/gdb/configure.host
46@@ -148,6 +148,7 @@ riscv*-*-linux*) gdb_host=linux ;; 46@@ -151,6 +151,8 @@ riscv*-*-linux*) gdb_host=linux ;;
47 47
48 s390*-*-linux*) gdb_host=linux ;; 48 s390*-*-linux*) gdb_host=linux ;;
49 49
50+sh*-*-linux*) gdb_host=linux ;; 50+sh*-*-linux*) gdb_host=linux ;;
51+
51 sh*-*-netbsdelf* | sh*-*-knetbsd*-gnu) 52 sh*-*-netbsdelf* | sh*-*-knetbsd*-gnu)
52 gdb_host=nbsd ;; 53 gdb_host=nbsd ;;
53 sh*-*-openbsd*) gdb_host=nbsd ;; 54 sh*-*-openbsd*) gdb_host=nbsd ;;
54diff --git a/gdb/sh-linux-tdep.c b/gdb/sh-linux-tdep.c 55diff --git a/gdb/sh-linux-tdep.c b/gdb/sh-linux-tdep.c
55index 5d2f38f5801..06a45b74827 100644 56index 700df35bc3b..aaed47ded81 100644
56--- a/gdb/sh-linux-tdep.c 57--- a/gdb/sh-linux-tdep.c
57+++ b/gdb/sh-linux-tdep.c 58+++ b/gdb/sh-linux-tdep.c
58@@ -18,14 +18,37 @@ 59@@ -18,14 +18,37 @@
@@ -596,11 +597,11 @@ index 5d2f38f5801..06a45b74827 100644
596+ set_gdbarch_regset_from_core_section (gdbarch, 597+ set_gdbarch_regset_from_core_section (gdbarch,
597+ sh_linux_regset_from_core_section); 598+ sh_linux_regset_from_core_section);
598+ 599+
599 linux_init_abi (info, gdbarch); 600 linux_init_abi (info, gdbarch, 0);
600 601
601 /* GNU/Linux uses SVR4-style shared libraries. */ 602 /* GNU/Linux uses SVR4-style shared libraries. */
602diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c 603diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
603index 7aadf9165ca..e173e215a2d 100644 604index bfb220adf79..6a077b235bf 100644
604--- a/gdb/sh-tdep.c 605--- a/gdb/sh-tdep.c
605+++ b/gdb/sh-tdep.c 606+++ b/gdb/sh-tdep.c
606@@ -21,6 +21,9 @@ 607@@ -21,6 +21,9 @@
@@ -694,7 +695,7 @@ index 7aadf9165ca..e173e215a2d 100644
694 695
695 if (regnum < SH_NUM_REGS && cache->saved_regs[regnum] != -1) 696 if (regnum < SH_NUM_REGS && cache->saved_regs[regnum] != -1)
696 return frame_unwind_got_memory (this_frame, regnum, 697 return frame_unwind_got_memory (this_frame, regnum,
697@@ -2234,8 +2221,8 @@ sh_return_in_first_hidden_param_p (struct gdbarch *gdbarch, 698@@ -2236,8 +2223,8 @@ sh_return_in_first_hidden_param_p (struct gdbarch *gdbarch,
698 static struct gdbarch * 699 static struct gdbarch *
699 sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 700 sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
700 { 701 {
@@ -704,7 +705,7 @@ index 7aadf9165ca..e173e215a2d 100644
704 705
705 /* If there is already a candidate, use it. */ 706 /* If there is already a candidate, use it. */
706 arches = gdbarch_list_lookup_by_info (arches, &info); 707 arches = gdbarch_list_lookup_by_info (arches, &info);
707@@ -2247,6 +2234,18 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 708@@ -2249,6 +2236,18 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
708 tdep = XCNEW (struct gdbarch_tdep); 709 tdep = XCNEW (struct gdbarch_tdep);
709 gdbarch = gdbarch_alloc (&info, tdep); 710 gdbarch = gdbarch_alloc (&info, tdep);
710 711
@@ -723,7 +724,7 @@ index 7aadf9165ca..e173e215a2d 100644
723 set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT); 724 set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
724 set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT); 725 set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
725 set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT); 726 set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT);
726@@ -2398,10 +2397,11 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 727@@ -2400,10 +2399,11 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
727 break; 728 break;
728 } 729 }
729 730
@@ -737,7 +738,7 @@ index 7aadf9165ca..e173e215a2d 100644
737 frame_unwind_append_unwinder (gdbarch, &sh_frame_unwind); 738 frame_unwind_append_unwinder (gdbarch, &sh_frame_unwind);
738 739
739diff --git a/gdb/sh-tdep.h b/gdb/sh-tdep.h 740diff --git a/gdb/sh-tdep.h b/gdb/sh-tdep.h
740index 76e2e76e39b..2710f63010c 100644 741index 737b6dc6bdc..8d82e819b8c 100644
741--- a/gdb/sh-tdep.h 742--- a/gdb/sh-tdep.h
742+++ b/gdb/sh-tdep.h 743+++ b/gdb/sh-tdep.h
743@@ -21,6 +21,12 @@ 744@@ -21,6 +21,12 @@
@@ -820,7 +821,7 @@ index 76e2e76e39b..2710f63010c 100644
820 where each general-purpose register is stored inside the associated 821 where each general-purpose register is stored inside the associated
821 core file section. */ 822 core file section. */
822diff --git a/gdb/testsuite/gdb.asm/asm-source.exp b/gdb/testsuite/gdb.asm/asm-source.exp 823diff --git a/gdb/testsuite/gdb.asm/asm-source.exp b/gdb/testsuite/gdb.asm/asm-source.exp
823index 4914498f98c..6e25cbed185 100644 824index dedcd92f2df..ae81b8becd3 100644
824--- a/gdb/testsuite/gdb.asm/asm-source.exp 825--- a/gdb/testsuite/gdb.asm/asm-source.exp
825+++ b/gdb/testsuite/gdb.asm/asm-source.exp 826+++ b/gdb/testsuite/gdb.asm/asm-source.exp
826@@ -116,6 +116,11 @@ switch -glob -- [istarget] { 827@@ -116,6 +116,11 @@ switch -glob -- [istarget] {
@@ -909,5 +910,5 @@ index 756606880fa..1205a9bc9c5 100644
909 static int count = 0; 910 static int count = 0;
910 911
911-- 912--
9122.29.2 9132.33.1
913 914
diff --git a/meta/recipes-devtools/gdb/gdb/0005-Dont-disable-libreadline.a-when-using-disable-static.patch b/meta/recipes-devtools/gdb/gdb/0005-Dont-disable-libreadline.a-when-using-disable-static.patch
index 71eab1c2b1..02ea30f9bf 100644
--- a/meta/recipes-devtools/gdb/gdb/0005-Dont-disable-libreadline.a-when-using-disable-static.patch
+++ b/meta/recipes-devtools/gdb/gdb/0005-Dont-disable-libreadline.a-when-using-disable-static.patch
@@ -1,7 +1,7 @@
1From ec566877c50bdae0013a38dd457004e1db725d86 Mon Sep 17 00:00:00 2001 1From e2efd044c479895767f1b929f5a54fa0c689f318 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 30 Apr 2016 15:25:03 -0700 3Date: Sat, 30 Apr 2016 15:25:03 -0700
4Subject: [PATCH 05/11] Dont disable libreadline.a when using --disable-static 4Subject: [PATCH 05/10] Dont disable libreadline.a when using --disable-static
5 5
6If gdb is configured with --disable-static then this is dutifully passed to 6If gdb is configured with --disable-static then this is dutifully passed to
7readline which then disables libreadline.a, which causes a problem when gdb 7readline which then disables libreadline.a, which causes a problem when gdb
@@ -19,7 +19,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
19 2 files changed, 3 insertions(+), 2 deletions(-) 19 2 files changed, 3 insertions(+), 2 deletions(-)
20 20
21diff --git a/Makefile.def b/Makefile.def 21diff --git a/Makefile.def b/Makefile.def
22index 76d062bb671..e0a1e2b14b1 100644 22index 5a460f1dbbc..77a702ac6d6 100644
23--- a/Makefile.def 23--- a/Makefile.def
24+++ b/Makefile.def 24+++ b/Makefile.def
25@@ -105,7 +105,8 @@ host_modules= { module= libiconv; 25@@ -105,7 +105,8 @@ host_modules= { module= libiconv;
@@ -33,10 +33,10 @@ index 76d062bb671..e0a1e2b14b1 100644
33 host_modules= { module= sim; }; 33 host_modules= { module= sim; };
34 host_modules= { module= texinfo; no_install= true; }; 34 host_modules= { module= texinfo; no_install= true; };
35diff --git a/Makefile.in b/Makefile.in 35diff --git a/Makefile.in b/Makefile.in
36index 9dfd39fae13..eaf1dd0f229 100644 36index 9b3a5d75735..98cbe844fca 100644
37--- a/Makefile.in 37--- a/Makefile.in
38+++ b/Makefile.in 38+++ b/Makefile.in
39@@ -25548,7 +25548,7 @@ configure-readline: 39@@ -25607,7 +25607,7 @@ configure-readline:
40 $$s/$$module_srcdir/configure \ 40 $$s/$$module_srcdir/configure \
41 --srcdir=$${topdir}/$$module_srcdir \ 41 --srcdir=$${topdir}/$$module_srcdir \
42 $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \ 42 $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
@@ -46,5 +46,5 @@ index 9dfd39fae13..eaf1dd0f229 100644
46 @endif readline 46 @endif readline
47 47
48-- 48--
492.29.2 492.33.1
50 50
diff --git a/meta/recipes-devtools/gdb/gdb/0006-use-asm-sgidefs.h.patch b/meta/recipes-devtools/gdb/gdb/0006-use-asm-sgidefs.h.patch
index a2932be6fb..ef271c45e2 100644
--- a/meta/recipes-devtools/gdb/gdb/0006-use-asm-sgidefs.h.patch
+++ b/meta/recipes-devtools/gdb/gdb/0006-use-asm-sgidefs.h.patch
@@ -1,7 +1,7 @@
1From 4b02e54b87d435e1715ce871bcce720561a7afb1 Mon Sep 17 00:00:00 2001 1From 5077518c11e8d75e9bf65cdf9ca21c59564e1037 Mon Sep 17 00:00:00 2001
2From: Andre McCurdy <amccurdy@gmail.com> 2From: Andre McCurdy <amccurdy@gmail.com>
3Date: Sat, 30 Apr 2016 15:29:06 -0700 3Date: Sat, 30 Apr 2016 15:29:06 -0700
4Subject: [PATCH 06/11] use <asm/sgidefs.h> 4Subject: [PATCH 06/10] use <asm/sgidefs.h>
5 5
6Build fix for MIPS with musl libc 6Build fix for MIPS with musl libc
7 7
@@ -19,7 +19,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
19 1 file changed, 1 insertion(+), 1 deletion(-) 19 1 file changed, 1 insertion(+), 1 deletion(-)
20 20
21diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c 21diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
22index 4337795bac8..7c8e54cabe0 100644 22index 6614b4de31e..237eb6eb975 100644
23--- a/gdb/mips-linux-nat.c 23--- a/gdb/mips-linux-nat.c
24+++ b/gdb/mips-linux-nat.c 24+++ b/gdb/mips-linux-nat.c
25@@ -31,7 +31,7 @@ 25@@ -31,7 +31,7 @@
@@ -32,5 +32,5 @@ index 4337795bac8..7c8e54cabe0 100644
32 #include <asm/ptrace.h> 32 #include <asm/ptrace.h>
33 #include "inf-ptrace.h" 33 #include "inf-ptrace.h"
34-- 34--
352.29.2 352.33.1
36 36
diff --git a/meta/recipes-devtools/gdb/gdb/0008-Change-order-of-CFLAGS.patch b/meta/recipes-devtools/gdb/gdb/0007-Change-order-of-CFLAGS.patch
index 4622752247..40d12579c0 100644
--- a/meta/recipes-devtools/gdb/gdb/0008-Change-order-of-CFLAGS.patch
+++ b/meta/recipes-devtools/gdb/gdb/0007-Change-order-of-CFLAGS.patch
@@ -1,7 +1,7 @@
1From 07175ae348c9d07581e1db94762d5a2d577a75ad Mon Sep 17 00:00:00 2001 1From 80080e6c8425ac51498f49c2063b960a08f9a27d Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 30 Apr 2016 15:35:39 -0700 3Date: Sat, 30 Apr 2016 15:35:39 -0700
4Subject: [PATCH 08/11] Change order of CFLAGS 4Subject: [PATCH 07/10] Change order of CFLAGS
5 5
6Lets us override Werror if need be 6Lets us override Werror if need be
7 7
@@ -13,11 +13,11 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
13 1 file changed, 1 insertion(+), 1 deletion(-) 13 1 file changed, 1 insertion(+), 1 deletion(-)
14 14
15diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in 15diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in
16index 2b1a77f2de7..cb5ddb12fd5 100644 16index 12e9b2777ae..ad44fbc3309 100644
17--- a/gdbserver/Makefile.in 17--- a/gdbserver/Makefile.in
18+++ b/gdbserver/Makefile.in 18+++ b/gdbserver/Makefile.in
19@@ -161,7 +161,7 @@ WIN32APILIBS = @WIN32APILIBS@ 19@@ -172,7 +172,7 @@ WIN32APILIBS = @WIN32APILIBS@
20 INTERNAL_CFLAGS_BASE = ${CXXFLAGS} ${GLOBAL_CFLAGS} \ 20 INTERNAL_CFLAGS_BASE = ${GLOBAL_CFLAGS} \
21 ${PROFILE_CFLAGS} ${INCLUDE_CFLAGS} ${CPPFLAGS} $(PTHREAD_CFLAGS) 21 ${PROFILE_CFLAGS} ${INCLUDE_CFLAGS} ${CPPFLAGS} $(PTHREAD_CFLAGS)
22 INTERNAL_WARN_CFLAGS = ${INTERNAL_CFLAGS_BASE} $(WARN_CFLAGS) 22 INTERNAL_WARN_CFLAGS = ${INTERNAL_CFLAGS_BASE} $(WARN_CFLAGS)
23-INTERNAL_CFLAGS = ${INTERNAL_WARN_CFLAGS} $(WERROR_CFLAGS) -DGDBSERVER 23-INTERNAL_CFLAGS = ${INTERNAL_WARN_CFLAGS} $(WERROR_CFLAGS) -DGDBSERVER
@@ -26,5 +26,5 @@ index 2b1a77f2de7..cb5ddb12fd5 100644
26 # LDFLAGS is specifically reserved for setting from the command line 26 # LDFLAGS is specifically reserved for setting from the command line
27 # when running make. 27 # when running make.
28-- 28--
292.29.2 292.33.1
30 30
diff --git a/meta/recipes-devtools/gdb/gdb/0009-resolve-restrict-keyword-conflict.patch b/meta/recipes-devtools/gdb/gdb/0008-resolve-restrict-keyword-conflict.patch
index 698fdb0672..9095f90582 100644
--- a/meta/recipes-devtools/gdb/gdb/0009-resolve-restrict-keyword-conflict.patch
+++ b/meta/recipes-devtools/gdb/gdb/0008-resolve-restrict-keyword-conflict.patch
@@ -1,7 +1,7 @@
1From 73a3babe48c7948f71683d0862eddc1609fdaa3d Mon Sep 17 00:00:00 2001 1From 4ee7e8afb9ff259e889ac938c673fda9ddc5e15a Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 10 May 2016 08:47:05 -0700 3Date: Tue, 10 May 2016 08:47:05 -0700
4Subject: [PATCH 09/11] resolve restrict keyword conflict 4Subject: [PATCH 08/10] resolve restrict keyword conflict
5 5
6GCC detects that we call 'restrict' as param name in function 6GCC detects that we call 'restrict' as param name in function
7signatures and complains since both params are called 'restrict' 7signatures and complains since both params are called 'restrict'
@@ -15,7 +15,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
15 1 file changed, 4 insertions(+), 4 deletions(-) 15 1 file changed, 4 insertions(+), 4 deletions(-)
16 16
17diff --git a/gnulib/import/sys_time.in.h b/gnulib/import/sys_time.in.h 17diff --git a/gnulib/import/sys_time.in.h b/gnulib/import/sys_time.in.h
18index d30b26719b2..fd76af5e6d9 100644 18index 90a67d18426..664641a1fe8 100644
19--- a/gnulib/import/sys_time.in.h 19--- a/gnulib/import/sys_time.in.h
20+++ b/gnulib/import/sys_time.in.h 20+++ b/gnulib/import/sys_time.in.h
21@@ -93,20 +93,20 @@ struct timeval 21@@ -93,20 +93,20 @@ struct timeval
@@ -44,5 +44,5 @@ index d30b26719b2..fd76af5e6d9 100644
44 _GL_CXXALIASWARN (gettimeofday); 44 _GL_CXXALIASWARN (gettimeofday);
45 # if defined __cplusplus && defined GNULIB_NAMESPACE 45 # if defined __cplusplus && defined GNULIB_NAMESPACE
46-- 46--
472.29.2 472.33.1
48 48
diff --git a/meta/recipes-devtools/gdb/gdb/0010-Fix-invalid-sigprocmask-call.patch b/meta/recipes-devtools/gdb/gdb/0009-Fix-invalid-sigprocmask-call.patch
index 7cf3eae753..5b9d1cfaf9 100644
--- a/meta/recipes-devtools/gdb/gdb/0010-Fix-invalid-sigprocmask-call.patch
+++ b/meta/recipes-devtools/gdb/gdb/0009-Fix-invalid-sigprocmask-call.patch
@@ -1,7 +1,7 @@
1From c5c5372c6a319cac8b3f9f86304fcebcbb5ea06f Mon Sep 17 00:00:00 2001 1From 5740876d92ddb67b039d5fbcd1b71e6c58823c08 Mon Sep 17 00:00:00 2001
2From: Yousong Zhou <yszhou4tech@gmail.com> 2From: Yousong Zhou <yszhou4tech@gmail.com>
3Date: Fri, 24 Mar 2017 10:36:03 +0800 3Date: Fri, 24 Mar 2017 10:36:03 +0800
4Subject: [PATCH 10/11] Fix invalid sigprocmask call 4Subject: [PATCH 09/10] Fix invalid sigprocmask call
5MIME-Version: 1.0 5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8 6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit 7Content-Transfer-Encoding: 8bit
@@ -32,7 +32,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
32 1 file changed, 1 insertion(+), 1 deletion(-) 32 1 file changed, 1 insertion(+), 1 deletion(-)
33 33
34diff --git a/gdbsupport/signals-state-save-restore.cc b/gdbsupport/signals-state-save-restore.cc 34diff --git a/gdbsupport/signals-state-save-restore.cc b/gdbsupport/signals-state-save-restore.cc
35index c292d498daf..af9dcaeb08e 100644 35index 95c156e5036..f4aa512d105 100644
36--- a/gdbsupport/signals-state-save-restore.cc 36--- a/gdbsupport/signals-state-save-restore.cc
37+++ b/gdbsupport/signals-state-save-restore.cc 37+++ b/gdbsupport/signals-state-save-restore.cc
38@@ -38,7 +38,7 @@ save_original_signals_state (bool quiet) 38@@ -38,7 +38,7 @@ save_original_signals_state (bool quiet)
@@ -45,5 +45,5 @@ index c292d498daf..af9dcaeb08e 100644
45 perror_with_name (("sigprocmask")); 45 perror_with_name (("sigprocmask"));
46 46
47-- 47--
482.29.2 482.33.1
49 49
diff --git a/meta/recipes-devtools/gdb/gdb/0011-gdbserver-ctrl-c-handling.patch b/meta/recipes-devtools/gdb/gdb/0010-gdbserver-ctrl-c-handling.patch
index 0a596b522f..cb4744e5dd 100644
--- a/meta/recipes-devtools/gdb/gdb/0011-gdbserver-ctrl-c-handling.patch
+++ b/meta/recipes-devtools/gdb/gdb/0010-gdbserver-ctrl-c-handling.patch
@@ -1,7 +1,7 @@
1From 63df98fa78c8a6e12b40ebdc5c155838d2bf8b5f Mon Sep 17 00:00:00 2001 1From d611a68f05c0c86af27bf6beae189a90a946e2e3 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 29 Nov 2018 18:00:23 -0800 3Date: Thu, 29 Nov 2018 18:00:23 -0800
4Subject: [PATCH 11/11] gdbserver ctrl-c handling 4Subject: [PATCH 10/10] gdbserver ctrl-c handling
5 5
6This problem was created by the upstream commit 78708b7c8c 6This problem was created by the upstream commit 78708b7c8c
7After applying the commit, it will send SIGINT to the process 7After applying the commit, it will send SIGINT to the process
@@ -23,10 +23,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
23 1 file changed, 1 insertion(+), 1 deletion(-) 23 1 file changed, 1 insertion(+), 1 deletion(-)
24 24
25diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc 25diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
26index e45493339d2..aabc099b456 100644 26index 5c6191d941c..7f7acf6700d 100644
27--- a/gdbserver/linux-low.cc 27--- a/gdbserver/linux-low.cc
28+++ b/gdbserver/linux-low.cc 28+++ b/gdbserver/linux-low.cc
29@@ -5714,7 +5714,7 @@ linux_process_target::request_interrupt () 29@@ -5733,7 +5733,7 @@ linux_process_target::request_interrupt ()
30 { 30 {
31 /* Send a SIGINT to the process group. This acts just like the user 31 /* Send a SIGINT to the process group. This acts just like the user
32 typed a ^C on the controlling terminal. */ 32 typed a ^C on the controlling terminal. */
@@ -36,5 +36,5 @@ index e45493339d2..aabc099b456 100644
36 36
37 bool 37 bool
38-- 38--
392.29.2 392.33.1
40 40
diff --git a/meta/recipes-devtools/gdb/gdb/0012-arc-Add-support-for-signal-handlers.patch b/meta/recipes-devtools/gdb/gdb/0012-arc-Add-support-for-signal-handlers.patch
deleted file mode 100644
index 6a98b65766..0000000000
--- a/meta/recipes-devtools/gdb/gdb/0012-arc-Add-support-for-signal-handlers.patch
+++ /dev/null
@@ -1,218 +0,0 @@
1From bfee93403b46ae4f050282b7721ba39073905c69 Mon Sep 17 00:00:00 2001
2From: Anton Kolesov <Anton.Kolesov@synopsys.com>
3Date: Mon, 22 Aug 2016 19:39:46 +0300
4Subject: [PATCH 1/4] arc: Add support for signal handlers
5
6This patch adds the necessary infrastructure to handle signal frames for
7ARC architecture. It is fairly similar to what any other architecture
8would have. Linux specific parts will be in a separate patch.
9
10v2 [1]:
11- Make the logic of "arc_sigtramp_frame_sniffer ()" simpler.
12
13[1] Tom's remark for the first version
14https://sourceware.org/pipermail/gdb-patches/2020-November/173221.html
15
16gdb/ChangeLog:
17
18 * arc-tdep.c (arc_make_sigtramp_frame_cache): New function.
19 (arc_sigtramp_frame_this_id): Likewise.
20 (arc_sigtramp_frame_prev_register): Likewise.
21 (arc_sigtramp_frame_sniffer): Likewise.
22 (arc_siftramp_frame_unwind): New global variable.
23 (arc_gdbarch_init): Use sigtramp capabilities.
24 (arc_dump_tdep): Print sigtramp fields.
25 * arc-tdep.h (gdbarch_tdep): Add sigtramp fields.
26
27Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=b4e3cd0440109d0a5552d3313ccbd35c8103335b]
28
29Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
30Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
31Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
32---
33 gdb/arc-tdep.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34 gdb/arc-tdep.h | 13 ++++++
35 2 files changed, 136 insertions(+)
36
37diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
38index 93e2fd88a9a..3356252525d 100644
39--- a/gdb/arc-tdep.c
40+++ b/gdb/arc-tdep.c
41@@ -1843,6 +1843,104 @@ arc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
42 reg->how = DWARF2_FRAME_REG_CFA;
43 }
44
45+/* Signal trampoline frame unwinder. Allows frame unwinding to happen
46+ from within signal handlers. */
47+
48+static struct arc_frame_cache *
49+arc_make_sigtramp_frame_cache (struct frame_info *this_frame)
50+{
51+ if (arc_debug)
52+ debug_printf ("arc: sigtramp_frame_cache\n");
53+
54+ struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
55+
56+ /* Allocate new frame cache instance and space for saved register info. */
57+ struct arc_frame_cache *cache = FRAME_OBSTACK_ZALLOC (struct arc_frame_cache);
58+ cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
59+
60+ /* Get the stack pointer and use it as the frame base. */
61+ cache->prev_sp = arc_frame_base_address (this_frame, NULL);
62+
63+ /* If the ARC-private target-dependent info doesn't have a table of
64+ offsets of saved register contents within an OS signal context
65+ structure, then there is nothing to analyze. */
66+ if (tdep->sc_reg_offset == NULL)
67+ return cache;
68+
69+ /* Find the address of the sigcontext structure. */
70+ CORE_ADDR addr = tdep->sigcontext_addr (this_frame);
71+
72+ /* For each register, if its contents have been saved within the
73+ sigcontext structure, determine the address of those contents. */
74+ gdb_assert (tdep->sc_num_regs <= (ARC_LAST_REGNUM + 1));
75+ for (int i = 0; i < tdep->sc_num_regs; i++)
76+ {
77+ if (tdep->sc_reg_offset[i] != ARC_OFFSET_NO_REGISTER)
78+ cache->saved_regs[i].addr = addr + tdep->sc_reg_offset[i];
79+ }
80+
81+ return cache;
82+}
83+
84+/* Implement the "this_id" frame_unwind method for signal trampoline
85+ frames. */
86+
87+static void
88+arc_sigtramp_frame_this_id (struct frame_info *this_frame,
89+ void **this_cache, struct frame_id *this_id)
90+{
91+ if (arc_debug)
92+ debug_printf ("arc: sigtramp_frame_this_id\n");
93+
94+ if (*this_cache == NULL)
95+ *this_cache = arc_make_sigtramp_frame_cache (this_frame);
96+
97+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
98+ struct arc_frame_cache *cache = (struct arc_frame_cache *) *this_cache;
99+ CORE_ADDR stack_addr = cache->prev_sp;
100+ CORE_ADDR code_addr
101+ = get_frame_register_unsigned (this_frame, gdbarch_pc_regnum (gdbarch));
102+ *this_id = frame_id_build (stack_addr, code_addr);
103+}
104+
105+/* Get a register from a signal handler frame. */
106+
107+static struct value *
108+arc_sigtramp_frame_prev_register (struct frame_info *this_frame,
109+ void **this_cache, int regnum)
110+{
111+ if (arc_debug)
112+ debug_printf ("arc: sigtramp_frame_prev_register (regnum = %d)\n", regnum);
113+
114+ /* Make sure we've initialized the cache. */
115+ if (*this_cache == NULL)
116+ *this_cache = arc_make_sigtramp_frame_cache (this_frame);
117+
118+ struct arc_frame_cache *cache = (struct arc_frame_cache *) *this_cache;
119+ return trad_frame_get_prev_register (this_frame, cache->saved_regs, regnum);
120+}
121+
122+/* Frame sniffer for signal handler frame. Only recognize a frame if we
123+ have a sigcontext_addr handler in the target dependency. */
124+
125+static int
126+arc_sigtramp_frame_sniffer (const struct frame_unwind *self,
127+ struct frame_info *this_frame,
128+ void **this_cache)
129+{
130+ struct gdbarch_tdep *tdep;
131+
132+ if (arc_debug)
133+ debug_printf ("arc: sigtramp_frame_sniffer\n");
134+
135+ tdep = gdbarch_tdep (get_frame_arch (this_frame));
136+
137+ /* If we have a sigcontext_addr handler, then just return 1 (same as the
138+ "default_frame_sniffer ()"). */
139+ return (tdep->sigcontext_addr != NULL && tdep->is_sigtramp != NULL
140+ && tdep->is_sigtramp (this_frame));
141+}
142+
143 /* Structure defining the ARC ordinary frame unwind functions. Since we are
144 the fallback unwinder, we use the default frame sniffer, which always
145 accepts the frame. */
146@@ -1858,6 +1956,21 @@ static const struct frame_unwind arc_frame_unwind = {
147 NULL
148 };
149
150+/* Structure defining the ARC signal frame unwind functions. Custom
151+ sniffer is used, because this frame must be accepted only in the right
152+ context. */
153+
154+static const struct frame_unwind arc_sigtramp_frame_unwind = {
155+ SIGTRAMP_FRAME,
156+ default_frame_unwind_stop_reason,
157+ arc_sigtramp_frame_this_id,
158+ arc_sigtramp_frame_prev_register,
159+ NULL,
160+ arc_sigtramp_frame_sniffer,
161+ NULL,
162+ NULL
163+};
164+
165
166 static const struct frame_base arc_normal_base = {
167 &arc_frame_unwind,
168@@ -2272,6 +2385,7 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
169 /* Frame unwinders and sniffers. */
170 dwarf2_frame_set_init_reg (gdbarch, arc_dwarf2_frame_init_reg);
171 dwarf2_append_unwinders (gdbarch);
172+ frame_unwind_append_unwinder (gdbarch, &arc_sigtramp_frame_unwind);
173 frame_unwind_append_unwinder (gdbarch, &arc_frame_unwind);
174 frame_base_set_default (gdbarch, &arc_normal_base);
175
176@@ -2350,6 +2464,15 @@ arc_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
177 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
178
179 fprintf_unfiltered (file, "arc_dump_tdep: jb_pc = %i\n", tdep->jb_pc);
180+
181+ fprintf_unfiltered (file, "arc_dump_tdep: is_sigtramp = <%s>\n",
182+ host_address_to_string (tdep->is_sigtramp));
183+ fprintf_unfiltered (file, "arc_dump_tdep: sigcontext_addr = <%s>\n",
184+ host_address_to_string (tdep->sigcontext_addr));
185+ fprintf_unfiltered (file, "arc_dump_tdep: sc_reg_offset = <%s>\n",
186+ host_address_to_string (tdep->sc_reg_offset));
187+ fprintf_unfiltered (file, "arc_dump_tdep: sc_num_regs = %d\n",
188+ tdep->sc_num_regs);
189 }
190
191 /* This command accepts single argument - address of instruction to
192diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h
193index 50b14905134..70fc3d95c48 100644
194--- a/gdb/arc-tdep.h
195+++ b/gdb/arc-tdep.h
196@@ -124,6 +124,19 @@ struct gdbarch_tdep
197
198 /* Whether target has hardware (aka zero-delay) loops. */
199 bool has_hw_loops;
200+
201+ /* Detect sigtramp. */
202+ bool (*is_sigtramp) (struct frame_info *);
203+
204+ /* Get address of sigcontext for sigtramp. */
205+ CORE_ADDR (*sigcontext_addr) (struct frame_info *);
206+
207+ /* Offset of registers in `struct sigcontext'. */
208+ const int *sc_reg_offset;
209+
210+ /* Number of registers in sc_reg_offsets. Most likely a ARC_LAST_REGNUM,
211+ but in theory it could be less, so it is kept separate. */
212+ int sc_num_regs;
213 };
214
215 /* Utility functions used by other ARC-specific modules. */
216--
2172.16.2
218
diff --git a/meta/recipes-devtools/gdb/gdb/0013-arc-Add-support-for-signal-frames-for-Linux-targets.patch b/meta/recipes-devtools/gdb/gdb/0013-arc-Add-support-for-signal-frames-for-Linux-targets.patch
deleted file mode 100644
index f699a5888d..0000000000
--- a/meta/recipes-devtools/gdb/gdb/0013-arc-Add-support-for-signal-frames-for-Linux-targets.patch
+++ /dev/null
@@ -1,232 +0,0 @@
1From 16ddc17b4f403a38701e0108b02aff967900cc66 Mon Sep 17 00:00:00 2001
2From: Anton Kolesov <Anton.Kolesov@synopsys.com>
3Date: Thu, 22 Dec 2016 21:52:16 +0300
4Subject: [PATCH 2/4] arc: Add support for signal frames for Linux targets
5
6Implement functions needed to unwind signal frames on ARC Linux targets.
7
8gdb/ChangeLog
9
10 * arc-linux-tdep.c (arc_linux_sc_reg_offsets): New static variable.
11 (arc_linux_is_sigtramp): New function.
12 (arc_linux_sigcontext_addr): Likewise.
13 (arc_linux_init_osabi): Use them.
14
15Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d4af727286e3a9f177ba11677fbd3a012d36558a]
16
17Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
18Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
19Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
20---
21 gdb/arc-linux-tdep.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++
22 1 file changed, 181 insertions(+)
23
24diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c
25index a7bace12623..17bb3e7b276 100644
26--- a/gdb/arc-linux-tdep.c
27+++ b/gdb/arc-linux-tdep.c
28@@ -33,6 +33,60 @@
29
30 #define REGOFF(offset) (offset * ARC_REGISTER_SIZE)
31
32+/* arc_linux_sc_reg_offsets[i] is the offset of register i in the `struct
33+ sigcontext'. Array index is an internal GDB register number, as defined in
34+ arc-tdep.h:arc_regnum.
35+
36+ From <include/uapi/asm/sigcontext.h> and <include/uapi/asm/ptrace.h>.
37+
38+ The layout of this struct is tightly bound to "arc_regnum" enum
39+ in arc-tdep.h. Any change of order in there, must be reflected
40+ here as well. */
41+static const int arc_linux_sc_reg_offsets[] = {
42+ /* R0 - R12. */
43+ REGOFF (22), REGOFF (21), REGOFF (20), REGOFF (19),
44+ REGOFF (18), REGOFF (17), REGOFF (16), REGOFF (15),
45+ REGOFF (14), REGOFF (13), REGOFF (12), REGOFF (11),
46+ REGOFF (10),
47+
48+ /* R13 - R25. */
49+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
50+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
51+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
52+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
53+ ARC_OFFSET_NO_REGISTER,
54+
55+ REGOFF (9), /* R26 (GP) */
56+ REGOFF (8), /* FP */
57+ REGOFF (23), /* SP */
58+ ARC_OFFSET_NO_REGISTER, /* ILINK */
59+ ARC_OFFSET_NO_REGISTER, /* R30 */
60+ REGOFF (7), /* BLINK */
61+
62+ /* R32 - R59. */
63+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
64+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
65+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
66+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
67+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
68+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
69+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
70+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
71+ ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER, ARC_OFFSET_NO_REGISTER,
72+ ARC_OFFSET_NO_REGISTER,
73+
74+ REGOFF (4), /* LP_COUNT */
75+ ARC_OFFSET_NO_REGISTER, /* RESERVED */
76+ ARC_OFFSET_NO_REGISTER, /* LIMM */
77+ ARC_OFFSET_NO_REGISTER, /* PCL */
78+
79+ REGOFF (6), /* PC */
80+ REGOFF (5), /* STATUS32 */
81+ REGOFF (2), /* LP_START */
82+ REGOFF (3), /* LP_END */
83+ REGOFF (1), /* BTA */
84+};
85+
86 /* arc_linux_core_reg_offsets[i] is the offset in the .reg section of GDB
87 regnum i. Array index is an internal GDB register number, as defined in
88 arc-tdep.h:arc_regnum.
89@@ -87,6 +141,127 @@ static const int arc_linux_core_reg_offsets[] = {
90 REGOFF (6) /* ERET */
91 };
92
93+/* Is THIS_FRAME a sigtramp function - the function that returns from
94+ signal handler into normal execution flow? This is the case if the PC is
95+ either at the start of, or in the middle of the two instructions:
96+
97+ mov r8, __NR_rt_sigreturn ; __NR_rt_sigreturn == 139
98+ trap_s 0 ; `swi' for ARC700
99+
100+ On ARC uClibc Linux this function is called __default_rt_sa_restorer.
101+
102+ Returns TRUE if this is a sigtramp frame. */
103+
104+static bool
105+arc_linux_is_sigtramp (struct frame_info *this_frame)
106+{
107+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
108+ CORE_ADDR pc = get_frame_pc (this_frame);
109+
110+ if (arc_debug)
111+ {
112+ debug_printf ("arc-linux: arc_linux_is_sigtramp, pc=%s\n",
113+ paddress(gdbarch, pc));
114+ }
115+
116+ static const gdb_byte insns_be_hs[] = {
117+ 0x20, 0x8a, 0x12, 0xc2, /* mov r8,nr_rt_sigreturn */
118+ 0x78, 0x1e /* trap_s 0 */
119+ };
120+ static const gdb_byte insns_be_700[] = {
121+ 0x20, 0x8a, 0x12, 0xc2, /* mov r8,nr_rt_sigreturn */
122+ 0x22, 0x6f, 0x00, 0x3f /* swi */
123+ };
124+
125+ gdb_byte arc_sigtramp_insns[sizeof (insns_be_700)];
126+ size_t insns_sz;
127+ if (arc_mach_is_arcv2 (gdbarch))
128+ {
129+ insns_sz = sizeof (insns_be_hs);
130+ memcpy (arc_sigtramp_insns, insns_be_hs, insns_sz);
131+ }
132+ else
133+ {
134+ insns_sz = sizeof (insns_be_700);
135+ memcpy (arc_sigtramp_insns, insns_be_700, insns_sz);
136+ }
137+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
138+ {
139+ /* On little endian targets, ARC code section is in what is called
140+ "middle endian", where half-words are in the big-endian order,
141+ only bytes inside the halfwords are in the little endian order.
142+ As a result it is very easy to convert big endian instruction to
143+ little endian, since it is needed to swap bytes in the halfwords,
144+ so there is no need to have information on whether that is a
145+ 4-byte instruction or 2-byte. */
146+ gdb_assert ((insns_sz % 2) == 0);
147+ for (int i = 0; i < insns_sz; i += 2)
148+ std::swap (arc_sigtramp_insns[i], arc_sigtramp_insns[i+1]);
149+ }
150+
151+ gdb_byte buf[insns_sz];
152+
153+ /* Read the memory at the PC. Since we are stopped, any breakpoint must
154+ have been removed. */
155+ if (!safe_frame_unwind_memory (this_frame, pc, buf, insns_sz))
156+ {
157+ /* Failed to unwind frame. */
158+ return FALSE;
159+ }
160+
161+ /* Is that code the sigtramp instruction sequence? */
162+ if (memcmp (buf, arc_sigtramp_insns, insns_sz) == 0)
163+ return TRUE;
164+
165+ /* No - look one instruction earlier in the code... */
166+ if (!safe_frame_unwind_memory (this_frame, pc - 4, buf, insns_sz))
167+ {
168+ /* Failed to unwind frame. */
169+ return FALSE;
170+ }
171+
172+ return (memcmp (buf, arc_sigtramp_insns, insns_sz) == 0);
173+}
174+
175+/* Get sigcontext structure of sigtramp frame - it contains saved
176+ registers of interrupted frame.
177+
178+ Stack pointer points to the rt_sigframe structure, and sigcontext can
179+ be found as in:
180+
181+ struct rt_sigframe {
182+ struct siginfo info;
183+ struct ucontext uc;
184+ ...
185+ };
186+
187+ struct ucontext {
188+ unsigned long uc_flags;
189+ struct ucontext *uc_link;
190+ stack_t uc_stack;
191+ struct sigcontext uc_mcontext;
192+ sigset_t uc_sigmask;
193+ };
194+
195+ sizeof (struct siginfo) == 0x80
196+ offsetof (struct ucontext, uc_mcontext) == 0x14
197+
198+ GDB cannot include linux headers and use offsetof () because those are
199+ target headers and GDB might be built for a different run host. There
200+ doesn't seem to be an established mechanism to figure out those offsets
201+ via gdbserver, so the only way is to hardcode values in the GDB,
202+ meaning that GDB will be broken if values will change. That seems to
203+ be a very unlikely scenario and other arches (aarch64, alpha, amd64,
204+ etc) in GDB hardcode values. */
205+
206+static CORE_ADDR
207+arc_linux_sigcontext_addr (struct frame_info *this_frame)
208+{
209+ const int ucontext_offset = 0x80;
210+ const int sigcontext_offset = 0x14;
211+ return get_frame_sp (this_frame) + ucontext_offset + sigcontext_offset;
212+}
213+
214 /* Implement the "cannot_fetch_register" gdbarch method. */
215
216 static int
217@@ -504,6 +679,12 @@ arc_linux_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
218 if (arc_debug)
219 debug_printf ("arc-linux: GNU/Linux OS/ABI initialization.\n");
220
221+ /* Fill in target-dependent info in ARC-private structure. */
222+ tdep->is_sigtramp = arc_linux_is_sigtramp;
223+ tdep->sigcontext_addr = arc_linux_sigcontext_addr;
224+ tdep->sc_reg_offset = arc_linux_sc_reg_offsets;
225+ tdep->sc_num_regs = ARRAY_SIZE (arc_linux_sc_reg_offsets);
226+
227 /* If we are using Linux, we have in uClibc
228 (libc/sysdeps/linux/arc/bits/setjmp.h):
229
230--
2312.16.2
232
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
deleted file mode 100644
index a7256065cc..0000000000
--- a/meta/recipes-devtools/gdb/gdb/0014-arc-Take-into-account-the-REGNUM-in-supply-collect-g.patch
+++ /dev/null
@@ -1,104 +0,0 @@
1From 5eb97d5e92ad23ee81cebc1ebd5eafe0aa55fc17 Mon Sep 17 00:00:00 2001
2From: Shahab Vahedi <shahab@synopsys.com>
3Date: Tue, 10 Nov 2020 19:34:57 +0100
4Subject: [PATCH 3/4] arc: Take into account the REGNUM in supply/collect gdb
5 hooks
6
7All the arc_linux_supply_*() target operations and the
8arc_linux_collect_v2_regset() in arc-linux-tdep.c were
9supplying/collecting all the registers in regcache as if the
10REGNUM was set to -1.
11
12The more efficient behavior is to examine the REGNUM and act
13accordingly. That is what this patch does.
14
15gdb/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
21Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=46023bbe81355230b4e7b76d3084337823d02362]
22
23Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
24Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
25---
26 gdb/arc-linux-tdep.c | 41 ++++++++++++++++++++++++++++++++---------
27 1 file changed, 32 insertions(+), 9 deletions(-)
28
29diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c
30index 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--
1032.16.2
104
diff --git a/meta/recipes-devtools/gdb/gdb/0015-gdb-Add-native-support-for-ARC-in-GNU-Linux.patch b/meta/recipes-devtools/gdb/gdb/0015-gdb-Add-native-support-for-ARC-in-GNU-Linux.patch
deleted file mode 100644
index 31cf0b0be2..0000000000
--- a/meta/recipes-devtools/gdb/gdb/0015-gdb-Add-native-support-for-ARC-in-GNU-Linux.patch
+++ /dev/null
@@ -1,414 +0,0 @@
1From 32b366249fd42d74cbc4a91039431554ebadcfd0 Mon Sep 17 00:00:00 2001
2From: Anton Kolesov <anton.kolesov@synopsys.com>
3Date: Fri, 14 Feb 2014 11:56:23 +0400
4Subject: [PATCH 4/4] gdb: Add native support for ARC in GNU/Linux
5
6With this patch in place it is possible to build a GDB that
7can run on ARC (GNU/Linux) hosts for debugging ARC targets.
8
9The "arc-linux-nat.c" is a rather small one that mostly deals
10with registers and a few thread related hooks.
11
12v2 [1]:
13- Remove "void" from the input of "_initialize_arc_linux_nat ()"
14
15[1] Tom's remark after the first patch
16https://sourceware.org/pipermail/gdb-patches/2020-November/173223.html
17
18gdb/ChangeLog:
19
20 * Makefile.in (ALLDEPFILES): Add arc-linux-nat.c.
21 * configure.host (host to gdb names): Add arc*-*-linux*.
22 * configure.nat (gdb_host_cpu): Add arc.
23 * arc-linux-nat.c: New.
24
25Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=04c9f85efcd8df5fc482ce97c0104cc7dd5d19e6]
26
27Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
28Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
29Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
30---
31 gdb/Makefile.in | 1 +
32 gdb/arc-linux-nat.c | 320 ++++++++++++++++++++++++++++++++++++++++++++++++++++
33 gdb/configure.host | 3 +
34 gdb/configure.nat | 4 +
35 4 files changed, 328 insertions(+)
36 create mode 100644 gdb/arc-linux-nat.c
37
38diff --git a/gdb/Makefile.in b/gdb/Makefile.in
39index ec371fc7e52..c76136907ae 100644
40--- a/gdb/Makefile.in
41+++ b/gdb/Makefile.in
42@@ -2136,6 +2136,7 @@ ALLDEPFILES = \
43 amd64-obsd-tdep.c \
44 amd64-sol2-tdep.c \
45 amd64-tdep.c \
46+ arc-linux-nat.c \
47 arc-tdep.c \
48 arm.c \
49 arm-bsd-tdep.c \
50diff --git a/gdb/arc-linux-nat.c b/gdb/arc-linux-nat.c
51new file mode 100644
52index 00000000000..41301fd4fed
53--- /dev/null
54+++ b/gdb/arc-linux-nat.c
55@@ -0,0 +1,320 @@
56+/* Native-dependent code for GNU/Linux ARC.
57+
58+ Copyright 2020 Free Software Foundation, Inc.
59+
60+ This file is part of GDB.
61+
62+ This program is free software; you can redistribute it and/or modify
63+ it under the terms of the GNU General Public License as published by
64+ the Free Software Foundation; either version 3 of the License, or
65+ (at your option) any later version.
66+
67+ This program is distributed in the hope that it will be useful,
68+ but WITHOUT ANY WARRANTY; without even the implied warranty of
69+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70+ GNU General Public License for more details.
71+
72+ You should have received a copy of the GNU General Public License
73+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
74+
75+#include "defs.h"
76+#include "frame.h"
77+#include "inferior.h"
78+#include "gdbcore.h"
79+#include "regcache.h"
80+#include "gdbsupport/gdb_assert.h"
81+#include "target.h"
82+#include "linux-nat.h"
83+#include "nat/gdb_ptrace.h"
84+
85+#include <stdint.h>
86+#include <sys/types.h>
87+#include <sys/param.h>
88+#include <signal.h>
89+#include <sys/user.h>
90+#include <sys/ioctl.h>
91+#include "gdbsupport/gdb_wait.h"
92+#include <fcntl.h>
93+#include <sys/procfs.h>
94+#include <linux/elf.h>
95+
96+#include "gregset.h"
97+#include "arc-tdep.h"
98+#include "arc-linux-tdep.h"
99+#include "arch/arc.h"
100+
101+/* Defines ps_err_e, struct ps_prochandle. */
102+#include "gdb_proc_service.h"
103+
104+/* Linux starting with 4.12 supports NT_ARC_V2 note type, which adds R30,
105+ R58 and R59 registers, which are specific to ARC HS and aren't
106+ available in ARC 700. */
107+#if defined (NT_ARC_V2) && defined (__ARCHS__)
108+#define ARC_HAS_V2_REGSET
109+#endif
110+
111+class arc_linux_nat_target final : public linux_nat_target
112+{
113+public:
114+ /* Add ARC register access methods. */
115+ void fetch_registers (struct regcache *, int) override;
116+ void store_registers (struct regcache *, int) override;
117+
118+ const struct target_desc *read_description () override;
119+
120+ /* Handle threads */
121+ void low_prepare_to_resume (struct lwp_info *lp) override;
122+};
123+
124+static arc_linux_nat_target the_arc_linux_nat_target;
125+
126+/* Read general registers from target process/thread (via ptrace)
127+ into REGCACHE. */
128+
129+static void
130+fetch_gregs (struct regcache *regcache, int regnum)
131+{
132+ const int tid = get_ptrace_pid (regcache->ptid ());
133+ struct iovec iov;
134+ gdb_gregset_t regs;
135+
136+ iov.iov_base = &regs;
137+ iov.iov_len = sizeof (gdb_gregset_t);
138+
139+ if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, (void *) &iov) < 0)
140+ perror_with_name (_("Couldn't get general registers"));
141+ else
142+ arc_linux_supply_gregset (NULL, regcache, regnum, &regs, 0);
143+}
144+
145+#ifdef ARC_HAS_V2_REGSET
146+/* Read ARC v2 registers from target process/thread (via ptrace)
147+ into REGCACHE. */
148+
149+static void
150+fetch_v2_regs (struct regcache *regcache, int regnum)
151+{
152+ const int tid = get_ptrace_pid (regcache->ptid ());
153+ struct iovec iov;
154+ bfd_byte v2_buffer[ARC_LINUX_SIZEOF_V2_REGSET];
155+
156+ iov.iov_base = &v2_buffer;
157+ iov.iov_len = ARC_LINUX_SIZEOF_V2_REGSET;
158+
159+ if (ptrace (PTRACE_GETREGSET, tid, NT_ARC_V2, (void *) &iov) < 0)
160+ perror_with_name (_("Couldn't get ARC HS registers"));
161+ else
162+ arc_linux_supply_v2_regset (NULL, regcache, regnum, v2_buffer, 0);
163+}
164+#endif
165+
166+/* Store general registers from REGCACHE into the target process/thread. */
167+
168+static void
169+store_gregs (const struct regcache *regcache, int regnum)
170+{
171+ const int tid = get_ptrace_pid (regcache->ptid ());
172+ struct iovec iov;
173+ gdb_gregset_t regs;
174+
175+ iov.iov_base = &regs;
176+ iov.iov_len = sizeof (gdb_gregset_t);
177+
178+ if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, (void *) &iov) < 0)
179+ perror_with_name (_("Couldn't get general registers"));
180+ else
181+ {
182+ arc_linux_collect_gregset (NULL, regcache, regnum, regs, 0);
183+
184+ if (ptrace (PTRACE_SETREGSET, tid, NT_PRSTATUS, (void *) &iov) < 0)
185+ perror_with_name (_("Couldn't write general registers"));
186+ }
187+}
188+
189+#ifdef ARC_HAS_V2_REGSET
190+/* Store ARC v2 registers from REGCACHE into the target process/thread. */
191+
192+static void
193+store_v2_regs (const struct regcache *regcache, int regnum)
194+{
195+ const int tid = get_ptrace_pid (regcache->ptid ());
196+ struct iovec iov;
197+ bfd_byte v2_buffer[ARC_LINUX_SIZEOF_V2_REGSET];
198+
199+ iov.iov_base = &v2_buffer;
200+ iov.iov_len = ARC_LINUX_SIZEOF_V2_REGSET;
201+
202+ if (ptrace (PTRACE_GETREGSET, tid, NT_ARC_V2, (void *) &iov) < 0)
203+ perror_with_name (_("Couldn't get ARC HS registers"));
204+ else
205+ {
206+ arc_linux_collect_v2_regset (NULL, regcache, regnum, v2_buffer, 0);
207+
208+ if (ptrace (PTRACE_SETREGSET, tid, NT_ARC_V2, (void *) &iov) < 0)
209+ perror_with_name (_("Couldn't write ARC HS registers"));
210+ }
211+}
212+#endif
213+
214+/* Target operation: Read REGNUM register (all registers if REGNUM == -1)
215+ from target process into REGCACHE. */
216+
217+void
218+arc_linux_nat_target::fetch_registers (struct regcache *regcache, int regnum)
219+{
220+
221+ if (regnum == -1 || regnum <= ARC_LAST_REGNUM)
222+ fetch_gregs (regcache, regnum);
223+
224+#ifdef ARC_HAS_V2_REGSET
225+ if (regnum == -1
226+ || regnum == ARC_R30_REGNUM
227+ || regnum == ARC_R58_REGNUM
228+ || regnum == ARC_R59_REGNUM)
229+ fetch_v2_regs (regcache, regnum);
230+#endif
231+}
232+
233+/* Target operation: Store REGNUM register (all registers if REGNUM == -1)
234+ to the target process from REGCACHE. */
235+
236+void
237+arc_linux_nat_target::store_registers (struct regcache *regcache, int regnum)
238+{
239+ if (regnum == -1 || regnum <= ARC_LAST_REGNUM)
240+ store_gregs (regcache, regnum);
241+
242+#ifdef ARC_HAS_V2_REGSET
243+ if (regnum == -1
244+ || regnum == ARC_R30_REGNUM
245+ || regnum == ARC_R58_REGNUM
246+ || regnum == ARC_R59_REGNUM)
247+ store_v2_regs (regcache, regnum);
248+#endif
249+}
250+
251+/* Copy general purpose register(s) from REGCACHE into regset GREGS.
252+ This function is exported to proc-service.c */
253+
254+void
255+fill_gregset (const struct regcache *regcache,
256+ gdb_gregset_t *gregs, int regnum)
257+{
258+ arc_linux_collect_gregset (NULL, regcache, regnum, gregs, 0);
259+}
260+
261+/* Copy all the general purpose registers from regset GREGS into REGCACHE.
262+ This function is exported to proc-service.c. */
263+
264+void
265+supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregs)
266+{
267+ arc_linux_supply_gregset (NULL, regcache, -1, gregs, 0);
268+}
269+
270+/* ARC doesn't have separate FP registers. This function is exported
271+ to proc-service.c. */
272+
273+void
274+fill_fpregset (const struct regcache *regcache,
275+ gdb_fpregset_t *fpregsetp, int regnum)
276+{
277+ if (arc_debug)
278+ debug_printf ("arc-linux-nat: fill_fpregset called.");
279+ return;
280+}
281+
282+/* ARC doesn't have separate FP registers. This function is exported
283+ to proc-service.c. */
284+
285+void
286+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
287+{
288+ if (arc_debug)
289+ debug_printf ("arc-linux-nat: supply_fpregset called.");
290+ return;
291+}
292+
293+/* Implement the "read_description" method of linux_nat_target. */
294+
295+const struct target_desc *
296+arc_linux_nat_target::read_description ()
297+{
298+ /* This is a native target, hence description is hardcoded. */
299+#ifdef __ARCHS__
300+ arc_arch_features features (4, ARC_ISA_ARCV2);
301+#else
302+ arc_arch_features features (4, ARC_ISA_ARCV1);
303+#endif
304+ return arc_lookup_target_description (features);
305+}
306+
307+/* As described in arc_linux_collect_gregset(), we need to write resume-PC
308+ to ERET. However by default GDB for native targets doesn't write
309+ registers if they haven't been changed. This is a callback called by
310+ generic GDB, and in this callback we have to rewrite PC value so it
311+ would force rewrite of register on target. It seems that the only
312+ other arch that utilizes this hook is x86/x86-64 for HW breakpoint
313+ support. But then, AFAIK no other arch has this stop_pc/eret
314+ complexity.
315+
316+ No better way was found, other than this fake write of register value,
317+ to force GDB into writing register to target. Is there any? */
318+
319+void
320+arc_linux_nat_target::low_prepare_to_resume (struct lwp_info *lwp)
321+{
322+ /* When new processes and threads are created we do not have the address
323+ space for them and calling get_thread_regcache will cause an internal
324+ error in GDB. It looks like that checking for last_resume_kind is the
325+ sensible way to determine processes for which we cannot get regcache.
326+ Ultimately, a better way would be removing the need for
327+ low_prepare_to_resume in the first place. */
328+ if (lwp->last_resume_kind == resume_stop)
329+ return;
330+
331+ struct regcache *regcache = get_thread_regcache (this, lwp->ptid);
332+ struct gdbarch *gdbarch = regcache->arch ();
333+
334+ /* Read current PC value, then write it back. It is required to call
335+ invalidate(), otherwise GDB will note that new value is equal to old
336+ value and will skip write. */
337+ ULONGEST new_pc;
338+ regcache_cooked_read_unsigned (regcache, gdbarch_pc_regnum (gdbarch),
339+ &new_pc);
340+ regcache->invalidate (gdbarch_pc_regnum (gdbarch));
341+ regcache_cooked_write_unsigned (regcache, gdbarch_pc_regnum (gdbarch),
342+ new_pc);
343+}
344+
345+/* Fetch the thread-local storage pointer for libthread_db. Note that
346+ this function is not called from GDB, but is called from libthread_db.
347+ This is required to debug multithreaded applications with NPTL. */
348+
349+ps_err_e
350+ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
351+ void **base)
352+{
353+ if (arc_debug >= 2)
354+ debug_printf ("arc-linux-nat: ps_get_thread_area called");
355+
356+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
357+ return PS_ERR;
358+
359+ /* IDX is the bias from the thread pointer to the beginning of the
360+ thread descriptor. It has to be subtracted due to implementation
361+ quirks in libthread_db. */
362+ *base = (void *) ((char *) *base - idx);
363+
364+ return PS_OK;
365+}
366+
367+/* Suppress warning from -Wmissing-prototypes. */
368+void _initialize_arc_linux_nat ();
369+void
370+_initialize_arc_linux_nat ()
371+{
372+ /* Register the target. */
373+ linux_target = &the_arc_linux_nat_target;
374+ add_inf_child_target (&the_arc_linux_nat_target);
375+}
376diff --git a/gdb/configure.host b/gdb/configure.host
377index ce528237291..e94a19b0332 100644
378--- a/gdb/configure.host
379+++ b/gdb/configure.host
380@@ -60,6 +60,7 @@ case "${host_cpu}" in
381
382 aarch64*) gdb_host_cpu=aarch64 ;;
383 alpha*) gdb_host_cpu=alpha ;;
384+arc*) gdb_host_cpu=arc ;;
385 arm*) gdb_host_cpu=arm ;;
386 hppa*) gdb_host_cpu=pa ;;
387 i[34567]86*) gdb_host_cpu=i386 ;;
388@@ -91,6 +92,8 @@ alpha*-*-netbsd* | alpha*-*-knetbsd*-gnu)
389 gdb_host=nbsd ;;
390 alpha*-*-openbsd*) gdb_host=nbsd ;;
391
392+arc*-*-linux*) gdb_host=linux ;;
393+
394 arm*-*-freebsd*) gdb_host=fbsd ;;
395 arm*-*-linux*) gdb_host=linux ;;
396 arm*-*-netbsdelf* | arm*-*-knetbsd*-gnu)
397diff --git a/gdb/configure.nat b/gdb/configure.nat
398index bb70e303384..cd11bc86dca 100644
399--- a/gdb/configure.nat
400+++ b/gdb/configure.nat
401@@ -238,6 +238,10 @@ case ${gdb_host} in
402 nat/aarch64-linux.o \
403 nat/aarch64-sve-linux-ptrace.o"
404 ;;
405+ arc)
406+ # Host: ARC based machine running GNU/Linux
407+ NATDEPFILES="${NATDEPFILES} arc-linux-nat.o"
408+ ;;
409 arm)
410 # Host: ARM based machine running GNU/Linux
411 NATDEPFILES="${NATDEPFILES} arm-linux-nat.o \
412--
4132.16.2
414
diff --git a/meta/recipes-devtools/gdb/gdb_10.2.bb b/meta/recipes-devtools/gdb/gdb_11.1.bb
index e73e3a2c5c..e73e3a2c5c 100644
--- a/meta/recipes-devtools/gdb/gdb_10.2.bb
+++ b/meta/recipes-devtools/gdb/gdb_11.1.bb