summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/gdb/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'meta-microblaze/recipes-devtools/gdb/gdb')
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0001-Patch-MicroBlaze.patch (renamed from meta-microblaze/recipes-devtools/gdb/gdb/0001-Add-initial-port-of-linux-gdbserver.patch)12
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0002-Initial-port-of-core-reading-support.patch2
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0003-Fix-debug-message-when-register-is-unavailable.patch2
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0004-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch2
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0005-Fixing-the-issues-related-to-GDB-7.12.patch (renamed from meta-microblaze/recipes-devtools/gdb/gdb/0006-Fixing-the-issues-related-to-GDB-7.12.patch)27
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0005-Initial-support-for-native-gdb.patch492
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0006-Patch-MicroBlaze-MicroBlaze-native-gdb-port.patch831
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0007-Patch-microblaze-Adding-64-bit-MB-support.patch186
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0008-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch (renamed from meta-microblaze/recipes-devtools/gdb/gdb/0009-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch)4
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0008-gdb-Fix-microblaze-target-compilation-3.patch288
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0009-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch (renamed from meta-microblaze/recipes-devtools/gdb/gdb/0010-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch)20
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0010-Patch-MicroBlaze-Code-changes-for-gdbserver.patch401
12 files changed, 1295 insertions, 972 deletions
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0001-Add-initial-port-of-linux-gdbserver.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0001-Patch-MicroBlaze.patch
index bc1c1a93..b5a2726b 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0001-Add-initial-port-of-linux-gdbserver.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0001-Patch-MicroBlaze.patch
@@ -1,8 +1,8 @@
1From 699248a2fc4b9334f5042e1657116ac6b67b7321 Mon Sep 17 00:00:00 2001 1From b7b3c1eb19b770b2d700dd3c9fa23a7ae225a72b Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com> 2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 19:07:44 +0530 3Date: Thu, 16 Jun 2022 09:50:14 +0530
4Subject: [PATCH 01/10] Add initial port of linux gdbserver add 4Subject: [PATCH 01/10] [Patch,MicroBlaze] : Add initial port of linux
5 gdb_proc_service_h to gdbserver microblaze-linux 5 gdbserver add gdb_proc_service_h to gdbserver microblaze-linux
6 6
7gdbserver needs to initialise the microblaze registers 7gdbserver needs to initialise the microblaze registers
8 8
@@ -451,7 +451,7 @@ index 00000000000..bd8a4384424
451+32:slr 451+32:slr
452+32:shr 452+32:shr
453diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in 453diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in
454index 2bd3a578932..7bee1f1894e 100644 454index 2bd3a578932..46b5a0c7c60 100644
455--- a/gdbserver/Makefile.in 455--- a/gdbserver/Makefile.in
456+++ b/gdbserver/Makefile.in 456+++ b/gdbserver/Makefile.in
457@@ -184,7 +184,8 @@ SFILES = \ 457@@ -184,7 +184,8 @@ SFILES = \
@@ -468,7 +468,7 @@ index 2bd3a578932..7bee1f1894e 100644
468 $(srcdir)/../gdb/nat/linux-namespaces.c \ 468 $(srcdir)/../gdb/nat/linux-namespaces.c \
469 $(srcdir)/../gdb/nat/linux-osdata.c \ 469 $(srcdir)/../gdb/nat/linux-osdata.c \
470 $(srcdir)/../gdb/nat/linux-personality.c \ 470 $(srcdir)/../gdb/nat/linux-personality.c \
471+ $(srcdir)/../gdb/nat/microblaze-linux.c \ 471+ $(srcdir)/../gdb/nat/microblaze-linux.c \
472 $(srcdir)/../gdb/nat/mips-linux-watch.c \ 472 $(srcdir)/../gdb/nat/mips-linux-watch.c \
473 $(srcdir)/../gdb/nat/ppc-linux.c \ 473 $(srcdir)/../gdb/nat/ppc-linux.c \
474 $(srcdir)/../gdb/nat/riscv-linux-tdesc.c \ 474 $(srcdir)/../gdb/nat/riscv-linux-tdesc.c \
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0002-Initial-port-of-core-reading-support.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0002-Initial-port-of-core-reading-support.patch
index d49a7fe6..352ed92e 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0002-Initial-port-of-core-reading-support.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0002-Initial-port-of-core-reading-support.patch
@@ -1,4 +1,4 @@
1From eae6f2fc7324729056f4bd3bfa66c0c5887d7b94 Mon Sep 17 00:00:00 2001 1From da36639f95d23083088a27c27f631d304ae316f1 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com> 2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 24 Jan 2017 14:55:56 +0530 3Date: Tue, 24 Jan 2017 14:55:56 +0530
4Subject: [PATCH 02/10] Initial port of core reading support Added support for 4Subject: [PATCH 02/10] Initial port of core reading support Added support for
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0003-Fix-debug-message-when-register-is-unavailable.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0003-Fix-debug-message-when-register-is-unavailable.patch
index 68d90f27..255bb9b5 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0003-Fix-debug-message-when-register-is-unavailable.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0003-Fix-debug-message-when-register-is-unavailable.patch
@@ -1,4 +1,4 @@
1From 80c56ef8463c23f51759f5c64ce0165e259a4071 Mon Sep 17 00:00:00 2001 1From da93f5715ff333ac4807b73fe678dde21fb3bd6c Mon Sep 17 00:00:00 2001
2From: Nathan Rossi <nathan.rossi@petalogix.com> 2From: Nathan Rossi <nathan.rossi@petalogix.com>
3Date: Tue, 8 May 2012 18:11:17 +1000 3Date: Tue, 8 May 2012 18:11:17 +1000
4Subject: [PATCH 03/10] Fix debug message when register is unavailable 4Subject: [PATCH 03/10] Fix debug message when register is unavailable
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0004-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0004-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch
index e63a696d..f1555b8a 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0004-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0004-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch
@@ -1,4 +1,4 @@
1From 7d970a0c616063a5095ce3725efed0feb40ceb30 Mon Sep 17 00:00:00 2001 1From 82ee589db2c1191fb274f4a76e217df318f8d6b2 Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@xilinx.com> 2From: David Holsgrove <david.holsgrove@xilinx.com>
3Date: Mon, 16 Dec 2013 16:37:32 +1000 3Date: Mon, 16 Dec 2013 16:37:32 +1000
4Subject: [PATCH 04/10] microblaze: Add build_gdbserver=yes to top level 4Subject: [PATCH 04/10] microblaze: Add build_gdbserver=yes to top level
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0006-Fixing-the-issues-related-to-GDB-7.12.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0005-Fixing-the-issues-related-to-GDB-7.12.patch
index eb1efa71..48e203a9 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0006-Fixing-the-issues-related-to-GDB-7.12.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0005-Fixing-the-issues-related-to-GDB-7.12.patch
@@ -1,34 +1,19 @@
1From 41b0d54fa00ce765e9a2ce09136938b72b2b96d7 Mon Sep 17 00:00:00 2001 1From ca1158d19ab9879167ca9fbe2fdf8d19094cc53f Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com> 2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 17 Feb 2017 14:09:40 +0530 3Date: Fri, 17 Feb 2017 14:09:40 +0530
4Subject: [PATCH 06/10] Fixing the issues related to GDB-7.12 4Subject: [PATCH 05/10] Fixing the issues related to GDB-7.12
5 5
6added all the required function which are new in 7.12 and removed 6added all the required function which are new in 7.12 and removed
7few deprecated functions from 7.6 7few deprecated functions from 7.6
8
9Conflicts:
10 gdb/config/microblaze/linux.mh
8--- 11---
9 gdb/config/microblaze/linux.mh | 4 +-
10 gdb/gdbserver/linux-microblaze-low.c | 97 ++++++++++++++++++++++++---- 12 gdb/gdbserver/linux-microblaze-low.c | 97 ++++++++++++++++++++++++----
11 gdb/microblaze-tdep.h | 1 + 13 gdb/microblaze-tdep.h | 1 +
12 gdbserver/configure.srv | 3 +- 14 gdbserver/configure.srv | 3 +-
13 4 files changed, 89 insertions(+), 16 deletions(-) 15 3 files changed, 86 insertions(+), 15 deletions(-)
14 16
15diff --git a/gdb/config/microblaze/linux.mh b/gdb/config/microblaze/linux.mh
16index a4eaf540e1d..74a53b854a4 100644
17--- a/gdb/config/microblaze/linux.mh
18+++ b/gdb/config/microblaze/linux.mh
19@@ -1,9 +1,11 @@
20 # Host: Microblaze, running Linux
21
22+#linux-nat.o linux-waitpid.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
23 NAT_FILE= config/nm-linux.h
24 NATDEPFILES= inf-ptrace.o fork-child.o \
25 microblaze-linux-nat.o proc-service.o linux-thread-db.o \
26- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
27+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
28+ linux-waitpid.o linux-personality.o linux-namespaces.o
29 NAT_CDEPS = $(srcdir)/proc-service.list
30
31 LOADLIBES = -ldl $(RDYNAMIC)
32diff --git a/gdb/gdbserver/linux-microblaze-low.c b/gdb/gdbserver/linux-microblaze-low.c 17diff --git a/gdb/gdbserver/linux-microblaze-low.c b/gdb/gdbserver/linux-microblaze-low.c
33index cba5d6fc585..a2733f3c21c 100644 18index cba5d6fc585..a2733f3c21c 100644
34--- a/gdb/gdbserver/linux-microblaze-low.c 19--- a/gdb/gdbserver/linux-microblaze-low.c
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0005-Initial-support-for-native-gdb.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0005-Initial-support-for-native-gdb.patch
deleted file mode 100644
index 3482bcd8..00000000
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0005-Initial-support-for-native-gdb.patch
+++ /dev/null
@@ -1,492 +0,0 @@
1From bac086097dfa813fcc0b978dc32eb9ae469bf4a8 Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@petalogix.com>
3Date: Fri, 20 Jul 2012 15:18:35 +1000
4Subject: [PATCH 05/10] Initial support for native gdb
5
6microblaze: Follow PPC method of getting setting registers
7using PTRACE PEEK/POKE
8
9Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
10---
11 gdb/Makefile.in | 2 +
12 gdb/config/microblaze/linux.mh | 9 +
13 gdb/microblaze-linux-nat.c | 431 +++++++++++++++++++++++++++++++++
14 3 files changed, 442 insertions(+)
15 create mode 100644 gdb/config/microblaze/linux.mh
16 create mode 100644 gdb/microblaze-linux-nat.c
17
18diff --git a/gdb/Makefile.in b/gdb/Makefile.in
19index ec371fc7e52..2e8d4cfe82e 100644
20--- a/gdb/Makefile.in
21+++ b/gdb/Makefile.in
22@@ -1336,6 +1336,7 @@ HFILES_NO_SRCDIR = \
23 memory-map.h \
24 memrange.h \
25 microblaze-tdep.h \
26+ microblaze-linux-tdep.h \
27 mips-linux-tdep.h \
28 mips-nbsd-tdep.h \
29 mips-tdep.h \
30@@ -2216,6 +2217,7 @@ ALLDEPFILES = \
31 m68k-tdep.c \
32 microblaze-linux-tdep.c \
33 microblaze-tdep.c \
34+ microblaze-linux-nat.c \
35 mingw-hdep.c \
36 mips-fbsd-nat.c \
37 mips-fbsd-tdep.c \
38diff --git a/gdb/config/microblaze/linux.mh b/gdb/config/microblaze/linux.mh
39new file mode 100644
40index 00000000000..a4eaf540e1d
41--- /dev/null
42+++ b/gdb/config/microblaze/linux.mh
43@@ -0,0 +1,9 @@
44+# Host: Microblaze, running Linux
45+
46+NAT_FILE= config/nm-linux.h
47+NATDEPFILES= inf-ptrace.o fork-child.o \
48+ microblaze-linux-nat.o proc-service.o linux-thread-db.o \
49+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
50+NAT_CDEPS = $(srcdir)/proc-service.list
51+
52+LOADLIBES = -ldl $(RDYNAMIC)
53diff --git a/gdb/microblaze-linux-nat.c b/gdb/microblaze-linux-nat.c
54new file mode 100644
55index 00000000000..e9b8c9c5221
56--- /dev/null
57+++ b/gdb/microblaze-linux-nat.c
58@@ -0,0 +1,431 @@
59+/* Microblaze GNU/Linux native support.
60+
61+ Copyright (C) 1988-1989, 1991-1992, 1994, 1996, 2000-2012 Free
62+ Software Foundation, Inc.
63+
64+ This file is part of GDB.
65+
66+ This program is free software; you can redistribute it and/or modify
67+ it under the terms of the GNU General Public License as published by
68+ the Free Software Foundation; either version 3 of the License, or
69+ (at your option) any later version.
70+
71+ This program is distributed in the hope that it will be useful,
72+ but WITHOUT ANY WARRANTY; without even the implied warranty of
73+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74+ GNU General Public License for more details.
75+
76+ You should have received a copy of the GNU General Public License
77+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
78+
79+#include "defs.h"
80+#include "arch-utils.h"
81+#include "dis-asm.h"
82+#include "frame.h"
83+#include "trad-frame.h"
84+#include "symtab.h"
85+#include "value.h"
86+#include "gdbcmd.h"
87+#include "breakpoint.h"
88+#include "inferior.h"
89+#include "regcache.h"
90+#include "target.h"
91+#include "frame.h"
92+#include "frame-base.h"
93+#include "frame-unwind.h"
94+#include "dwarf2-frame.h"
95+#include "osabi.h"
96+
97+#include "gdb_assert.h"
98+#include "gdb_string.h"
99+#include "target-descriptions.h"
100+#include "opcodes/microblaze-opcm.h"
101+#include "opcodes/microblaze-dis.h"
102+
103+#include "linux-nat.h"
104+#include "target-descriptions.h"
105+
106+#include <sys/user.h>
107+#include <sys/utsname.h>
108+#include <sys/procfs.h>
109+#include <sys/ptrace.h>
110+
111+/* Prototypes for supply_gregset etc. */
112+#include "gregset.h"
113+
114+#include "microblaze-tdep.h"
115+
116+#include <elf/common.h>
117+#include "auxv.h"
118+
119+/* Defines ps_err_e, struct ps_prochandle. */
120+#include "gdb_proc_service.h"
121+
122+/* On GNU/Linux, threads are implemented as pseudo-processes, in which
123+ case we may be tracing more than one process at a time. In that
124+ case, inferior_ptid will contain the main process ID and the
125+ individual thread (process) ID. get_thread_id () is used to get
126+ the thread id if it's available, and the process id otherwise. */
127+
128+int
129+get_thread_id (ptid_t ptid)
130+{
131+ int tid = TIDGET (ptid);
132+ if (0 == tid)
133+ tid = PIDGET (ptid);
134+ return tid;
135+}
136+
137+#define GET_THREAD_ID(PTID) get_thread_id (PTID)
138+
139+/* Non-zero if our kernel may support the PTRACE_GETREGS and
140+ PTRACE_SETREGS requests, for reading and writing the
141+ general-purpose registers. Zero if we've tried one of
142+ them and gotten an error. */
143+int have_ptrace_getsetregs = 1;
144+
145+static int
146+microblaze_register_u_addr (struct gdbarch *gdbarch, int regno)
147+{
148+ int u_addr = -1;
149+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
150+ /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
151+ interface, and not the wordsize of the program's ABI. */
152+ int wordsize = sizeof (long);
153+
154+ /* General purpose registers occupy 1 slot each in the buffer. */
155+ if (regno >= MICROBLAZE_R0_REGNUM
156+ && regno <= MICROBLAZE_FSR_REGNUM)
157+ u_addr = (regno * wordsize);
158+
159+ return u_addr;
160+}
161+
162+
163+static void
164+fetch_register (struct regcache *regcache, int tid, int regno)
165+{
166+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
167+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
168+ /* This isn't really an address. But ptrace thinks of it as one. */
169+ CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
170+ int bytes_transferred;
171+ unsigned int offset; /* Offset of registers within the u area. */
172+ char buf[MAX_REGISTER_SIZE];
173+
174+ if (regaddr == -1)
175+ {
176+ memset (buf, '\0', register_size (gdbarch, regno)); /* Supply zeroes */
177+ regcache_raw_supply (regcache, regno, buf);
178+ return;
179+ }
180+
181+ /* Read the raw register using sizeof(long) sized chunks. On a
182+ 32-bit platform, 64-bit floating-point registers will require two
183+ transfers. */
184+ for (bytes_transferred = 0;
185+ bytes_transferred < register_size (gdbarch, regno);
186+ bytes_transferred += sizeof (long))
187+ {
188+ long l;
189+
190+ errno = 0;
191+ l = ptrace (PTRACE_PEEKUSER, tid, (PTRACE_TYPE_ARG3) regaddr, 0);
192+ regaddr += sizeof (long);
193+ if (errno != 0)
194+ {
195+ char message[128];
196+ sprintf (message, "reading register %s (#%d)",
197+ gdbarch_register_name (gdbarch, regno), regno);
198+ perror_with_name (message);
199+ }
200+ memcpy (&buf[bytes_transferred], &l, sizeof (l));
201+ }
202+
203+ /* Now supply the register. Keep in mind that the regcache's idea
204+ of the register's size may not be a multiple of sizeof
205+ (long). */
206+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
207+ {
208+ /* Little-endian values are always found at the left end of the
209+ bytes transferred. */
210+ regcache_raw_supply (regcache, regno, buf);
211+ }
212+ else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
213+ {
214+ /* Big-endian values are found at the right end of the bytes
215+ transferred. */
216+ size_t padding = (bytes_transferred - register_size (gdbarch, regno));
217+ regcache_raw_supply (regcache, regno, buf + padding);
218+ }
219+ else
220+ internal_error (__FILE__, __LINE__,
221+ _("fetch_register: unexpected byte order: %d"),
222+ gdbarch_byte_order (gdbarch));
223+}
224+
225+/* This function actually issues the request to ptrace, telling
226+ it to get all general-purpose registers and put them into the
227+ specified regset.
228+
229+ If the ptrace request does not exist, this function returns 0
230+ and properly sets the have_ptrace_* flag. If the request fails,
231+ this function calls perror_with_name. Otherwise, if the request
232+ succeeds, then the regcache gets filled and 1 is returned. */
233+static int
234+fetch_all_gp_regs (struct regcache *regcache, int tid)
235+{
236+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
237+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
238+ gdb_gregset_t gregset;
239+
240+ if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0)
241+ {
242+ if (errno == EIO)
243+ {
244+ have_ptrace_getsetregs = 0;
245+ return 0;
246+ }
247+ perror_with_name (_("Couldn't get general-purpose registers."));
248+ }
249+
250+ supply_gregset (regcache, (const gdb_gregset_t *) &gregset);
251+
252+ return 1;
253+}
254+
255+
256+/* This is a wrapper for the fetch_all_gp_regs function. It is
257+ responsible for verifying if this target has the ptrace request
258+ that can be used to fetch all general-purpose registers at one
259+ shot. If it doesn't, then we should fetch them using the
260+ old-fashioned way, which is to iterate over the registers and
261+ request them one by one. */
262+static void
263+fetch_gp_regs (struct regcache *regcache, int tid)
264+{
265+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
266+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
267+ int i;
268+
269+ if (have_ptrace_getsetregs)
270+ if (fetch_all_gp_regs (regcache, tid))
271+ return;
272+
273+ /* If we've hit this point, it doesn't really matter which
274+ architecture we are using. We just need to read the
275+ registers in the "old-fashioned way". */
276+ for (i = MICROBLAZE_R0_REGNUM; i <= MICROBLAZE_FSR_REGNUM; i++)
277+ fetch_register (regcache, tid, i);
278+}
279+
280+
281+static void
282+store_register (const struct regcache *regcache, int tid, int regno)
283+{
284+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
285+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
286+ /* This isn't really an address. But ptrace thinks of it as one. */
287+ CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
288+ int i;
289+ size_t bytes_to_transfer;
290+ char buf[MAX_REGISTER_SIZE];
291+
292+ if (regaddr == -1)
293+ return;
294+
295+ /* First collect the register. Keep in mind that the regcache's
296+ idea of the register's size may not be a multiple of sizeof
297+ (long). */
298+ memset (buf, 0, sizeof buf);
299+ bytes_to_transfer = align_up (register_size (gdbarch, regno), sizeof (long));
300+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
301+ {
302+ /* Little-endian values always sit at the left end of the buffer. */
303+ regcache_raw_collect (regcache, regno, buf);
304+ }
305+ else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
306+ {
307+ /* Big-endian values sit at the right end of the buffer. */
308+ size_t padding = (bytes_to_transfer - register_size (gdbarch, regno));
309+ regcache_raw_collect (regcache, regno, buf + padding);
310+ }
311+
312+ for (i = 0; i < bytes_to_transfer; i += sizeof (long))
313+ {
314+ long l;
315+
316+ memcpy (&l, &buf[i], sizeof (l));
317+ errno = 0;
318+ ptrace (PTRACE_POKEUSER, tid, (PTRACE_TYPE_ARG3) regaddr, l);
319+ regaddr += sizeof (long);
320+
321+ if (errno != 0)
322+ {
323+ char message[128];
324+ sprintf (message, "writing register %s (#%d)",
325+ gdbarch_register_name (gdbarch, regno), regno);
326+ perror_with_name (message);
327+ }
328+ }
329+}
330+
331+/* This function actually issues the request to ptrace, telling
332+ it to store all general-purpose registers present in the specified
333+ regset.
334+
335+ If the ptrace request does not exist, this function returns 0
336+ and properly sets the have_ptrace_* flag. If the request fails,
337+ this function calls perror_with_name. Otherwise, if the request
338+ succeeds, then the regcache is stored and 1 is returned. */
339+static int
340+store_all_gp_regs (const struct regcache *regcache, int tid, int regno)
341+{
342+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
343+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
344+ gdb_gregset_t gregset;
345+
346+ if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0)
347+ {
348+ if (errno == EIO)
349+ {
350+ have_ptrace_getsetregs = 0;
351+ return 0;
352+ }
353+ perror_with_name (_("Couldn't get general-purpose registers."));
354+ }
355+
356+ fill_gregset (regcache, &gregset, regno);
357+
358+ if (ptrace (PTRACE_SETREGS, tid, 0, (void *) &gregset) < 0)
359+ {
360+ if (errno == EIO)
361+ {
362+ have_ptrace_getsetregs = 0;
363+ return 0;
364+ }
365+ perror_with_name (_("Couldn't set general-purpose registers."));
366+ }
367+
368+ return 1;
369+}
370+
371+/* This is a wrapper for the store_all_gp_regs function. It is
372+ responsible for verifying if this target has the ptrace request
373+ that can be used to store all general-purpose registers at one
374+ shot. If it doesn't, then we should store them using the
375+ old-fashioned way, which is to iterate over the registers and
376+ store them one by one. */
377+static void
378+store_gp_regs (const struct regcache *regcache, int tid, int regno)
379+{
380+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
381+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
382+ int i;
383+
384+ if (have_ptrace_getsetregs)
385+ if (store_all_gp_regs (regcache, tid, regno))
386+ return;
387+
388+ /* If we hit this point, it doesn't really matter which
389+ architecture we are using. We just need to store the
390+ registers in the "old-fashioned way". */
391+ for (i = MICROBLAZE_R0_REGNUM; i <= MICROBLAZE_FSR_REGNUM; i++)
392+ store_register (regcache, tid, i);
393+}
394+
395+
396+/* Fetch registers from the child process. Fetch all registers if
397+ regno == -1, otherwise fetch all general registers or all floating
398+ point registers depending upon the value of regno. */
399+
400+static void
401+microblaze_linux_fetch_inferior_registers (struct target_ops *ops,
402+ struct regcache *regcache, int regno)
403+{
404+ /* Get the thread id for the ptrace call. */
405+ int tid = GET_THREAD_ID (inferior_ptid);
406+
407+ if (regno == -1)
408+ fetch_gp_regs (regcache, tid);
409+ else
410+ fetch_register (regcache, tid, regno);
411+}
412+
413+/* Store registers back into the inferior. Store all registers if
414+ regno == -1, otherwise store all general registers or all floating
415+ point registers depending upon the value of regno. */
416+
417+static void
418+microblaze_linux_store_inferior_registers (struct target_ops *ops,
419+ struct regcache *regcache, int regno)
420+{
421+ /* Get the thread id for the ptrace call. */
422+ int tid = GET_THREAD_ID (inferior_ptid);
423+
424+ if (regno >= 0)
425+ store_register (regcache, tid, regno);
426+ else
427+ store_gp_regs (regcache, tid, -1);
428+}
429+
430+/* Wrapper functions for the standard regset handling, used by
431+ thread debugging. */
432+
433+void
434+fill_gregset (const struct regcache *regcache,
435+ gdb_gregset_t *gregsetp, int regno)
436+{
437+ microblaze_collect_gregset (NULL, regcache, regno, gregsetp);
438+}
439+
440+void
441+supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
442+{
443+ microblaze_supply_gregset (NULL, regcache, -1, gregsetp);
444+}
445+
446+void
447+fill_fpregset (const struct regcache *regcache,
448+ gdb_fpregset_t *fpregsetp, int regno)
449+{
450+ /* FIXME. */
451+}
452+
453+void
454+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
455+{
456+ /* FIXME. */
457+}
458+
459+static const struct target_desc *
460+microblaze_linux_read_description (struct target_ops *ops)
461+{
462+ CORE_ADDR microblaze_hwcap = 0;
463+
464+ if (target_auxv_search (ops, AT_HWCAP, &microblaze_hwcap) != 1)
465+ return NULL;
466+
467+ return NULL;
468+}
469+
470+
471+void _initialize_microblaze_linux_nat (void);
472+
473+void
474+_initialize_microblaze_linux_nat (void)
475+{
476+ struct target_ops *t;
477+
478+ /* Fill in the generic GNU/Linux methods. */
479+ t = linux_target ();
480+
481+ /* Add our register access methods. */
482+ t->to_fetch_registers = microblaze_linux_fetch_inferior_registers;
483+ t->to_store_registers = microblaze_linux_store_inferior_registers;
484+
485+ t->to_read_description = microblaze_linux_read_description;
486+
487+ /* Register the target. */
488+ linux_nat_add_target (t);
489+}
490--
4912.17.1
492
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0006-Patch-MicroBlaze-MicroBlaze-native-gdb-port.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0006-Patch-MicroBlaze-MicroBlaze-native-gdb-port.patch
new file mode 100644
index 00000000..9498e8f7
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0006-Patch-MicroBlaze-MicroBlaze-native-gdb-port.patch
@@ -0,0 +1,831 @@
1From b37df6ced77898e8cb7e1c343af005d5bfe1272f Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 15 Jun 2022 10:29:09 +0530
4Subject: [PATCH 06/10] [Patch,MicroBlaze] : MicroBlaze native gdb port.
5
6---
7 gdb/Makefile.in | 2 +
8 gdb/configure.nat | 4 +
9 gdb/features/microblaze-linux.c | 79 +++++++
10 gdb/microblaze-linux-nat.c | 366 ++++++++++++++++++++++++++++++++
11 gdb/microblaze-linux-tdep.c | 2 +
12 gdb/microblaze-linux-tdep.h | 24 +++
13 gdb/microblaze-tdep.c | 151 ++++++++++++-
14 gdb/microblaze-tdep.h | 15 +-
15 8 files changed, 629 insertions(+), 14 deletions(-)
16 create mode 100755 gdb/features/microblaze-linux.c
17 create mode 100755 gdb/microblaze-linux-nat.c
18 create mode 100644 gdb/microblaze-linux-tdep.h
19
20diff --git a/gdb/Makefile.in b/gdb/Makefile.in
21index ec371fc7e52..0449b8e4c2b 100644
22--- a/gdb/Makefile.in
23+++ b/gdb/Makefile.in
24@@ -1336,6 +1336,7 @@ HFILES_NO_SRCDIR = \
25 memory-map.h \
26 memrange.h \
27 microblaze-tdep.h \
28+ microblaze-linux-tdep.h \
29 mips-linux-tdep.h \
30 mips-nbsd-tdep.h \
31 mips-tdep.h \
32@@ -2214,6 +2215,7 @@ ALLDEPFILES = \
33 m68k-linux-nat.c \
34 m68k-linux-tdep.c \
35 m68k-tdep.c \
36+ microblaze-linux-nat.c \
37 microblaze-linux-tdep.c \
38 microblaze-tdep.c \
39 mingw-hdep.c \
40diff --git a/gdb/configure.nat b/gdb/configure.nat
41index bb70e303384..53f19a3d263 100644
42--- a/gdb/configure.nat
43+++ b/gdb/configure.nat
44@@ -261,6 +261,10 @@ case ${gdb_host} in
45 # Host: Motorola m68k running GNU/Linux.
46 NATDEPFILES="${NATDEPFILES} m68k-linux-nat.o"
47 ;;
48+ microblaze)
49+ # Host: Microblaze running GNU/Linux.
50+ NATDEPFILES="${NATDEPFILES} microblaze-linux-nat.o"
51+ ;;
52 mips)
53 # Host: Linux/MIPS
54 NATDEPFILES="${NATDEPFILES} linux-nat-trad.o \
55diff --git a/gdb/features/microblaze-linux.c b/gdb/features/microblaze-linux.c
56new file mode 100755
57index 00000000000..29f681bf2ac
58--- /dev/null
59+++ b/gdb/features/microblaze-linux.c
60@@ -0,0 +1,79 @@
61+/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
62+ Original: microblaze.xml */
63+
64+#include "defs.h"
65+#include "osabi.h"
66+#include "target-descriptions.h"
67+
68+struct target_desc *tdesc_microblaze_linux;
69+static void
70+initialize_tdesc_microblaze_linux (void)
71+{
72+ struct target_desc *result = allocate_target_description ();
73+ struct tdesc_feature *feature;
74+ set_tdesc_architecture (result, bfd_scan_arch ("microblaze"));
75+ set_tdesc_osabi (result, osabi_from_tdesc_string ("GNU/Linux"));
76+
77+ feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.core");
78+ tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int");
79+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int");
80+ tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int");
81+ tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "int");
82+ tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "int");
83+ tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "int");
84+ tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "int");
85+ tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "int");
86+ tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "int");
87+ tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "int");
88+ tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "int");
89+ tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "int");
90+ tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "int");
91+ tdesc_create_reg (feature, "r13", 13, 1, NULL, 32, "int");
92+ tdesc_create_reg (feature, "r14", 14, 1, NULL, 32, "int");
93+ tdesc_create_reg (feature, "r15", 15, 1, NULL, 32, "int");
94+ tdesc_create_reg (feature, "r16", 16, 1, NULL, 32, "int");
95+ tdesc_create_reg (feature, "r17", 17, 1, NULL, 32, "int");
96+ tdesc_create_reg (feature, "r18", 18, 1, NULL, 32, "int");
97+ tdesc_create_reg (feature, "r19", 19, 1, NULL, 32, "int");
98+ tdesc_create_reg (feature, "r20", 20, 1, NULL, 32, "int");
99+ tdesc_create_reg (feature, "r21", 21, 1, NULL, 32, "int");
100+ tdesc_create_reg (feature, "r22", 22, 1, NULL, 32, "int");
101+ tdesc_create_reg (feature, "r23", 23, 1, NULL, 32, "int");
102+ tdesc_create_reg (feature, "r24", 24, 1, NULL, 32, "int");
103+ tdesc_create_reg (feature, "r25", 25, 1, NULL, 32, "int");
104+ tdesc_create_reg (feature, "r26", 26, 1, NULL, 32, "int");
105+ tdesc_create_reg (feature, "r27", 27, 1, NULL, 32, "int");
106+ tdesc_create_reg (feature, "r28", 28, 1, NULL, 32, "int");
107+ tdesc_create_reg (feature, "r29", 29, 1, NULL, 32, "int");
108+ tdesc_create_reg (feature, "r30", 30, 1, NULL, 32, "int");
109+ tdesc_create_reg (feature, "r31", 31, 1, NULL, 32, "int");
110+ tdesc_create_reg (feature, "rpc", 32, 1, NULL, 32, "int");
111+ tdesc_create_reg (feature, "rmsr", 33, 1, NULL, 32, "int");
112+ tdesc_create_reg (feature, "rear", 34, 1, NULL, 32, "int");
113+ tdesc_create_reg (feature, "resr", 35, 1, NULL, 32, "int");
114+ tdesc_create_reg (feature, "rfsr", 36, 1, NULL, 32, "int");
115+ tdesc_create_reg (feature, "rbtr", 37, 1, NULL, 32, "int");
116+ tdesc_create_reg (feature, "rpvr0", 38, 1, NULL, 32, "int");
117+ tdesc_create_reg (feature, "rpvr1", 39, 1, NULL, 32, "int");
118+ tdesc_create_reg (feature, "rpvr2", 40, 1, NULL, 32, "int");
119+ tdesc_create_reg (feature, "rpvr3", 41, 1, NULL, 32, "int");
120+ tdesc_create_reg (feature, "rpvr4", 42, 1, NULL, 32, "int");
121+ tdesc_create_reg (feature, "rpvr5", 43, 1, NULL, 32, "int");
122+ tdesc_create_reg (feature, "rpvr6", 44, 1, NULL, 32, "int");
123+ tdesc_create_reg (feature, "rpvr7", 45, 1, NULL, 32, "int");
124+ tdesc_create_reg (feature, "rpvr8", 46, 1, NULL, 32, "int");
125+ tdesc_create_reg (feature, "rpvr9", 47, 1, NULL, 32, "int");
126+ tdesc_create_reg (feature, "rpvr10", 48, 1, NULL, 32, "int");
127+ tdesc_create_reg (feature, "rpvr11", 49, 1, NULL, 32, "int");
128+ tdesc_create_reg (feature, "redr", 50, 1, NULL, 32, "int");
129+ tdesc_create_reg (feature, "rpid", 51, 1, NULL, 32, "int");
130+ tdesc_create_reg (feature, "rzpr", 52, 1, NULL, 32, "int");
131+ tdesc_create_reg (feature, "rtlbx", 53, 1, NULL, 32, "int");
132+ tdesc_create_reg (feature, "rtlbsx", 54, 1, NULL, 32, "int");
133+ tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
134+ tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
135+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
136+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
137+
138+ tdesc_microblaze_linux = result;
139+}
140diff --git a/gdb/microblaze-linux-nat.c b/gdb/microblaze-linux-nat.c
141new file mode 100755
142index 00000000000..6b9daa23120
143--- /dev/null
144+++ b/gdb/microblaze-linux-nat.c
145@@ -0,0 +1,366 @@
146+/* Native-dependent code for GNU/Linux MicroBlaze.
147+ Copyright (C) 2021 Free Software Foundation, Inc.
148+
149+ This file is part of GDB.
150+
151+ This program is free software; you can redistribute it and/or modify
152+ it under the terms of the GNU General Public License as published by
153+ the Free Software Foundation; either version 3 of the License, or
154+ (at your option) any later version.
155+
156+ This program is distributed in the hope that it will be useful,
157+ but WITHOUT ANY WARRANTY; without even the implied warranty of
158+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
159+ GNU General Public License for more details.
160+
161+ You should have received a copy of the GNU General Public License
162+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
163+
164+#include "defs.h"
165+#include "arch-utils.h"
166+#include "dis-asm.h"
167+#include "frame.h"
168+#include "trad-frame.h"
169+#include "symtab.h"
170+#include "value.h"
171+#include "gdbcmd.h"
172+#include "breakpoint.h"
173+#include "inferior.h"
174+#include "gdbthread.h"
175+#include "gdbcore.h"
176+#include "regcache.h"
177+#include "regset.h"
178+#include "target.h"
179+#include "frame.h"
180+#include "frame-base.h"
181+#include "frame-unwind.h"
182+#include "osabi.h"
183+#include "gdbsupport/gdb_assert.h"
184+#include <string.h>
185+#include "target-descriptions.h"
186+#include "opcodes/microblaze-opcm.h"
187+#include "opcodes/microblaze-dis.h"
188+#include "gregset.h"
189+
190+#include "linux-nat.h"
191+#include "linux-tdep.h"
192+#include "target-descriptions.h"
193+
194+#include <sys/user.h>
195+#include <sys/ioctl.h>
196+#include <sys/uio.h>
197+#include "gdbsupport/gdb_wait.h"
198+#include <fcntl.h>
199+#include <sys/procfs.h>
200+#include "nat/gdb_ptrace.h"
201+#include "nat/linux-ptrace.h"
202+#include "inf-ptrace.h"
203+#include <algorithm>
204+#include <unordered_map>
205+#include <list>
206+#include <sys/ptrace.h>
207+
208+/* Prototypes for supply_gregset etc. */
209+#include "gregset.h"
210+
211+#include "microblaze-tdep.h"
212+#include "microblaze-linux-tdep.h"
213+#include "inferior.h"
214+
215+#include "elf/common.h"
216+
217+#include "auxv.h"
218+#include "linux-tdep.h"
219+
220+#include <sys/ptrace.h>
221+
222+
223+//int have_ptrace_getsetregs=1;
224+
225+/* MicroBlaze Linux native additions to the default linux support. */
226+
227+class microblaze_linux_nat_target final : public linux_nat_target
228+{
229+public:
230+ /* Add our register access methods. */
231+ void fetch_registers (struct regcache *regcache, int regnum) override;
232+ void store_registers (struct regcache *regcache, int regnum) override;
233+
234+ /* Read suitable target description. */
235+ const struct target_desc *read_description () override;
236+};
237+
238+static microblaze_linux_nat_target the_microblaze_linux_nat_target;
239+
240+static int
241+microblaze_register_u_addr (struct gdbarch *gdbarch, int regno)
242+{
243+ int u_addr = -1;
244+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
245+ /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
246+ * interface, and not the wordsize of the program's ABI. */
247+ int wordsize = sizeof (long);
248+
249+ /* General purpose registers occupy 1 slot each in the buffer. */
250+ if (regno >= MICROBLAZE_R0_REGNUM
251+ && regno <= MICROBLAZE_FSR_REGNUM)
252+ u_addr = ((regno - MICROBLAZE_R0_REGNUM)* wordsize);
253+
254+ return u_addr;
255+}
256+
257+/* Copy general purpose register REGNUM (or all gp regs if REGNUM == -1)
258+ from regset GREGS into REGCACHE. */
259+
260+static void
261+supply_gregset_regnum (struct regcache *regcache, const prgregset_t *gregs,
262+ int regnum)
263+{
264+ int i;
265+ const elf_greg_t *regp = *gregs;
266+ /* Access all registers */
267+ if (regnum == -1)
268+ {
269+ /* We fill the general purpose registers. */
270+ for (i = MICROBLAZE_R0_REGNUM + 1; i < MICROBLAZE_FSR_REGNUM; i++)
271+ regcache->raw_supply (i, regp + i);
272+
273+ /* Supply MICROBLAZE_PC_REGNUM from index 32. */
274+ regcache->raw_supply (MICROBLAZE_PC_REGNUM, regp + 32);
275+
276+ /* Fill the inaccessible zero register with zero. */
277+ regcache->raw_supply_zeroed (0);
278+ }
279+ else if (regnum == MICROBLAZE_R0_REGNUM)
280+ regcache->raw_supply_zeroed (0);
281+ else if (regnum == MICROBLAZE_PC_REGNUM)
282+ regcache->raw_supply (MICROBLAZE_PC_REGNUM, regp + 32);
283+ else if (regnum > MICROBLAZE_R0_REGNUM && regnum < MICROBLAZE_FSR_REGNUM)
284+ regcache->raw_supply (regnum, regp + regnum);
285+}
286+
287+/* Copy all general purpose registers from regset GREGS into REGCACHE. */
288+
289+void
290+supply_gregset (struct regcache *regcache, const prgregset_t *gregs)
291+{
292+ supply_gregset_regnum (regcache, gregs, -1);
293+}
294+
295+/* Copy general purpose register REGNUM (or all gp regs if REGNUM == -1)
296+ from REGCACHE into regset GREGS. */
297+
298+void
299+fill_gregset (const struct regcache *regcache, prgregset_t *gregs, int regnum)
300+{
301+ elf_greg_t *regp = *gregs;
302+ if (regnum == -1)
303+ {
304+ /* We fill the general purpose registers. */
305+ for (int i = MICROBLAZE_R0_REGNUM + 1; i < MICROBLAZE_FSR_REGNUM; i++)
306+ regcache->raw_collect (i, regp + i);
307+
308+ regcache->raw_collect (MICROBLAZE_PC_REGNUM, regp + 32);
309+ }
310+ else if (regnum == MICROBLAZE_R0_REGNUM)
311+ /* Nothing to do here. */
312+ ;
313+ else if (regnum > MICROBLAZE_R0_REGNUM && regnum < MICROBLAZE_FSR_REGNUM)
314+ regcache->raw_collect (regnum, regp + regnum);
315+ else if (regnum == MICROBLAZE_PC_REGNUM)
316+ regcache->raw_collect (MICROBLAZE_PC_REGNUM, regp + 32);
317+}
318+
319+/* Transfering floating-point registers between GDB, inferiors and cores.
320+ Since MicroBlaze floating-point registers are the same as GPRs these do
321+ nothing. */
322+
323+void
324+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregs)
325+{
326+}
327+
328+void
329+fill_fpregset (const struct regcache *regcache,
330+ gdb_fpregset_t *fpregs, int regno)
331+{
332+}
333+
334+
335+static void
336+fetch_register (struct regcache *regcache, int tid, int regno)
337+{
338+ struct gdbarch *gdbarch = regcache->arch ();
339+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
340+ /* This isn't really an address. But ptrace thinks of it as one. */
341+ CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
342+ int bytes_transferred;
343+ char buf[MICROBLAZE_MAX_REGISTER_SIZE];
344+
345+ if (regaddr == -1)
346+ {
347+ memset (buf, '\0', register_size (gdbarch, regno)); /* Supply zeroes */
348+ regcache->raw_supply (regno, buf);
349+ return;
350+ }
351+
352+ /* Read the raw register using sizeof(long) sized chunks. On a
353+ * 32-bit platform, 64-bit floating-point registers will require two
354+ * transfers. */
355+ for (bytes_transferred = 0;
356+ bytes_transferred < register_size (gdbarch, regno);
357+ bytes_transferred += sizeof (long))
358+ {
359+ long l;
360+
361+ errno = 0;
362+ l = ptrace (PTRACE_PEEKUSER, tid, (PTRACE_TYPE_ARG3) regaddr, 0);
363+ if (errno == EIO)
364+ {
365+ printf("ptrace io error\n");
366+ }
367+ regaddr += sizeof (long);
368+ if (errno != 0)
369+ {
370+ char message[128];
371+ sprintf (message, "reading register %s (#%d)",
372+ gdbarch_register_name (gdbarch, regno), regno);
373+ perror_with_name (message);
374+ }
375+ memcpy (&buf[bytes_transferred], &l, sizeof (l));
376+ }
377+
378+ /* Now supply the register. Keep in mind that the regcache's idea
379+ * of the register's size may not be a multiple of sizeof
380+ * (long). */
381+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
382+ {
383+ /* Little-endian values are always found at the left end of the
384+ * bytes transferred. */
385+ regcache->raw_supply (regno, buf);
386+ }
387+ else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
388+ {
389+ /* Big-endian values are found at the right end of the bytes
390+ * transferred. */
391+ size_t padding = (bytes_transferred - register_size (gdbarch, regno));
392+ regcache->raw_supply (regno, buf + padding);
393+ }
394+ else
395+ internal_error (__FILE__, __LINE__,
396+ _("fetch_register: unexpected byte order: %d"),
397+ gdbarch_byte_order (gdbarch));
398+}
399+
400+
401+/* This is a wrapper for the fetch_all_gp_regs function. It is
402+ * responsible for verifying if this target has the ptrace request
403+ * that can be used to fetch all general-purpose registers at one
404+ * shot. If it doesn't, then we should fetch them using the
405+ * old-fashioned way, which is to iterate over the registers and
406+ * request them one by one. */
407+static void
408+fetch_gp_regs (struct regcache *regcache, int tid)
409+{
410+ int i;
411+/* If we've hit this point, it doesn't really matter which
412+ architecture we are using. We just need to read the
413+ registers in the "old-fashioned way". */
414+ for (i = MICROBLAZE_R0_REGNUM; i <= MICROBLAZE_FSR_REGNUM; i++)
415+ fetch_register (regcache, tid, i);
416+}
417+
418+/* Return a target description for the current target. */
419+
420+const struct target_desc *
421+microblaze_linux_nat_target::read_description ()
422+{
423+ return tdesc_microblaze_linux;
424+}
425+
426+/* Fetch REGNUM (or all registers if REGNUM == -1) from the target
427+ into REGCACHE using PTRACE_GETREGSET. */
428+
429+void
430+microblaze_linux_nat_target::fetch_registers (struct regcache * regcache,
431+ int regno)
432+{
433+ /* Get the thread id for the ptrace call. */
434+ int tid = regcache->ptid ().lwp ();
435+//int tid = get_ptrace_pid (regcache->ptid());
436+#if 1
437+ if (regno == -1)
438+#endif
439+ fetch_gp_regs (regcache, tid);
440+#if 1
441+ else
442+ fetch_register (regcache, tid, regno);
443+#endif
444+}
445+
446+
447+/* Store REGNUM (or all registers if REGNUM == -1) to the target
448+ from REGCACHE using PTRACE_SETREGSET. */
449+
450+void
451+microblaze_linux_nat_target::store_registers (struct regcache *regcache, int regno)
452+{
453+ int tid;
454+
455+ tid = get_ptrace_pid (regcache->ptid ());
456+
457+ struct gdbarch *gdbarch = regcache->arch ();
458+ /* This isn't really an address. But ptrace thinks of it as one. */
459+ CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
460+ int i;
461+ size_t bytes_to_transfer;
462+ char buf[MICROBLAZE_MAX_REGISTER_SIZE];
463+
464+ if (regaddr == -1)
465+ return;
466+
467+ /* First collect the register. Keep in mind that the regcache's
468+ * idea of the register's size may not be a multiple of sizeof
469+ * (long). */
470+ memset (buf, 0, sizeof buf);
471+ bytes_to_transfer = align_up (register_size (gdbarch, regno), sizeof (long));
472+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
473+ {
474+ /* Little-endian values always sit at the left end of the buffer. */
475+ regcache->raw_collect (regno, buf);
476+ }
477+ else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
478+ {
479+ /* Big-endian values sit at the right end of the buffer. */
480+ size_t padding = (bytes_to_transfer - register_size (gdbarch, regno));
481+ regcache->raw_collect (regno, buf + padding);
482+ }
483+
484+ for (i = 0; i < bytes_to_transfer; i += sizeof (long))
485+ {
486+ long l;
487+
488+ memcpy (&l, &buf[i], sizeof (l));
489+ errno = 0;
490+ ptrace (PTRACE_POKEUSER, tid, (PTRACE_TYPE_ARG3) regaddr, l);
491+ regaddr += sizeof (long);
492+
493+ if (errno != 0)
494+ {
495+ char message[128];
496+ sprintf (message, "writing register %s (#%d)",
497+ gdbarch_register_name (gdbarch, regno), regno);
498+ perror_with_name (message);
499+ }
500+ }
501+}
502+
503+void _initialize_microblaze_linux_nat (void);
504+
505+void
506+_initialize_microblaze_linux_nat (void)
507+{
508+ /* Register the target. */
509+ linux_target = &the_microblaze_linux_nat_target;
510+ add_inf_child_target (linux_target);
511+}
512diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
513index b8277dfd735..b77acc9dc61 100644
514--- a/gdb/microblaze-linux-tdep.c
515+++ b/gdb/microblaze-linux-tdep.c
516@@ -37,6 +37,7 @@
517 #include "tramp-frame.h"
518 #include "linux-tdep.h"
519 #include "glibc-tdep.h"
520+#include "features/microblaze-linux.c"
521
522 static int microblaze_debug_flag = 0;
523
524@@ -179,4 +180,5 @@ _initialize_microblaze_linux_tdep ()
525 {
526 gdbarch_register_osabi (bfd_arch_microblaze, 0, GDB_OSABI_LINUX,
527 microblaze_linux_init_abi);
528+ initialize_tdesc_microblaze_linux ();
529 }
530diff --git a/gdb/microblaze-linux-tdep.h b/gdb/microblaze-linux-tdep.h
531new file mode 100644
532index 00000000000..a2c744e2961
533--- /dev/null
534+++ b/gdb/microblaze-linux-tdep.h
535@@ -0,0 +1,24 @@
536+/* Target-dependent code for GNU/Linux on OpenRISC.
537+
538+ Copyright (C) 2021 Free Software Foundation, Inc.
539+
540+ This file is part of GDB.
541+
542+ This program is free software; you can redistribute it and/or modify
543+ it under the terms of the GNU General Public License as published by
544+ the Free Software Foundation; either version 3 of the License, or
545+ (at your option) any later version.
546+
547+ This program is distributed in the hope that it will be useful,
548+ but WITHOUT ANY WARRANTY; without even the implied warranty of
549+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
550+ GNU General Public License for more details.
551+
552+ You should have received a copy of the GNU General Public License
553+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
554+#ifndef MICROBLAZE_LINUX_TDEP_H
555+#define MICROBLAZE_LINUX_TDEP_H
556+ /* Target descriptions. */
557+ extern struct target_desc *tdesc_microblaze_linux;
558+
559+#endif /* MICROBLAZE_LINUX_TDEP_H */
560diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
561index 399fa0e3dca..0a5b5ab59cc 100644
562--- a/gdb/microblaze-tdep.c
563+++ b/gdb/microblaze-tdep.c
564@@ -295,6 +295,7 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
565 cache->frameless_p = 0; /* Frame found. */
566 save_hidden_pointer_found = 0;
567 non_stack_instruction_found = 0;
568+ cache->register_offsets[rd] = -imm;
569 continue;
570 }
571 else if (IS_SPILL_SP(op, rd, ra))
572@@ -443,15 +444,17 @@ microblaze_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
573 if (find_pc_partial_function (start_pc, NULL, &func_start, &func_end))
574 {
575 sal = find_pc_line (func_start, 0);
576-
577- if (sal.end < func_end
578- && start_pc <= sal.end)
579+
580+ if (sal.line !=0 && sal.end <= func_end && start_pc <= sal.end) {
581 start_pc = sal.end;
582+ microblaze_debug("start_pc is %d\t sal.end is %d\t func_end is %d\t",start_pc,sal.end,func_end);
583+ }
584 }
585
586 ostart_pc = microblaze_analyze_prologue (gdbarch, func_start, 0xffffffffUL,
587 &cache);
588
589+
590 if (ostart_pc > start_pc)
591 return ostart_pc;
592 return start_pc;
593@@ -465,6 +468,7 @@ microblaze_frame_cache (struct frame_info *next_frame, void **this_cache)
594 struct microblaze_frame_cache *cache;
595 struct gdbarch *gdbarch = get_frame_arch (next_frame);
596 int rn;
597+ CORE_ADDR current_pc;
598
599 if (*this_cache)
600 return (struct microblaze_frame_cache *) *this_cache;
601@@ -478,10 +482,17 @@ microblaze_frame_cache (struct frame_info *next_frame, void **this_cache)
602 cache->register_offsets[rn] = -1;
603
604 /* Call for side effects. */
605- get_frame_func (next_frame);
606-
607- cache->pc = get_frame_address_in_block (next_frame);
608-
609+ cache->pc = get_frame_func (next_frame);
610+
611+// cache->pc = get_frame_address_in_block (next_frame);
612+ current_pc = get_frame_pc (next_frame);
613+ if (cache->pc)
614+ microblaze_analyze_prologue (gdbarch, cache->pc, current_pc, cache);
615+
616+ cache->saved_sp = cache->base + cache->framesize;
617+ cache->register_offsets[MICROBLAZE_PREV_PC_REGNUM] = cache->base;
618+ cache->register_offsets[MICROBLAZE_SP_REGNUM] = cache->saved_sp;
619+
620 return cache;
621 }
622
623@@ -506,6 +517,25 @@ microblaze_frame_prev_register (struct frame_info *this_frame,
624 struct microblaze_frame_cache *cache =
625 microblaze_frame_cache (this_frame, this_cache);
626
627+if ((regnum == MICROBLAZE_SP_REGNUM &&
628+ cache->register_offsets[MICROBLAZE_SP_REGNUM])
629+ || (regnum == MICROBLAZE_FP_REGNUM &&
630+ cache->register_offsets[MICROBLAZE_SP_REGNUM]))
631+
632+ return frame_unwind_got_constant (this_frame, regnum,
633+ cache->register_offsets[MICROBLAZE_SP_REGNUM]);
634+
635+if (regnum == MICROBLAZE_PC_REGNUM)
636+{
637+ regnum = 15;
638+ return frame_unwind_got_memory (this_frame, regnum,
639+ cache->register_offsets[MICROBLAZE_PREV_PC_REGNUM]);
640+
641+}
642+if (regnum == MICROBLAZE_SP_REGNUM)
643+ regnum = 1;
644+#if 0
645+
646 if (cache->frameless_p)
647 {
648 if (regnum == MICROBLAZE_PC_REGNUM)
649@@ -518,7 +548,9 @@ microblaze_frame_prev_register (struct frame_info *this_frame,
650 else
651 return trad_frame_get_prev_register (this_frame, cache->saved_regs,
652 regnum);
653-
654+#endif
655+ return trad_frame_get_prev_register (this_frame, cache->saved_regs,
656+ regnum);
657 }
658
659 static const struct frame_unwind microblaze_frame_unwind =
660@@ -633,7 +665,106 @@ microblaze_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
661 return (TYPE_LENGTH (type) == 16);
662 }
663
664-
665+#if 1
666+static std::vector<CORE_ADDR>
667+microblaze_software_single_step (struct regcache *regcache)
668+{
669+ struct gdbarch *arch = regcache->arch ();
670+ //struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
671+ static int le_breakp[] = MICROBLAZE_BREAKPOINT_LE;
672+ static int be_breakp[] = MICROBLAZE_BREAKPOINT;
673+ enum bfd_endian byte_order = gdbarch_byte_order (arch);
674+ int *breakp = byte_order == BFD_ENDIAN_BIG ? be_breakp : le_breakp;
675+// std::vector<CORE_ADDR> ret = NULL;
676+
677+ /* Save the address and the values of the next_pc and the target */
678+ static struct sstep_breaks
679+ {
680+ CORE_ADDR address;
681+ bfd_boolean valid;
682+ /* Shadow contents. */
683+ char data[INST_WORD_SIZE];
684+ } stepbreaks[2];
685+ int ii;
686+
687+ CORE_ADDR pc;
688+ std::vector<CORE_ADDR> next_pcs;
689+ long insn;
690+ enum microblaze_instr minstr;
691+ bfd_boolean isunsignednum;
692+ enum microblaze_instr_type insn_type;
693+ short delay_slots;
694+ int imm;
695+ bfd_boolean immfound = FALSE;
696+
697+ /* Set a breakpoint at the next instruction */
698+ /* If the current instruction is an imm, set it at the inst after */
699+ /* If the instruction has a delay slot, skip the delay slot */
700+ pc = regcache_read_pc (regcache);
701+ insn = microblaze_fetch_instruction (pc);
702+ minstr = get_insn_microblaze (insn, &isunsignednum, &insn_type, &delay_slots);
703+ if (insn_type == immediate_inst)
704+ {
705+ int rd, ra, rb;
706+ immfound = TRUE;
707+ minstr = microblaze_decode_insn (insn, &rd, &ra, &rb, &imm);
708+ pc = pc + INST_WORD_SIZE;
709+ insn = microblaze_fetch_instruction (pc);
710+ minstr = get_insn_microblaze (insn, &isunsignednum, &insn_type, &delay_slots);
711+ }
712+ stepbreaks[0].address = pc + (delay_slots * INST_WORD_SIZE) + INST_WORD_SIZE;
713+ if (insn_type != return_inst) {
714+ stepbreaks[0].valid = TRUE;
715+ } else {
716+ stepbreaks[0].valid = FALSE;
717+ }
718+
719+ microblaze_debug ("single-step insn_type=%x insn=%x\n", insn_type, insn);
720+ /* Now check for branch or return instructions */
721+ if (insn_type == branch_inst || insn_type == return_inst) {
722+ int limm;
723+ int lrd, lra, lrb;
724+ int ra, rb;
725+ bfd_boolean targetvalid;
726+ bfd_boolean unconditionalbranch;
727+ microblaze_decode_insn(insn, &lrd, &lra, &lrb, &limm);
728+ if (lra >= 0 && lra < MICROBLAZE_NUM_REGS)
729+ ra = regcache_raw_get_unsigned(regcache, lra);
730+ else
731+ ra = 0;
732+ if (lrb >= 0 && lrb < MICROBLAZE_NUM_REGS)
733+ rb = regcache_raw_get_unsigned(regcache, lrb);
734+ else
735+ rb = 0;
736+ stepbreaks[1].address = microblaze_get_target_address (insn, immfound, imm, pc, ra, rb, &targetvalid, &unconditionalbranch);
737+ microblaze_debug ("single-step uncondbr=%d targetvalid=%d target=%x\n", unconditionalbranch, targetvalid, stepbreaks[1].address);
738+ if (unconditionalbranch)
739+ stepbreaks[0].valid = FALSE; /* This is a unconditional branch: will not come to the next address */
740+ if (targetvalid && (stepbreaks[0].valid == FALSE ||
741+ (stepbreaks[0].address != stepbreaks[1].address))
742+ && (stepbreaks[1].address != pc)) {
743+ stepbreaks[1].valid = TRUE;
744+ } else {
745+ stepbreaks[1].valid = FALSE;
746+ }
747+ } else {
748+ stepbreaks[1].valid = FALSE;
749+ }
750+
751+ /* Insert the breakpoints */
752+ for (ii = 0; ii < 2; ++ii)
753+ {
754+
755+ /* ignore invalid breakpoint. */
756+ if (stepbreaks[ii].valid) {
757+ // VEC_safe_push (CORE_ADDR, next_pcs, stepbreaks[ii].address);;
758+ next_pcs.push_back (stepbreaks[ii].address);
759+ }
760+ }
761+ return next_pcs;
762+}
763+#endif
764+
765 static int dwarf2_to_reg_map[78] =
766 { 0 /* r0 */, 1 /* r1 */, 2 /* r2 */, 3 /* r3 */, /* 0- 3 */
767 4 /* r4 */, 5 /* r5 */, 6 /* r6 */, 7 /* r7 */, /* 4- 7 */
768@@ -805,6 +936,8 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
769 microblaze_breakpoint::bp_from_kind);
770 set_gdbarch_memory_remove_breakpoint (gdbarch, microblaze_linux_memory_remove_breakpoint);
771
772+ set_gdbarch_software_single_step (gdbarch, microblaze_software_single_step);
773+
774 set_gdbarch_frame_args_skip (gdbarch, 8);
775
776 set_gdbarch_unwind_pc (gdbarch, microblaze_unwind_pc);
777diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
778index 872a3931f20..7f75c693b74 100644
779--- a/gdb/microblaze-tdep.h
780+++ b/gdb/microblaze-tdep.h
781@@ -59,11 +59,11 @@ enum microblaze_regnum
782 MICROBLAZE_R12_REGNUM,
783 MICROBLAZE_R13_REGNUM,
784 MICROBLAZE_R14_REGNUM,
785- MICROBLAZE_R15_REGNUM,
786+ MICROBLAZE_R15_REGNUM,MICROBLAZE_PREV_PC_REGNUM = MICROBLAZE_R15_REGNUM,
787 MICROBLAZE_R16_REGNUM,
788 MICROBLAZE_R17_REGNUM,
789 MICROBLAZE_R18_REGNUM,
790- MICROBLAZE_R19_REGNUM,
791+ MICROBLAZE_R19_REGNUM,MICROBLAZE_FP_REGNUM = MICROBLAZE_R19_REGNUM,
792 MICROBLAZE_R20_REGNUM,
793 MICROBLAZE_R21_REGNUM,
794 MICROBLAZE_R22_REGNUM,
795@@ -76,7 +76,8 @@ enum microblaze_regnum
796 MICROBLAZE_R29_REGNUM,
797 MICROBLAZE_R30_REGNUM,
798 MICROBLAZE_R31_REGNUM,
799- MICROBLAZE_PC_REGNUM,
800+ MICROBLAZE_MAX_GPR_REGS,
801+ MICROBLAZE_PC_REGNUM=32,
802 MICROBLAZE_MSR_REGNUM,
803 MICROBLAZE_EAR_REGNUM,
804 MICROBLAZE_ESR_REGNUM,
805@@ -101,17 +102,21 @@ enum microblaze_regnum
806 MICROBLAZE_RTLBSX_REGNUM,
807 MICROBLAZE_RTLBLO_REGNUM,
808 MICROBLAZE_RTLBHI_REGNUM,
809- MICROBLAZE_SLR_REGNUM, MICROBLAZE_NUM_CORE_REGS = MICROBLAZE_SLR_REGNUM,
810+ MICROBLAZE_SLR_REGNUM,
811 MICROBLAZE_SHR_REGNUM,
812- MICROBLAZE_NUM_REGS
813+ MICROBLAZE_NUM_REGS, MICROBLAZE_NUM_CORE_REGS = MICROBLAZE_NUM_REGS
814 };
815
816+/* Big enough to hold the size of the largest register in bytes. */
817+#define MICROBLAZE_MAX_REGISTER_SIZE 64
818+
819 struct microblaze_frame_cache
820 {
821 /* Base address. */
822 CORE_ADDR base;
823 CORE_ADDR pc;
824
825+ CORE_ADDR saved_sp;
826 /* Do we have a frame? */
827 int frameless_p;
828
829--
8302.17.1
831
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0007-Patch-microblaze-Adding-64-bit-MB-support.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0007-Patch-microblaze-Adding-64-bit-MB-support.patch
index 6536c22d..564562da 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0007-Patch-microblaze-Adding-64-bit-MB-support.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0007-Patch-microblaze-Adding-64-bit-MB-support.patch
@@ -1,4 +1,4 @@
1From f9e5f9f884470d0a216126b347b4699d6051fcdd Mon Sep 17 00:00:00 2001 1From 0eea9a3f068837d4792719a8f9ba15736938eea4 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com> 2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 31 Jan 2019 14:36:00 +0530 3Date: Thu, 31 Jan 2019 14:36:00 +0530
4Subject: [PATCH 07/10] [Patch, microblaze]: Adding 64 bit MB support Added new 4Subject: [PATCH 07/10] [Patch, microblaze]: Adding 64 bit MB support Added new
@@ -16,6 +16,9 @@ Conflicts:
16Conflicts: 16Conflicts:
17 bfd/configure 17 bfd/configure
18 opcodes/microblaze-opcm.h 18 opcodes/microblaze-opcm.h
19
20Conflicts:
21 gdb/microblaze-tdep.c
19--- 22---
20 bfd/Makefile.am | 2 + 23 bfd/Makefile.am | 2 +
21 bfd/Makefile.in | 3 + 24 bfd/Makefile.in | 3 +
@@ -41,8 +44,8 @@ Conflicts:
41 gdb/features/microblaze64.c | 77 + 44 gdb/features/microblaze64.c | 77 +
42 gdb/features/microblaze64.xml | 11 + 45 gdb/features/microblaze64.xml | 11 +
43 gdb/microblaze-linux-tdep.c | 36 +- 46 gdb/microblaze-linux-tdep.c | 36 +-
44 gdb/microblaze-tdep.c | 210 +- 47 gdb/microblaze-tdep.c | 102 +-
45 gdb/microblaze-tdep.h | 8 +- 48 gdb/microblaze-tdep.h | 4 +-
46 .../microblaze-with-stack-protect.dat | 4 +- 49 .../microblaze-with-stack-protect.dat | 4 +-
47 .../linux-microblaze-low.c | 0 50 .../linux-microblaze-low.c | 0
48 include/elf/common.h | 1 + 51 include/elf/common.h | 1 +
@@ -50,7 +53,7 @@ Conflicts:
50 opcodes/microblaze-dis.c | 51 +- 53 opcodes/microblaze-dis.c | 51 +-
51 opcodes/microblaze-opc.h | 180 +- 54 opcodes/microblaze-opc.h | 180 +-
52 opcodes/microblaze-opcm.h | 36 +- 55 opcodes/microblaze-opcm.h | 36 +-
53 41 files changed, 5454 insertions(+), 248 deletions(-) 56 41 files changed, 5345 insertions(+), 245 deletions(-)
54 create mode 100755 bfd/elf64-microblaze.c 57 create mode 100755 bfd/elf64-microblaze.c
55 create mode 100644 gdb/features/microblaze64-core.xml 58 create mode 100644 gdb/features/microblaze64-core.xml
56 create mode 100644 gdb/features/microblaze64-stack-protect.xml 59 create mode 100644 gdb/features/microblaze64-stack-protect.xml
@@ -4880,18 +4883,18 @@ index 00000000000..515d18e65cf
4880+ <xi:include href="microblaze64-core.xml"/> 4883+ <xi:include href="microblaze64-core.xml"/>
4881+</target> 4884+</target>
4882diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c 4885diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
4883index b8277dfd735..0c9ec82cee5 100644 4886index b77acc9dc61..ba87d0bbd63 100644
4884--- a/gdb/microblaze-linux-tdep.c 4887--- a/gdb/microblaze-linux-tdep.c
4885+++ b/gdb/microblaze-linux-tdep.c 4888+++ b/gdb/microblaze-linux-tdep.c
4886@@ -39,6 +39,7 @@ 4889@@ -40,6 +40,7 @@
4887 #include "glibc-tdep.h" 4890 #include "features/microblaze-linux.c"
4888 4891
4889 static int microblaze_debug_flag = 0; 4892 static int microblaze_debug_flag = 0;
4890+int MICROBLAZE_REGISTER_SIZE=4; 4893+int MICROBLAZE_REGISTER_SIZE=4;
4891 4894
4892 static void 4895 static void
4893 microblaze_debug (const char *fmt, ...) 4896 microblaze_debug (const char *fmt, ...)
4894@@ -54,6 +55,7 @@ microblaze_debug (const char *fmt, ...) 4897@@ -55,6 +56,7 @@ microblaze_debug (const char *fmt, ...)
4895 } 4898 }
4896 } 4899 }
4897 4900
@@ -4899,7 +4902,7 @@ index b8277dfd735..0c9ec82cee5 100644
4899 static int 4902 static int
4900 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch, 4903 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
4901 struct bp_target_info *bp_tgt) 4904 struct bp_target_info *bp_tgt)
4902@@ -85,6 +87,8 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch, 4905@@ -86,6 +88,8 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
4903 return val; 4906 return val;
4904 } 4907 }
4905 4908
@@ -4908,7 +4911,7 @@ index b8277dfd735..0c9ec82cee5 100644
4908 static void 4911 static void
4909 microblaze_linux_sigtramp_cache (struct frame_info *next_frame, 4912 microblaze_linux_sigtramp_cache (struct frame_info *next_frame,
4910 struct trad_frame_cache *this_cache, 4913 struct trad_frame_cache *this_cache,
4911@@ -146,8 +150,8 @@ microblaze_linux_init_abi (struct gdbarch_info info, 4914@@ -147,8 +151,8 @@ microblaze_linux_init_abi (struct gdbarch_info info,
4912 4915
4913 linux_init_abi (info, gdbarch); 4916 linux_init_abi (info, gdbarch);
4914 4917
@@ -4919,7 +4922,7 @@ index b8277dfd735..0c9ec82cee5 100644
4919 4922
4920 /* Shared library handling. */ 4923 /* Shared library handling. */
4921 set_solib_svr4_fetch_link_map_offsets (gdbarch, 4924 set_solib_svr4_fetch_link_map_offsets (gdbarch,
4922@@ -159,10 +163,30 @@ microblaze_linux_init_abi (struct gdbarch_info info, 4925@@ -160,10 +164,30 @@ microblaze_linux_init_abi (struct gdbarch_info info,
4923 4926
4924 /* BFD target for core files. */ 4927 /* BFD target for core files. */
4925 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) 4928 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
@@ -4952,7 +4955,7 @@ index b8277dfd735..0c9ec82cee5 100644
4952 4955
4953 /* Shared library handling. */ 4956 /* Shared library handling. */
4954 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target); 4957 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
4955@@ -177,6 +201,8 @@ void _initialize_microblaze_linux_tdep (); 4958@@ -178,7 +202,9 @@ void _initialize_microblaze_linux_tdep ();
4956 void 4959 void
4957 _initialize_microblaze_linux_tdep () 4960 _initialize_microblaze_linux_tdep ()
4958 { 4961 {
@@ -4961,9 +4964,10 @@ index b8277dfd735..0c9ec82cee5 100644
4961+ microblaze_linux_init_abi); 4964+ microblaze_linux_init_abi);
4962+ gdbarch_register_osabi (bfd_arch_microblaze, bfd_mach_microblaze64, GDB_OSABI_LINUX, 4965+ gdbarch_register_osabi (bfd_arch_microblaze, bfd_mach_microblaze64, GDB_OSABI_LINUX,
4963 microblaze_linux_init_abi); 4966 microblaze_linux_init_abi);
4967 initialize_tdesc_microblaze_linux ();
4964 } 4968 }
4965diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c 4969diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
4966index 399fa0e3dca..e51c022c1ba 100644 4970index 0a5b5ab59cc..667d658adfd 100644
4967--- a/gdb/microblaze-tdep.c 4971--- a/gdb/microblaze-tdep.c
4968+++ b/gdb/microblaze-tdep.c 4972+++ b/gdb/microblaze-tdep.c
4969@@ -40,7 +40,9 @@ 4973@@ -40,7 +40,9 @@
@@ -5023,7 +5027,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5023 /* Allocate and initialize a frame cache. */ 5027 /* Allocate and initialize a frame cache. */
5024 5028
5025 static struct microblaze_frame_cache * 5029 static struct microblaze_frame_cache *
5026@@ -556,17 +568,16 @@ microblaze_extract_return_value (struct type *type, struct regcache *regcache, 5030@@ -588,17 +600,16 @@ microblaze_extract_return_value (struct type *type, struct regcache *regcache,
5027 gdb_byte *valbuf) 5031 gdb_byte *valbuf)
5028 { 5032 {
5029 gdb_byte buf[8]; 5033 gdb_byte buf[8];
@@ -5043,118 +5047,10 @@ index 399fa0e3dca..e51c022c1ba 100644
5043 return; 5047 return;
5044 case 4: /* for sizes 4 or 8, copy the required length. */ 5048 case 4: /* for sizes 4 or 8, copy the required length. */
5045 case 8: 5049 case 8:
5046@@ -633,7 +644,119 @@ microblaze_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type) 5050@@ -765,6 +776,12 @@ microblaze_software_single_step (struct regcache *regcache)
5047 return (TYPE_LENGTH (type) == 16);
5048 } 5051 }
5052 #endif
5049 5053
5050-
5051+#if 0
5052+static std::vector<CORE_ADDR>
5053+microblaze_software_single_step (struct regcache *regcache)
5054+{
5055+// struct gdbarch *arch = get_frame_arch(frame);
5056+ struct gdbarch *arch = get_regcache_arch (regcache);
5057+ struct address_space *aspace = get_regcache_aspace (regcache);
5058+// struct address_space *aspace = get_frame_address_space (frame);
5059+ struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
5060+ static char le_breakp[] = MICROBLAZE_BREAKPOINT_LE;
5061+ static char be_breakp[] = MICROBLAZE_BREAKPOINT;
5062+ enum bfd_endian byte_order = gdbarch_byte_order (arch);
5063+ char *breakp = byte_order == BFD_ENDIAN_BIG ? be_breakp : le_breakp;
5064+ std::vector<CORE_ADDR> ret = 0;
5065+
5066+ /* Save the address and the values of the next_pc and the target */
5067+ static struct sstep_breaks
5068+ {
5069+ CORE_ADDR address;
5070+ bfd_boolean valid;
5071+ /* Shadow contents. */
5072+ char data[INST_WORD_SIZE];
5073+ } stepbreaks[2];
5074+ int ii;
5075+
5076+ if (1)
5077+ {
5078+ CORE_ADDR pc;
5079+ std::vector<CORE_ADDR> *next_pcs = NULL;
5080+ long insn;
5081+ enum microblaze_instr minstr;
5082+ bfd_boolean isunsignednum;
5083+ enum microblaze_instr_type insn_type;
5084+ short delay_slots;
5085+ int imm;
5086+ bfd_boolean immfound = FALSE;
5087+
5088+ /* Set a breakpoint at the next instruction */
5089+ /* If the current instruction is an imm, set it at the inst after */
5090+ /* If the instruction has a delay slot, skip the delay slot */
5091+ pc = regcache_read_pc (regcache);
5092+ insn = microblaze_fetch_instruction (pc);
5093+ minstr = get_insn_microblaze (insn, &isunsignednum, &insn_type, &delay_slots);
5094+ if (insn_type == immediate_inst)
5095+ {
5096+ int rd, ra, rb;
5097+ immfound = TRUE;
5098+ minstr = microblaze_decode_insn (insn, &rd, &ra, &rb, &imm);
5099+ pc = pc + INST_WORD_SIZE;
5100+ insn = microblaze_fetch_instruction (pc);
5101+ minstr = get_insn_microblaze (insn, &isunsignednum, &insn_type, &delay_slots);
5102+ }
5103+ stepbreaks[0].address = pc + (delay_slots * INST_WORD_SIZE) + INST_WORD_SIZE;
5104+ if (insn_type != return_inst) {
5105+ stepbreaks[0].valid = TRUE;
5106+ } else {
5107+ stepbreaks[0].valid = FALSE;
5108+ }
5109+
5110+ microblaze_debug ("single-step insn_type=%x insn=%x\n", insn_type, insn);
5111+ /* Now check for branch or return instructions */
5112+ if (insn_type == branch_inst || insn_type == return_inst) {
5113+ int limm;
5114+ int lrd, lra, lrb;
5115+ int ra, rb;
5116+ bfd_boolean targetvalid;
5117+ bfd_boolean unconditionalbranch;
5118+ microblaze_decode_insn(insn, &lrd, &lra, &lrb, &limm);
5119+ if (lra >= 0 && lra < MICROBLAZE_NUM_REGS)
5120+ ra = regcache_raw_get_unsigned(regcache, lra);
5121+ else
5122+ ra = 0;
5123+ if (lrb >= 0 && lrb < MICROBLAZE_NUM_REGS)
5124+ rb = regcache_raw_get_unsigned(regcache, lrb);
5125+ else
5126+ rb = 0;
5127+ stepbreaks[1].address = microblaze_get_target_address (insn, immfound, imm, pc, ra, rb, &targetvalid, &unconditionalbranch);
5128+ microblaze_debug ("single-step uncondbr=%d targetvalid=%d target=%x\n", unconditionalbranch, targetvalid, stepbreaks[1].address);
5129+ if (unconditionalbranch)
5130+ stepbreaks[0].valid = FALSE; /* This is a unconditional branch: will not come to the next address */
5131+ if (targetvalid && (stepbreaks[0].valid == FALSE ||
5132+ (stepbreaks[0].address != stepbreaks[1].address))
5133+ && (stepbreaks[1].address != pc)) {
5134+ stepbreaks[1].valid = TRUE;
5135+ } else {
5136+ stepbreaks[1].valid = FALSE;
5137+ }
5138+ } else {
5139+ stepbreaks[1].valid = FALSE;
5140+ }
5141+
5142+ /* Insert the breakpoints */
5143+ for (ii = 0; ii < 2; ++ii)
5144+ {
5145+
5146+ /* ignore invalid breakpoint. */
5147+ if (stepbreaks[ii].valid) {
5148+ VEC_safe_push (CORE_ADDR, next_pcs, stepbreaks[ii].address);;
5149+// insert_single_step_breakpoint (arch, aspace, stepbreaks[ii].address);
5150+ ret = next_pcs;
5151+ }
5152+ }
5153+ }
5154+ return ret;
5155+}
5156+#endif
5157+
5158+static void 5054+static void
5159+microblaze_write_pc (struct regcache *regcache, CORE_ADDR pc) 5055+microblaze_write_pc (struct regcache *regcache, CORE_ADDR pc)
5160+{ 5056+{
@@ -5164,7 +5060,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5164 static int dwarf2_to_reg_map[78] = 5060 static int dwarf2_to_reg_map[78] =
5165 { 0 /* r0 */, 1 /* r1 */, 2 /* r2 */, 3 /* r3 */, /* 0- 3 */ 5061 { 0 /* r0 */, 1 /* r1 */, 2 /* r2 */, 3 /* r3 */, /* 0- 3 */
5166 4 /* r4 */, 5 /* r5 */, 6 /* r6 */, 7 /* r7 */, /* 4- 7 */ 5062 4 /* r4 */, 5 /* r5 */, 6 /* r6 */, 7 /* r7 */, /* 4- 7 */
5167@@ -668,13 +791,14 @@ microblaze_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int reg) 5063@@ -799,13 +816,14 @@ microblaze_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int reg)
5168 static void 5064 static void
5169 microblaze_register_g_packet_guesses (struct gdbarch *gdbarch) 5065 microblaze_register_g_packet_guesses (struct gdbarch *gdbarch)
5170 { 5066 {
@@ -5182,7 +5078,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5182 } 5078 }
5183 5079
5184 void 5080 void
5185@@ -682,7 +806,7 @@ microblaze_supply_gregset (const struct regset *regset, 5081@@ -813,7 +831,7 @@ microblaze_supply_gregset (const struct regset *regset,
5186 struct regcache *regcache, 5082 struct regcache *regcache,
5187 int regnum, const void *gregs) 5083 int regnum, const void *gregs)
5188 { 5084 {
@@ -5191,7 +5087,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5191 if (regnum >= 0) 5087 if (regnum >= 0)
5192 regcache->raw_supply (regnum, regs + regnum); 5088 regcache->raw_supply (regnum, regs + regnum);
5193 5089
5194@@ -690,7 +814,7 @@ microblaze_supply_gregset (const struct regset *regset, 5090@@ -821,7 +839,7 @@ microblaze_supply_gregset (const struct regset *regset,
5195 int i; 5091 int i;
5196 5092
5197 for (i = 0; i < 50; i++) { 5093 for (i = 0; i < 50; i++) {
@@ -5200,7 +5096,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5200 } 5096 }
5201 } 5097 }
5202 } 5098 }
5203@@ -713,6 +837,17 @@ microblaze_iterate_over_regset_sections (struct gdbarch *gdbarch, 5099@@ -844,6 +862,17 @@ microblaze_iterate_over_regset_sections (struct gdbarch *gdbarch,
5204 } 5100 }
5205 5101
5206 5102
@@ -5218,7 +5114,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5218 5114
5219 static struct gdbarch * 5115 static struct gdbarch *
5220 microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5116 microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5221@@ -727,8 +862,15 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5117@@ -858,8 +887,15 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5222 if (arches != NULL) 5118 if (arches != NULL)
5223 return arches->gdbarch; 5119 return arches->gdbarch;
5224 if (tdesc == NULL) 5120 if (tdesc == NULL)
@@ -5236,7 +5132,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5236 /* Check any target description for validity. */ 5132 /* Check any target description for validity. */
5237 if (tdesc_has_registers (tdesc)) 5133 if (tdesc_has_registers (tdesc))
5238 { 5134 {
5239@@ -736,27 +878,35 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5135@@ -867,27 +903,35 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5240 int valid_p; 5136 int valid_p;
5241 int i; 5137 int i;
5242 5138
@@ -5277,7 +5173,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5277 } 5173 }
5278 5174
5279 if (!valid_p) 5175 if (!valid_p)
5280@@ -764,6 +914,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5176@@ -895,6 +939,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5281 tdesc_data_cleanup (tdesc_data); 5177 tdesc_data_cleanup (tdesc_data);
5282 return NULL; 5178 return NULL;
5283 } 5179 }
@@ -5285,7 +5181,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5285 } 5181 }
5286 5182
5287 /* Allocate space for the new architecture. */ 5183 /* Allocate space for the new architecture. */
5288@@ -783,7 +934,17 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5184@@ -914,7 +959,17 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5289 /* Register numbers of various important registers. */ 5185 /* Register numbers of various important registers. */
5290 set_gdbarch_sp_regnum (gdbarch, MICROBLAZE_SP_REGNUM); 5186 set_gdbarch_sp_regnum (gdbarch, MICROBLAZE_SP_REGNUM);
5291 set_gdbarch_pc_regnum (gdbarch, MICROBLAZE_PC_REGNUM); 5187 set_gdbarch_pc_regnum (gdbarch, MICROBLAZE_PC_REGNUM);
@@ -5303,7 +5199,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5303 /* Map Dwarf2 registers to GDB registers. */ 5199 /* Map Dwarf2 registers to GDB registers. */
5304 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, microblaze_dwarf2_reg_to_regnum); 5200 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, microblaze_dwarf2_reg_to_regnum);
5305 5201
5306@@ -803,13 +964,15 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5202@@ -934,7 +989,9 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5307 microblaze_breakpoint::kind_from_pc); 5203 microblaze_breakpoint::kind_from_pc);
5308 set_gdbarch_sw_breakpoint_from_kind (gdbarch, 5204 set_gdbarch_sw_breakpoint_from_kind (gdbarch,
5309 microblaze_breakpoint::bp_from_kind); 5205 microblaze_breakpoint::bp_from_kind);
@@ -5312,7 +5208,9 @@ index 399fa0e3dca..e51c022c1ba 100644
5312+ 5208+
5313+// set_gdbarch_software_single_step (gdbarch, microblaze_software_single_step); 5209+// set_gdbarch_software_single_step (gdbarch, microblaze_software_single_step);
5314 5210
5315 set_gdbarch_frame_args_skip (gdbarch, 8); 5211 set_gdbarch_software_single_step (gdbarch, microblaze_software_single_step);
5212
5213@@ -942,7 +999,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5316 5214
5317 set_gdbarch_unwind_pc (gdbarch, microblaze_unwind_pc); 5215 set_gdbarch_unwind_pc (gdbarch, microblaze_unwind_pc);
5318 5216
@@ -5321,7 +5219,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5321 5219
5322 frame_base_set_default (gdbarch, &microblaze_frame_base); 5220 frame_base_set_default (gdbarch, &microblaze_frame_base);
5323 5221
5324@@ -824,12 +987,11 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5222@@ -957,12 +1014,11 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5325 tdesc_use_registers (gdbarch, tdesc, tdesc_data); 5223 tdesc_use_registers (gdbarch, tdesc, tdesc_data);
5326 //frame_base_append_sniffer (gdbarch, microblaze_frame_sniffer); 5224 //frame_base_append_sniffer (gdbarch, microblaze_frame_sniffer);
5327 5225
@@ -5336,7 +5234,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5336 return gdbarch; 5234 return gdbarch;
5337 } 5235 }
5338 5236
5339@@ -841,6 +1003,8 @@ _initialize_microblaze_tdep () 5237@@ -974,6 +1030,8 @@ _initialize_microblaze_tdep ()
5340 5238
5341 initialize_tdesc_microblaze_with_stack_protect (); 5239 initialize_tdesc_microblaze_with_stack_protect ();
5342 initialize_tdesc_microblaze (); 5240 initialize_tdesc_microblaze ();
@@ -5346,7 +5244,7 @@ index 399fa0e3dca..e51c022c1ba 100644
5346 add_setshow_zuinteger_cmd ("microblaze", class_maintenance, 5244 add_setshow_zuinteger_cmd ("microblaze", class_maintenance,
5347 &microblaze_debug_flag, _("\ 5245 &microblaze_debug_flag, _("\
5348diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h 5246diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
5349index 872a3931f20..dc1d4686914 100644 5247index 7f75c693b74..e0fa7ef9b12 100644
5350--- a/gdb/microblaze-tdep.h 5248--- a/gdb/microblaze-tdep.h
5351+++ b/gdb/microblaze-tdep.h 5249+++ b/gdb/microblaze-tdep.h
5352@@ -27,7 +27,7 @@ struct microblaze_gregset 5250@@ -27,7 +27,7 @@ struct microblaze_gregset
@@ -5358,19 +5256,7 @@ index 872a3931f20..dc1d4686914 100644
5358 }; 5256 };
5359 5257
5360 struct gdbarch_tdep 5258 struct gdbarch_tdep
5361@@ -101,9 +101,9 @@ enum microblaze_regnum 5259@@ -133,7 +133,7 @@ struct microblaze_frame_cache
5362 MICROBLAZE_RTLBSX_REGNUM,
5363 MICROBLAZE_RTLBLO_REGNUM,
5364 MICROBLAZE_RTLBHI_REGNUM,
5365- MICROBLAZE_SLR_REGNUM, MICROBLAZE_NUM_CORE_REGS = MICROBLAZE_SLR_REGNUM,
5366+ MICROBLAZE_SLR_REGNUM,
5367 MICROBLAZE_SHR_REGNUM,
5368- MICROBLAZE_NUM_REGS
5369+ MICROBLAZE_NUM_REGS, MICROBLAZE_NUM_CORE_REGS = MICROBLAZE_NUM_REGS
5370 };
5371
5372 struct microblaze_frame_cache
5373@@ -128,7 +128,7 @@ struct microblaze_frame_cache
5374 struct trad_frame_saved_reg *saved_regs; 5260 struct trad_frame_saved_reg *saved_regs;
5375 }; 5261 };
5376 /* All registers are 32 bits. */ 5262 /* All registers are 32 bits. */
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0009-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0008-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch
index fca85fa2..abbea266 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0009-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0008-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch
@@ -1,7 +1,7 @@
1From 9ab0a0a551902e5196d46178b57fa1b33b587092 Mon Sep 17 00:00:00 2001 1From cc8ee172b9145ce488c556a2eb50f931f0676eea Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com> 2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 19 Apr 2021 14:33:27 +0530 3Date: Mon, 19 Apr 2021 14:33:27 +0530
4Subject: [PATCH 09/10] [Patch,MicroBlaze] : these changes will make 64 bit 4Subject: [PATCH 08/10] [Patch,MicroBlaze] : these changes will make 64 bit
5 vectors as default target types when we built gdb with microblaze 64 bit type 5 vectors as default target types when we built gdb with microblaze 64 bit type
6 targets,for instance microblaze-xilinx-elf64/microblazeel-xilinx-elf64 6 targets,for instance microblaze-xilinx-elf64/microblazeel-xilinx-elf64
7 7
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0008-gdb-Fix-microblaze-target-compilation-3.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0008-gdb-Fix-microblaze-target-compilation-3.patch
deleted file mode 100644
index 6a570b6a..00000000
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0008-gdb-Fix-microblaze-target-compilation-3.patch
+++ /dev/null
@@ -1,288 +0,0 @@
1From 306ca46b3f330ee39601b9aede6b53c9cdbe9f86 Mon Sep 17 00:00:00 2001
2From: Mark Hatle <mark.hatle@xilinx.com>
3Date: Wed, 9 Dec 2020 23:35:35 -0600
4Subject: [PATCH 08/10] gdb: Fix microblaze target compilation (#3)
5
6Add microblaze-linux-nat.c to configure.nat
7
8Transition microblaze-linux-nat.c to use the new gdb C++ style functions.
9
10Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
11---
12 gdb/configure.nat | 5 ++
13 gdb/microblaze-linux-nat.c | 96 ++++++++++++++------------------------
14 gdb/microblaze-tdep.h | 3 ++
15 3 files changed, 43 insertions(+), 61 deletions(-)
16
17diff --git a/gdb/configure.nat b/gdb/configure.nat
18index bb70e303384..d8548a6b666 100644
19--- a/gdb/configure.nat
20+++ b/gdb/configure.nat
21@@ -261,6 +261,11 @@ case ${gdb_host} in
22 # Host: Motorola m68k running GNU/Linux.
23 NATDEPFILES="${NATDEPFILES} m68k-linux-nat.o"
24 ;;
25+ microblaze)
26+ # Host: Microblaze running GNU/Linux.
27+ NATDEPFILES="${NATDEPFILES} microblaze-linux-nat.o"
28+ NAT_CDEPS=
29+ ;;
30 mips)
31 # Host: Linux/MIPS
32 NATDEPFILES="${NATDEPFILES} linux-nat-trad.o \
33diff --git a/gdb/microblaze-linux-nat.c b/gdb/microblaze-linux-nat.c
34index e9b8c9c5221..bac4697e1e6 100644
35--- a/gdb/microblaze-linux-nat.c
36+++ b/gdb/microblaze-linux-nat.c
37@@ -36,13 +36,14 @@
38 #include "dwarf2-frame.h"
39 #include "osabi.h"
40
41-#include "gdb_assert.h"
42-#include "gdb_string.h"
43+#include "gdbsupport/gdb_assert.h"
44+#include <string.h>
45 #include "target-descriptions.h"
46 #include "opcodes/microblaze-opcm.h"
47 #include "opcodes/microblaze-dis.h"
48
49 #include "linux-nat.h"
50+#include "linux-tdep.h"
51 #include "target-descriptions.h"
52
53 #include <sys/user.h>
54@@ -61,22 +62,17 @@
55 /* Defines ps_err_e, struct ps_prochandle. */
56 #include "gdb_proc_service.h"
57
58-/* On GNU/Linux, threads are implemented as pseudo-processes, in which
59- case we may be tracing more than one process at a time. In that
60- case, inferior_ptid will contain the main process ID and the
61- individual thread (process) ID. get_thread_id () is used to get
62- the thread id if it's available, and the process id otherwise. */
63-
64-int
65-get_thread_id (ptid_t ptid)
66+class microblaze_linux_nat_target final : public linux_nat_target
67 {
68- int tid = TIDGET (ptid);
69- if (0 == tid)
70- tid = PIDGET (ptid);
71- return tid;
72-}
73+public:
74+ /* Add our register access methods. */
75+ void fetch_registers (struct regcache *, int) override;
76+ void store_registers (struct regcache *, int) override;
77+
78+ const struct target_desc *read_description () override;
79+};
80
81-#define GET_THREAD_ID(PTID) get_thread_id (PTID)
82+static microblaze_linux_nat_target the_microblaze_linux_nat_target;
83
84 /* Non-zero if our kernel may support the PTRACE_GETREGS and
85 PTRACE_SETREGS requests, for reading and writing the
86@@ -88,7 +84,6 @@ static int
87 microblaze_register_u_addr (struct gdbarch *gdbarch, int regno)
88 {
89 int u_addr = -1;
90- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
91 /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
92 interface, and not the wordsize of the program's ABI. */
93 int wordsize = sizeof (long);
94@@ -105,18 +100,16 @@ microblaze_register_u_addr (struct gdbarch *gdbarch, int regno)
95 static void
96 fetch_register (struct regcache *regcache, int tid, int regno)
97 {
98- struct gdbarch *gdbarch = get_regcache_arch (regcache);
99- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
100+ struct gdbarch *gdbarch = regcache->arch ();
101 /* This isn't really an address. But ptrace thinks of it as one. */
102 CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
103 int bytes_transferred;
104- unsigned int offset; /* Offset of registers within the u area. */
105- char buf[MAX_REGISTER_SIZE];
106+ char buf[MICROBLAZE_MAX_REGISTER_SIZE];
107
108 if (regaddr == -1)
109 {
110 memset (buf, '\0', register_size (gdbarch, regno)); /* Supply zeroes */
111- regcache_raw_supply (regcache, regno, buf);
112+ regcache->raw_supply (regno, buf);
113 return;
114 }
115
116@@ -149,14 +142,14 @@ fetch_register (struct regcache *regcache, int tid, int regno)
117 {
118 /* Little-endian values are always found at the left end of the
119 bytes transferred. */
120- regcache_raw_supply (regcache, regno, buf);
121+ regcache->raw_supply (regno, buf);
122 }
123 else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
124 {
125 /* Big-endian values are found at the right end of the bytes
126 transferred. */
127 size_t padding = (bytes_transferred - register_size (gdbarch, regno));
128- regcache_raw_supply (regcache, regno, buf + padding);
129+ regcache->raw_supply (regno, buf + padding);
130 }
131 else
132 internal_error (__FILE__, __LINE__,
133@@ -175,8 +168,6 @@ fetch_register (struct regcache *regcache, int tid, int regno)
134 static int
135 fetch_all_gp_regs (struct regcache *regcache, int tid)
136 {
137- struct gdbarch *gdbarch = get_regcache_arch (regcache);
138- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
139 gdb_gregset_t gregset;
140
141 if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0)
142@@ -204,8 +195,6 @@ fetch_all_gp_regs (struct regcache *regcache, int tid)
143 static void
144 fetch_gp_regs (struct regcache *regcache, int tid)
145 {
146- struct gdbarch *gdbarch = get_regcache_arch (regcache);
147- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
148 int i;
149
150 if (have_ptrace_getsetregs)
151@@ -223,13 +212,12 @@ fetch_gp_regs (struct regcache *regcache, int tid)
152 static void
153 store_register (const struct regcache *regcache, int tid, int regno)
154 {
155- struct gdbarch *gdbarch = get_regcache_arch (regcache);
156- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
157+ struct gdbarch *gdbarch = regcache->arch ();
158 /* This isn't really an address. But ptrace thinks of it as one. */
159 CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
160 int i;
161 size_t bytes_to_transfer;
162- char buf[MAX_REGISTER_SIZE];
163+ char buf[MICROBLAZE_MAX_REGISTER_SIZE];
164
165 if (regaddr == -1)
166 return;
167@@ -242,13 +230,13 @@ store_register (const struct regcache *regcache, int tid, int regno)
168 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
169 {
170 /* Little-endian values always sit at the left end of the buffer. */
171- regcache_raw_collect (regcache, regno, buf);
172+ regcache->raw_collect (regno, buf);
173 }
174 else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
175 {
176 /* Big-endian values sit at the right end of the buffer. */
177 size_t padding = (bytes_to_transfer - register_size (gdbarch, regno));
178- regcache_raw_collect (regcache, regno, buf + padding);
179+ regcache->raw_collect (regno, buf + padding);
180 }
181
182 for (i = 0; i < bytes_to_transfer; i += sizeof (long))
183@@ -281,8 +269,6 @@ store_register (const struct regcache *regcache, int tid, int regno)
184 static int
185 store_all_gp_regs (const struct regcache *regcache, int tid, int regno)
186 {
187- struct gdbarch *gdbarch = get_regcache_arch (regcache);
188- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
189 gdb_gregset_t gregset;
190
191 if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0)
192@@ -319,8 +305,6 @@ store_all_gp_regs (const struct regcache *regcache, int tid, int regno)
193 static void
194 store_gp_regs (const struct regcache *regcache, int tid, int regno)
195 {
196- struct gdbarch *gdbarch = get_regcache_arch (regcache);
197- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
198 int i;
199
200 if (have_ptrace_getsetregs)
201@@ -339,12 +323,12 @@ store_gp_regs (const struct regcache *regcache, int tid, int regno)
202 regno == -1, otherwise fetch all general registers or all floating
203 point registers depending upon the value of regno. */
204
205-static void
206-microblaze_linux_fetch_inferior_registers (struct target_ops *ops,
207- struct regcache *regcache, int regno)
208+void
209+microblaze_linux_nat_target::fetch_registers (struct regcache * regcache,
210+ int regno)
211 {
212 /* Get the thread id for the ptrace call. */
213- int tid = GET_THREAD_ID (inferior_ptid);
214+ int tid = regcache->ptid ().lwp ();
215
216 if (regno == -1)
217 fetch_gp_regs (regcache, tid);
218@@ -356,12 +340,12 @@ microblaze_linux_fetch_inferior_registers (struct target_ops *ops,
219 regno == -1, otherwise store all general registers or all floating
220 point registers depending upon the value of regno. */
221
222-static void
223-microblaze_linux_store_inferior_registers (struct target_ops *ops,
224- struct regcache *regcache, int regno)
225+void
226+microblaze_linux_nat_target::store_registers (struct regcache *regcache,
227+ int regno)
228 {
229 /* Get the thread id for the ptrace call. */
230- int tid = GET_THREAD_ID (inferior_ptid);
231+ int tid = regcache->ptid ().lwp ();
232
233 if (regno >= 0)
234 store_register (regcache, tid, regno);
235@@ -398,12 +382,12 @@ supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
236 /* FIXME. */
237 }
238
239-static const struct target_desc *
240-microblaze_linux_read_description (struct target_ops *ops)
241+const struct target_desc *
242+microblaze_linux_nat_target::read_description ()
243 {
244- CORE_ADDR microblaze_hwcap = 0;
245+ CORE_ADDR microblaze_hwcap = linux_get_hwcap (this);
246
247- if (target_auxv_search (ops, AT_HWCAP, &microblaze_hwcap) != 1)
248+ if (microblaze_hwcap != 1)
249 return NULL;
250
251 return NULL;
252@@ -415,17 +399,7 @@ void _initialize_microblaze_linux_nat (void);
253 void
254 _initialize_microblaze_linux_nat (void)
255 {
256- struct target_ops *t;
257-
258- /* Fill in the generic GNU/Linux methods. */
259- t = linux_target ();
260-
261- /* Add our register access methods. */
262- t->to_fetch_registers = microblaze_linux_fetch_inferior_registers;
263- t->to_store_registers = microblaze_linux_store_inferior_registers;
264-
265- t->to_read_description = microblaze_linux_read_description;
266-
267 /* Register the target. */
268- linux_nat_add_target (t);
269+ linux_target = &the_microblaze_linux_nat_target;
270+ add_inf_child_target (&the_microblaze_linux_nat_target);
271 }
272diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
273index dc1d4686914..a5c12c10e0b 100644
274--- a/gdb/microblaze-tdep.h
275+++ b/gdb/microblaze-tdep.h
276@@ -106,6 +106,9 @@ enum microblaze_regnum
277 MICROBLAZE_NUM_REGS, MICROBLAZE_NUM_CORE_REGS = MICROBLAZE_NUM_REGS
278 };
279
280+/* Big enough to hold the size of the largest register in bytes. */
281+#define MICROBLAZE_MAX_REGISTER_SIZE 64
282+
283 struct microblaze_frame_cache
284 {
285 /* Base address. */
286--
2872.17.1
288
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0010-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0009-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch
index 78ef9202..35466e8f 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0010-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0009-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch
@@ -1,7 +1,7 @@
1From 67fd78c3fa5894e0038c09a858cb518c20340abf Mon Sep 17 00:00:00 2001 1From a721a7063f829ccaf6cf8273be04b763b53a735d Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com> 2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 9 Nov 2021 16:19:17 +0530 3Date: Tue, 9 Nov 2021 16:19:17 +0530
4Subject: [PATCH 10/10] [Patch,MicroBlaze] : Added m64 abi for 64 bit target 4Subject: [PATCH 09/10] [Patch,MicroBlaze] : Added m64 abi for 64 bit target
5 descriptions. set m64 abi for 64 bit elf. 5 descriptions. set m64 abi for 64 bit elf.
6 6
7--- 7---
@@ -22,7 +22,7 @@ index 515d18e65cf..9c1b7d22003 100644
22 <xi:include href="microblaze64-core.xml"/> 22 <xi:include href="microblaze64-core.xml"/>
23 </target> 23 </target>
24diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c 24diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
25index e51c022c1ba..3bffbbe4b3d 100644 25index 667d658adfd..aad6a9cae6e 100644
26--- a/gdb/microblaze-tdep.c 26--- a/gdb/microblaze-tdep.c
27+++ b/gdb/microblaze-tdep.c 27+++ b/gdb/microblaze-tdep.c
28@@ -65,8 +65,94 @@ 28@@ -65,8 +65,94 @@
@@ -139,7 +139,7 @@ index e51c022c1ba..3bffbbe4b3d 100644
139 static void ATTRIBUTE_PRINTF (1, 2) 139 static void ATTRIBUTE_PRINTF (1, 2)
140 microblaze_debug (const char *fmt, ...) 140 microblaze_debug (const char *fmt, ...)
141 { 141 {
142@@ -855,15 +953,30 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 142@@ -880,15 +978,30 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
143 struct gdbarch_tdep *tdep; 143 struct gdbarch_tdep *tdep;
144 struct gdbarch *gdbarch; 144 struct gdbarch *gdbarch;
145 struct tdesc_arch_data *tdesc_data = NULL; 145 struct tdesc_arch_data *tdesc_data = NULL;
@@ -172,7 +172,7 @@ index e51c022c1ba..3bffbbe4b3d 100644
172 { 172 {
173 tdesc = tdesc_microblaze64; 173 tdesc = tdesc_microblaze64;
174 reg_size = 8; 174 reg_size = 8;
175@@ -878,7 +991,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 175@@ -903,7 +1016,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
176 int valid_p; 176 int valid_p;
177 int i; 177 int i;
178 178
@@ -181,7 +181,7 @@ index e51c022c1ba..3bffbbe4b3d 100644
181 feature = tdesc_find_feature (tdesc, 181 feature = tdesc_find_feature (tdesc,
182 "org.gnu.gdb.microblaze64.core"); 182 "org.gnu.gdb.microblaze64.core");
183 else 183 else
184@@ -892,7 +1005,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 184@@ -917,7 +1030,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
185 for (i = 0; i < MICROBLAZE_NUM_REGS; i++) 185 for (i = 0; i < MICROBLAZE_NUM_REGS; i++)
186 valid_p &= tdesc_numbered_register (feature, tdesc_data, i, 186 valid_p &= tdesc_numbered_register (feature, tdesc_data, i,
187 microblaze_register_names[i]); 187 microblaze_register_names[i]);
@@ -190,7 +190,7 @@ index e51c022c1ba..3bffbbe4b3d 100644
190 feature = tdesc_find_feature (tdesc, 190 feature = tdesc_find_feature (tdesc,
191 "org.gnu.gdb.microblaze64.stack-protect"); 191 "org.gnu.gdb.microblaze64.stack-protect");
192 else 192 else
193@@ -943,7 +1056,8 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 193@@ -968,7 +1081,8 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
194 set_gdbarch_ptr_bit (gdbarch, 64); 194 set_gdbarch_ptr_bit (gdbarch, 64);
195 break; 195 break;
196 } 196 }
@@ -200,7 +200,7 @@ index e51c022c1ba..3bffbbe4b3d 100644
200 200
201 /* Map Dwarf2 registers to GDB registers. */ 201 /* Map Dwarf2 registers to GDB registers. */
202 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, microblaze_dwarf2_reg_to_regnum); 202 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, microblaze_dwarf2_reg_to_regnum);
203@@ -1000,7 +1114,30 @@ void 203@@ -1027,7 +1141,30 @@ void
204 _initialize_microblaze_tdep () 204 _initialize_microblaze_tdep ()
205 { 205 {
206 register_gdbarch_init (bfd_arch_microblaze, microblaze_gdbarch_init); 206 register_gdbarch_init (bfd_arch_microblaze, microblaze_gdbarch_init);
@@ -232,14 +232,14 @@ index e51c022c1ba..3bffbbe4b3d 100644
232 initialize_tdesc_microblaze_with_stack_protect (); 232 initialize_tdesc_microblaze_with_stack_protect ();
233 initialize_tdesc_microblaze (); 233 initialize_tdesc_microblaze ();
234 initialize_tdesc_microblaze64_with_stack_protect (); 234 initialize_tdesc_microblaze64_with_stack_protect ();
235@@ -1015,5 +1152,4 @@ When non-zero, microblaze specific debugging is enabled."), 235@@ -1042,5 +1179,4 @@ When non-zero, microblaze specific debugging is enabled."),
236 NULL, 236 NULL,
237 &setdebuglist, &showdebuglist); 237 &setdebuglist, &showdebuglist);
238 238
239- 239-
240 } 240 }
241diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h 241diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
242index a5c12c10e0b..29da6d29dcb 100644 242index e0fa7ef9b12..9cb9628295f 100644
243--- a/gdb/microblaze-tdep.h 243--- a/gdb/microblaze-tdep.h
244+++ b/gdb/microblaze-tdep.h 244+++ b/gdb/microblaze-tdep.h
245@@ -19,8 +19,16 @@ 245@@ -19,8 +19,16 @@
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0010-Patch-MicroBlaze-Code-changes-for-gdbserver.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0010-Patch-MicroBlaze-Code-changes-for-gdbserver.patch
new file mode 100644
index 00000000..dc38b480
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0010-Patch-MicroBlaze-Code-changes-for-gdbserver.patch
@@ -0,0 +1,401 @@
1From 01e16382c8fce4448c911a4c5780259e181e83dd Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Fri, 8 Jul 2022 12:53:51 +0530
4Subject: [PATCH 10/10] [Patch,MicroBlaze]: Code changes for gdbserver.
5
6---
7 gdb/features/Makefile | 1 +
8 gdb/features/microblaze-linux.xml | 1 +
9 gdb/regformats/microblaze-linux.dat | 64 +++++++++
10 gdbserver/Makefile.in | 5 +-
11 gdbserver/configure.srv | 1 +
12 ...croblaze-low.c => linux-microblaze-low.cc} | 132 ++++++++++--------
13 6 files changed, 138 insertions(+), 66 deletions(-)
14 create mode 100644 gdb/regformats/microblaze-linux.dat
15 rename gdbserver/{linux-microblaze-low.c => linux-microblaze-low.cc} (72%)
16
17diff --git a/gdb/features/Makefile b/gdb/features/Makefile
18index 131fc14adbf..1b15305862e 100644
19--- a/gdb/features/Makefile
20+++ b/gdb/features/Makefile
21@@ -47,6 +47,7 @@
22 WHICH = mips-linux mips-dsp-linux \
23 microblaze-with-stack-protect \
24 microblaze64-with-stack-protect \
25+ microblaze-linux \
26 mips64-linux mips64-dsp-linux \
27 nios2-linux \
28 rs6000/powerpc-32 \
29diff --git a/gdb/features/microblaze-linux.xml b/gdb/features/microblaze-linux.xml
30index 8983e66eb3d..688a3f83d1e 100644
31--- a/gdb/features/microblaze-linux.xml
32+++ b/gdb/features/microblaze-linux.xml
33@@ -7,6 +7,7 @@
34
35 <!DOCTYPE target SYSTEM "gdb-target.dtd">
36 <target>
37+ <architecture>microblaze</architecture>
38 <osabi>GNU/Linux</osabi>
39 <xi:include href="microblaze-core.xml"/>
40 </target>
41diff --git a/gdb/regformats/microblaze-linux.dat b/gdb/regformats/microblaze-linux.dat
42new file mode 100644
43index 00000000000..b5b49f485cd
44--- /dev/null
45+++ b/gdb/regformats/microblaze-linux.dat
46@@ -0,0 +1,64 @@
47+# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro:
48+# Generated from: microblaze-linux.xml
49+name:microblaze_linux
50+xmltarget:microblaze-linux.xml
51+expedite:r1,rpc
52+32:r0
53+32:r1
54+32:r2
55+32:r3
56+32:r4
57+32:r5
58+32:r6
59+32:r7
60+32:r8
61+32:r9
62+32:r10
63+32:r11
64+32:r12
65+32:r13
66+32:r14
67+32:r15
68+32:r16
69+32:r17
70+32:r18
71+32:r19
72+32:r20
73+32:r21
74+32:r22
75+32:r23
76+32:r24
77+32:r25
78+32:r26
79+32:r27
80+32:r28
81+32:r29
82+32:r30
83+32:r31
84+32:rpc
85+32:rmsr
86+32:rear
87+32:resr
88+32:rfsr
89+32:rbtr
90+32:rpvr0
91+32:rpvr1
92+32:rpvr2
93+32:rpvr3
94+32:rpvr4
95+32:rpvr5
96+32:rpvr6
97+32:rpvr7
98+32:rpvr8
99+32:rpvr9
100+32:rpvr10
101+32:rpvr11
102+32:redr
103+32:rpid
104+32:rzpr
105+32:rtlbx
106+32:rtlbsx
107+32:rtlblo
108+32:rtlbhi
109+32:slr
110+32:shr
111diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in
112index 46b5a0c7c60..eaaf6820fe0 100644
113--- a/gdbserver/Makefile.in
114+++ b/gdbserver/Makefile.in
115@@ -184,7 +184,7 @@ SFILES = \
116 $(srcdir)/linux-ia64-low.cc \
117 $(srcdir)/linux-low.cc \
118 $(srcdir)/linux-m68k-low.cc \
119- $(srcdir)/linux-microblaze-low.c \
120+ $(srcdir)/linux-microblaze-low.cc \
121 $(srcdir)/linux-mips-low.cc \
122 $(srcdir)/linux-nios2-low.cc \
123 $(srcdir)/linux-ppc-low.cc \
124@@ -222,7 +222,6 @@ SFILES = \
125 $(srcdir)/../gdb/nat/linux-namespaces.c \
126 $(srcdir)/../gdb/nat/linux-osdata.c \
127 $(srcdir)/../gdb/nat/linux-personality.c \
128- $(srcdir)/../gdb/nat/microblaze-linux.c \
129 $(srcdir)/../gdb/nat/mips-linux-watch.c \
130 $(srcdir)/../gdb/nat/ppc-linux.c \
131 $(srcdir)/../gdb/nat/riscv-linux-tdesc.c \
132@@ -564,8 +563,6 @@ target/%.o: ../gdb/target/%.c
133
134 %-generated.cc: ../gdb/regformats/rs6000/%.dat $(regdat_sh)
135 $(ECHO_REGDAT) $(SHELL) $(regdat_sh) $< $@
136-microblaze-linux.c : $(srcdir)/../regformats/reg-microblaze.dat $(regdat_sh)
137- $(ECHO_REGDAT) $(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-microblaze.dat microblaze-linux.c
138
139 #
140 # Dependency tracking.
141diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv
142index af10cb05683..026b156bd60 100644
143--- a/gdbserver/configure.srv
144+++ b/gdbserver/configure.srv
145@@ -169,6 +169,7 @@ case "${gdbserver_host}" in
146 microblaze*-*-linux*) srv_regobj="microblaze-linux.o"
147 srv_tgtobj="$srv_linux_obj linux-microblaze-low.o "
148 srv_xmlfiles="microblaze-linux.xml"
149+ srv_xmlfiles="${srv_xmlfiles} microblaze-core.xml"
150 srv_linux_regsets=yes
151 srv_linux_usrregs=yes
152 srv_linux_thread_db=yes
153diff --git a/gdbserver/linux-microblaze-low.c b/gdbserver/linux-microblaze-low.cc
154similarity index 72%
155rename from gdbserver/linux-microblaze-low.c
156rename to gdbserver/linux-microblaze-low.cc
157index a2733f3c21c..d30fa102b5e 100644
158--- a/gdbserver/linux-microblaze-low.c
159+++ b/gdbserver/linux-microblaze-low.cc
160@@ -20,12 +20,17 @@
161 #include "server.h"
162 #include "linux-low.h"
163
164+#include "elf/common.h"
165+#include "nat/gdb_ptrace.h"
166+#include <endian.h>
167+
168 #include <asm/ptrace.h>
169 #include <sys/procfs.h>
170 #include <sys/ptrace.h>
171
172 #include "gdb_proc_service.h"
173
174+
175 static int microblaze_regmap[] =
176 {PT_GPR(0), PT_GPR(1), PT_GPR(2), PT_GPR(3),
177 PT_GPR(4), PT_GPR(5), PT_GPR(6), PT_GPR(7),
178@@ -39,14 +44,46 @@ static int microblaze_regmap[] =
179 PT_FSR
180 };
181
182+
183+
184+class microblaze_target : public linux_process_target
185+{
186+public:
187+
188+ const regs_info *get_regs_info () override;
189+
190+ const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
191+ // CORE_ADDR microblaze_reinsert_addr (regcache *regcache);
192+
193+protected:
194+
195+ void low_arch_setup () override;
196+
197+ bool low_cannot_fetch_register (int regno) override;
198+
199+ bool low_cannot_store_register (int regno) override;
200+
201+ // bool low_supports_breakpoints () override;
202+
203+ CORE_ADDR low_get_pc (regcache *regcache) override;
204+
205+ void low_set_pc (regcache *regcache, CORE_ADDR newpc) override;
206+
207+ bool low_breakpoint_at (CORE_ADDR pc) override;
208+};
209+
210+/* The singleton target ops object. */
211+
212+static microblaze_target the_microblaze_target;
213+
214 #define microblaze_num_regs (sizeof (microblaze_regmap) / sizeof (microblaze_regmap[0]))
215
216 /* Defined in auto-generated file microblaze-linux.c. */
217-void init_registers_microblaze (void);
218-extern const struct target_desc *tdesc_microblaze;
219+void init_registers_microblaze_linux (void);
220+extern const struct target_desc *tdesc_microblaze_linux;
221
222-static int
223-microblaze_cannot_store_register (int regno)
224+bool
225+microblaze_target::low_cannot_store_register (int regno)
226 {
227 if (microblaze_regmap[regno] == -1 || regno == 0)
228 return 1;
229@@ -54,14 +91,14 @@ microblaze_cannot_store_register (int regno)
230 return 0;
231 }
232
233-static int
234-microblaze_cannot_fetch_register (int regno)
235+bool
236+microblaze_target::low_cannot_fetch_register (int regno)
237 {
238 return 0;
239 }
240
241-static CORE_ADDR
242-microblaze_get_pc (struct regcache *regcache)
243+CORE_ADDR
244+microblaze_target::low_get_pc (struct regcache *regcache)
245 {
246 unsigned long pc;
247
248@@ -69,8 +106,8 @@ microblaze_get_pc (struct regcache *regcache)
249 return (CORE_ADDR) pc;
250 }
251
252-static void
253-microblaze_set_pc (struct regcache *regcache, CORE_ADDR pc)
254+void
255+microblaze_target::low_set_pc (struct regcache *regcache, CORE_ADDR pc)
256 {
257 unsigned long newpc = pc;
258
259@@ -84,34 +121,35 @@ static const unsigned long microblaze_breakpoint = 0xba0c0018;
260
261 /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
262
263-static const gdb_byte *
264-microblaze_sw_breakpoint_from_kind (int kind, int *size)
265+const gdb_byte *
266+microblaze_target::sw_breakpoint_from_kind (int kind, int *size)
267 {
268 *size = microblaze_breakpoint_len;
269 return (const gdb_byte *) &microblaze_breakpoint;
270 }
271
272-static int
273-microblaze_breakpoint_at (CORE_ADDR where)
274+bool
275+microblaze_target::low_breakpoint_at (CORE_ADDR where)
276 {
277 unsigned long insn;
278
279- (*the_target->read_memory) (where, (unsigned char *) &insn, 4);
280+ read_memory (where, (unsigned char *) &insn, 4);
281 if (insn == microblaze_breakpoint)
282 return 1;
283 /* If necessary, recognize more trap instructions here. GDB only uses the
284 one. */
285 return 0;
286 }
287-
288-static CORE_ADDR
289-microblaze_reinsert_addr (struct regcache *regcache)
290+#if 0
291+CORE_ADDR
292+microblaze_target::microblaze_reinsert_addr (struct regcache *regcache)
293 {
294 unsigned long pc;
295 collect_register_by_name (regcache, "r15", &pc);
296 return pc;
297 }
298-
299+#endif
300+#if 0
301 #ifdef HAVE_PTRACE_GETREGS
302
303 static void
304@@ -166,12 +204,15 @@ microblaze_store_gregset (struct regcache *regcache, const void *buf)
305 }
306
307 #endif /* HAVE_PTRACE_GETREGS */
308+#endif
309
310 static struct regset_info microblaze_regsets[] = {
311+#if 0
312 #ifdef HAVE_PTRACE_GETREGS
313 { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS, microblaze_fill_gregset, microblaze_store_gregset },
314 { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
315 #endif /* HAVE_PTRACE_GETREGS */
316+#endif
317 { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
318 NULL_REGSET
319 };
320@@ -189,17 +230,17 @@ static struct regsets_info microblaze_regsets_info =
321 NULL, /* disabled_regsets */
322 };
323
324-static struct regs_info regs_info =
325+static struct regs_info microblaze_regs_info =
326 {
327 NULL, /* regset_bitmap */
328 &microblaze_usrregs_info,
329 &microblaze_regsets_info
330 };
331
332-static const struct regs_info *
333-microblaze_regs_info (void)
334+const regs_info *
335+microblaze_target::get_regs_info (void)
336 {
337- return &regs_info;
338+ return &microblaze_regs_info;
339 }
340
341 /* Support for hardware single step. */
342@@ -211,50 +252,17 @@ microblaze_supports_hardware_single_step (void)
343 }
344
345
346-static void
347-microblaze_arch_setup (void)
348+void
349+microblaze_target::low_arch_setup (void)
350 {
351- current_process ()->tdesc = tdesc_microblaze;
352+ current_process ()->tdesc = tdesc_microblaze_linux;
353 }
354
355-struct linux_target_ops the_low_target = {
356- microblaze_arch_setup,
357- microblaze_regs_info,
358- microblaze_cannot_fetch_register,
359- microblaze_cannot_store_register,
360- NULL, /* fetch_register */
361- microblaze_get_pc,
362- microblaze_set_pc,
363- NULL,
364- microblaze_sw_breakpoint_from_kind,
365- NULL,
366- 0,
367- microblaze_breakpoint_at,
368- NULL,
369- NULL,
370- NULL,
371- NULL,
372- NULL,
373- microblaze_collect_ptrace_register,
374- microblaze_supply_ptrace_register,
375- NULL, /* siginfo_fixup */
376- NULL, /* new_process */
377- NULL, /* new_thread */
378- NULL, /* new_fork */
379- NULL, /* prepare_to_resume */
380- NULL, /* process_qsupported */
381- NULL, /* supports_tracepoints */
382- NULL, /* get_thread_area */
383- NULL, /* install_fast_tracepoint_jump_pad */
384- NULL, /* emit_ops */
385- NULL, /* get_min_fast_tracepoint_insn_len */
386- NULL, /* supports_range_stepping */
387- NULL, /* breakpoint_kind_from_current_state */
388- microblaze_supports_hardware_single_step,
389-};
390+linux_process_target *the_linux_target = &the_microblaze_target;
391
392 void
393 initialize_low_arch (void)
394 {
395- init_registers_microblaze ();
396+ init_registers_microblaze_linux ();
397+ initialize_regsets_info (&microblaze_regsets_info);
398 }
399--
4002.17.1
401