diff options
Diffstat (limited to 'meta-microblaze/recipes-devtools/gdb/gdb/0002-Add-initial-port-of-linux-gdbserver-add-gdb_proc_ser.patch')
-rw-r--r-- | meta-microblaze/recipes-devtools/gdb/gdb/0002-Add-initial-port-of-linux-gdbserver-add-gdb_proc_ser.patch | 639 |
1 files changed, 639 insertions, 0 deletions
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0002-Add-initial-port-of-linux-gdbserver-add-gdb_proc_ser.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0002-Add-initial-port-of-linux-gdbserver-add-gdb_proc_ser.patch new file mode 100644 index 00000000..02b42cbd --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb/0002-Add-initial-port-of-linux-gdbserver-add-gdb_proc_ser.patch | |||
@@ -0,0 +1,639 @@ | |||
1 | From fa91dbd8c23e519760213f32de572cbf98ad6bc3 Mon Sep 17 00:00:00 2001 | ||
2 | From: Mahesh Bodapati <mbodapat@xilinx.com> | ||
3 | Date: Mon, 10 Oct 2022 15:07:22 +0530 | ||
4 | Subject: [PATCH 02/54] Add initial port of linux gdbserver add | ||
5 | gdb_proc_service_h to gdbserver microblaze-linux | ||
6 | |||
7 | gdbserver needs to initialise the microblaze registers | ||
8 | |||
9 | other archs use this step to run a *_arch_setup() to carry out all | ||
10 | architecture specific setup - may need to add in future | ||
11 | |||
12 | * add linux-ptrace.o to gdbserver configure | ||
13 | * Update breakpoint opcode | ||
14 | * fix segfault on connecting gdbserver | ||
15 | * add microblaze_linux_memory_remove_breakpoint | ||
16 | * add set_solib_svr4_fetch_link_map_offsets | ||
17 | * add set_gdbarch_fetch_tls_load_module_address | ||
18 | * Force reading of r0 as 0, prevent stores | ||
19 | |||
20 | Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com> | ||
21 | Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com> | ||
22 | Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com> | ||
23 | Signed-off-by: Aayush Misra <aayushm@amd.com> | ||
24 | --- | ||
25 | gdb/configure.host | 2 + | ||
26 | gdb/features/Makefile | 1 + | ||
27 | gdb/features/microblaze-linux.xml | 13 ++ | ||
28 | gdb/microblaze-linux-tdep.c | 29 ++- | ||
29 | gdb/microblaze-tdep.c | 35 +++- | ||
30 | gdb/microblaze-tdep.h | 4 +- | ||
31 | gdb/regformats/microblaze-linux.dat | 64 +++++++ | ||
32 | gdb/regformats/reg-microblaze.dat | 41 +++++ | ||
33 | gdbserver/configure.srv | 10 ++ | ||
34 | gdbserver/linux-microblaze-low.cc | 269 ++++++++++++++++++++++++++++ | ||
35 | 10 files changed, 465 insertions(+), 3 deletions(-) | ||
36 | create mode 100644 gdb/features/microblaze-linux.xml | ||
37 | create mode 100644 gdb/regformats/microblaze-linux.dat | ||
38 | create mode 100644 gdb/regformats/reg-microblaze.dat | ||
39 | create mode 100644 gdbserver/linux-microblaze-low.cc | ||
40 | |||
41 | diff --git a/gdb/configure.host b/gdb/configure.host | ||
42 | index da71675b201..877537d06ef 100644 | ||
43 | --- a/gdb/configure.host | ||
44 | +++ b/gdb/configure.host | ||
45 | @@ -61,6 +61,7 @@ i[34567]86*) gdb_host_cpu=i386 ;; | ||
46 | loongarch*) gdb_host_cpu=loongarch ;; | ||
47 | m68*) gdb_host_cpu=m68k ;; | ||
48 | mips*) gdb_host_cpu=mips ;; | ||
49 | +microblaze*) gdb_host_cpu=microblaze ;; | ||
50 | powerpc* | rs6000) gdb_host_cpu=powerpc ;; | ||
51 | sparcv9 | sparc64) gdb_host_cpu=sparc ;; | ||
52 | s390*) gdb_host_cpu=s390 ;; | ||
53 | @@ -127,6 +128,7 @@ m68*-*-openbsd*) gdb_host=obsd ;; | ||
54 | |||
55 | m88*-*-openbsd*) gdb_host=obsd ;; | ||
56 | |||
57 | +microblaze*-*linux*) gdb_host=linux ;; | ||
58 | mips*-*-linux*) gdb_host=linux ;; | ||
59 | mips*-*-netbsdaout* | mips*-*-knetbsd*-gnu) | ||
60 | gdb_host=nbsd ;; | ||
61 | diff --git a/gdb/features/Makefile b/gdb/features/Makefile | ||
62 | index 32341f71815..0af9d67c2f7 100644 | ||
63 | --- a/gdb/features/Makefile | ||
64 | +++ b/gdb/features/Makefile | ||
65 | @@ -46,6 +46,7 @@ | ||
66 | # List of .dat files to create in ../regformats/ | ||
67 | WHICH = mips-linux mips-dsp-linux \ | ||
68 | mips64-linux mips64-dsp-linux \ | ||
69 | + microblaze-linux \ | ||
70 | nios2-linux \ | ||
71 | or1k-linux \ | ||
72 | rs6000/powerpc-32 \ | ||
73 | diff --git a/gdb/features/microblaze-linux.xml b/gdb/features/microblaze-linux.xml | ||
74 | new file mode 100644 | ||
75 | index 00000000000..688a3f83d1e | ||
76 | --- /dev/null | ||
77 | +++ b/gdb/features/microblaze-linux.xml | ||
78 | @@ -0,0 +1,13 @@ | ||
79 | +<?xml version="1.0"?> | ||
80 | +<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc. | ||
81 | + | ||
82 | + Copying and distribution of this file, with or without modification, | ||
83 | + are permitted in any medium without royalty provided the copyright | ||
84 | + notice and this notice are preserved. --> | ||
85 | + | ||
86 | +<!DOCTYPE target SYSTEM "gdb-target.dtd"> | ||
87 | +<target> | ||
88 | + <architecture>microblaze</architecture> | ||
89 | + <osabi>GNU/Linux</osabi> | ||
90 | + <xi:include href="microblaze-core.xml"/> | ||
91 | +</target> | ||
92 | diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c | ||
93 | index ae33cb5c014..9160b4ad464 100644 | ||
94 | --- a/gdb/microblaze-linux-tdep.c | ||
95 | +++ b/gdb/microblaze-linux-tdep.c | ||
96 | @@ -37,6 +37,22 @@ | ||
97 | #include "tramp-frame.h" | ||
98 | #include "linux-tdep.h" | ||
99 | |||
100 | +static int microblaze_debug_flag = 0; | ||
101 | + | ||
102 | +static void | ||
103 | +microblaze_debug (const char *fmt, ...) | ||
104 | +{ | ||
105 | + if (microblaze_debug_flag) | ||
106 | + { | ||
107 | + va_list args; | ||
108 | + | ||
109 | + va_start (args, fmt); | ||
110 | + printf_unfiltered ("MICROBLAZE LINUX: "); | ||
111 | + vprintf_unfiltered (fmt, args); | ||
112 | + va_end (args); | ||
113 | + } | ||
114 | +} | ||
115 | + | ||
116 | static int | ||
117 | microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch, | ||
118 | struct bp_target_info *bp_tgt) | ||
119 | @@ -50,13 +66,20 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch, | ||
120 | /* Determine appropriate breakpoint contents and size for this address. */ | ||
121 | bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen); | ||
122 | |||
123 | + /* Make sure we see the memory breakpoints. */ | ||
124 | + scoped_restore restore_memory | ||
125 | + = make_scoped_restore_show_memory_breakpoints (1); | ||
126 | + | ||
127 | val = target_read_memory (addr, old_contents, bplen); | ||
128 | |||
129 | /* If our breakpoint is no longer at the address, this means that the | ||
130 | program modified the code on us, so it is wrong to put back the | ||
131 | old value. */ | ||
132 | if (val == 0 && memcmp (bp, old_contents, bplen) == 0) | ||
133 | - val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen); | ||
134 | + { | ||
135 | + val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen); | ||
136 | + microblaze_debug ("microblaze_linux_memory_remove_breakpoint writing back to memory at addr 0x%lx\n", addr); | ||
137 | + } | ||
138 | |||
139 | return val; | ||
140 | } | ||
141 | @@ -129,6 +152,10 @@ microblaze_linux_init_abi (struct gdbarch_info info, | ||
142 | /* Trampolines. */ | ||
143 | tramp_frame_prepend_unwinder (gdbarch, | ||
144 | µblaze_linux_sighandler_tramp_frame); | ||
145 | + | ||
146 | + /* Enable TLS support. */ | ||
147 | + set_gdbarch_fetch_tls_load_module_address (gdbarch, | ||
148 | + svr4_fetch_objfile_link_map); | ||
149 | } | ||
150 | |||
151 | void _initialize_microblaze_linux_tdep (); | ||
152 | diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c | ||
153 | index f254a54305c..28a647e940b 100644 | ||
154 | --- a/gdb/microblaze-tdep.c | ||
155 | +++ b/gdb/microblaze-tdep.c | ||
156 | @@ -128,7 +128,38 @@ microblaze_fetch_instruction (CORE_ADDR pc) | ||
157 | constexpr gdb_byte microblaze_break_insn[] = MICROBLAZE_BREAKPOINT; | ||
158 | |||
159 | typedef BP_MANIPULATION (microblaze_break_insn) microblaze_breakpoint; | ||
160 | - | ||
161 | +static int | ||
162 | +microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch, | ||
163 | + struct bp_target_info *bp_tgt) | ||
164 | +{ | ||
165 | + CORE_ADDR addr = bp_tgt->placed_address; | ||
166 | + const unsigned char *bp; | ||
167 | + int val; | ||
168 | + int bplen; | ||
169 | + gdb_byte old_contents[BREAKPOINT_MAX]; | ||
170 | + | ||
171 | + /* Determine appropriate breakpoint contents and size for this address. */ | ||
172 | + bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen); | ||
173 | + if (bp == NULL) | ||
174 | + error (_("Software breakpoints not implemented for this target.")); | ||
175 | + | ||
176 | + /* Make sure we see the memory breakpoints. */ | ||
177 | + scoped_restore restore_memory | ||
178 | + = make_scoped_restore_show_memory_breakpoints (1); | ||
179 | + | ||
180 | + val = target_read_memory (addr, old_contents, bplen); | ||
181 | + | ||
182 | + /* If our breakpoint is no longer at the address, this means that the | ||
183 | + program modified the code on us, so it is wrong to put back the | ||
184 | + old value. */ | ||
185 | + if (val == 0 && memcmp (bp, old_contents, bplen) == 0) | ||
186 | + { | ||
187 | + val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen); | ||
188 | + microblaze_debug ("microblaze_linux_memory_remove_breakpoint writing back to memory at addr 0x%lx\n", addr); | ||
189 | + } | ||
190 | + | ||
191 | + return val; | ||
192 | +} | ||
193 | |||
194 | /* Allocate and initialize a frame cache. */ | ||
195 | |||
196 | @@ -714,6 +745,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
197 | microblaze_breakpoint::kind_from_pc); | ||
198 | set_gdbarch_sw_breakpoint_from_kind (gdbarch, | ||
199 | microblaze_breakpoint::bp_from_kind); | ||
200 | + set_gdbarch_memory_remove_breakpoint (gdbarch, microblaze_linux_memory_remove_breakpoint); | ||
201 | |||
202 | set_gdbarch_frame_args_skip (gdbarch, 8); | ||
203 | |||
204 | @@ -754,4 +786,5 @@ When non-zero, microblaze specific debugging is enabled."), | ||
205 | NULL, | ||
206 | &setdebuglist, &showdebuglist); | ||
207 | |||
208 | + | ||
209 | } | ||
210 | diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h | ||
211 | index 892e5b3b849..e9f57e97c26 100644 | ||
212 | --- a/gdb/microblaze-tdep.h | ||
213 | +++ b/gdb/microblaze-tdep.h | ||
214 | @@ -118,6 +118,8 @@ struct microblaze_frame_cache | ||
215 | |||
216 | /* MICROBLAZE_BREAKPOINT defines the breakpoint that should be used. | ||
217 | Only used for native debugging. */ | ||
218 | -#define MICROBLAZE_BREAKPOINT {0xb9, 0xcc, 0x00, 0x60} | ||
219 | +#define MICROBLAZE_BREAKPOINT {0xba, 0x0c, 0x00, 0x18} | ||
220 | +#define MICROBLAZE_BREAKPOINT_LE {0x18, 0x00, 0x0c, 0xba} | ||
221 | + | ||
222 | |||
223 | #endif /* microblaze-tdep.h */ | ||
224 | diff --git a/gdb/regformats/microblaze-linux.dat b/gdb/regformats/microblaze-linux.dat | ||
225 | new file mode 100644 | ||
226 | index 00000000000..b5b49f485cd | ||
227 | --- /dev/null | ||
228 | +++ b/gdb/regformats/microblaze-linux.dat | ||
229 | @@ -0,0 +1,64 @@ | ||
230 | +# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro: | ||
231 | +# Generated from: microblaze-linux.xml | ||
232 | +name:microblaze_linux | ||
233 | +xmltarget:microblaze-linux.xml | ||
234 | +expedite:r1,rpc | ||
235 | +32:r0 | ||
236 | +32:r1 | ||
237 | +32:r2 | ||
238 | +32:r3 | ||
239 | +32:r4 | ||
240 | +32:r5 | ||
241 | +32:r6 | ||
242 | +32:r7 | ||
243 | +32:r8 | ||
244 | +32:r9 | ||
245 | +32:r10 | ||
246 | +32:r11 | ||
247 | +32:r12 | ||
248 | +32:r13 | ||
249 | +32:r14 | ||
250 | +32:r15 | ||
251 | +32:r16 | ||
252 | +32:r17 | ||
253 | +32:r18 | ||
254 | +32:r19 | ||
255 | +32:r20 | ||
256 | +32:r21 | ||
257 | +32:r22 | ||
258 | +32:r23 | ||
259 | +32:r24 | ||
260 | +32:r25 | ||
261 | +32:r26 | ||
262 | +32:r27 | ||
263 | +32:r28 | ||
264 | +32:r29 | ||
265 | +32:r30 | ||
266 | +32:r31 | ||
267 | +32:rpc | ||
268 | +32:rmsr | ||
269 | +32:rear | ||
270 | +32:resr | ||
271 | +32:rfsr | ||
272 | +32:rbtr | ||
273 | +32:rpvr0 | ||
274 | +32:rpvr1 | ||
275 | +32:rpvr2 | ||
276 | +32:rpvr3 | ||
277 | +32:rpvr4 | ||
278 | +32:rpvr5 | ||
279 | +32:rpvr6 | ||
280 | +32:rpvr7 | ||
281 | +32:rpvr8 | ||
282 | +32:rpvr9 | ||
283 | +32:rpvr10 | ||
284 | +32:rpvr11 | ||
285 | +32:redr | ||
286 | +32:rpid | ||
287 | +32:rzpr | ||
288 | +32:rtlbx | ||
289 | +32:rtlbsx | ||
290 | +32:rtlblo | ||
291 | +32:rtlbhi | ||
292 | +32:slr | ||
293 | +32:shr | ||
294 | diff --git a/gdb/regformats/reg-microblaze.dat b/gdb/regformats/reg-microblaze.dat | ||
295 | new file mode 100644 | ||
296 | index 00000000000..bd8a4384424 | ||
297 | --- /dev/null | ||
298 | +++ b/gdb/regformats/reg-microblaze.dat | ||
299 | @@ -0,0 +1,41 @@ | ||
300 | +name:microblaze | ||
301 | +expedite:r1,pc | ||
302 | +32:r0 | ||
303 | +32:r1 | ||
304 | +32:r2 | ||
305 | +32:r3 | ||
306 | +32:r4 | ||
307 | +32:r5 | ||
308 | +32:r6 | ||
309 | +32:r7 | ||
310 | +32:r8 | ||
311 | +32:r9 | ||
312 | +32:r10 | ||
313 | +32:r11 | ||
314 | +32:r12 | ||
315 | +32:r13 | ||
316 | +32:r14 | ||
317 | +32:r15 | ||
318 | +32:r16 | ||
319 | +32:r17 | ||
320 | +32:r18 | ||
321 | +32:r19 | ||
322 | +32:r20 | ||
323 | +32:r21 | ||
324 | +32:r22 | ||
325 | +32:r23 | ||
326 | +32:r24 | ||
327 | +32:r25 | ||
328 | +32:r26 | ||
329 | +32:r27 | ||
330 | +32:r28 | ||
331 | +32:r29 | ||
332 | +32:r30 | ||
333 | +32:r31 | ||
334 | +32:pc | ||
335 | +32:msr | ||
336 | +32:ear | ||
337 | +32:esr | ||
338 | +32:fsr | ||
339 | +32:slr | ||
340 | +32:shr | ||
341 | diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv | ||
342 | index 9e861a75088..11ce617e72f 100644 | ||
343 | --- a/gdbserver/configure.srv | ||
344 | +++ b/gdbserver/configure.srv | ||
345 | @@ -159,6 +159,16 @@ case "${gdbserver_host}" in | ||
346 | srv_linux_regsets=yes | ||
347 | srv_linux_thread_db=yes | ||
348 | ;; | ||
349 | + | ||
350 | +microblaze*-*-linux*) srv_regobj="microblaze-linux.o" | ||
351 | + srv_tgtobj="$srv_linux_obj linux-microblaze-low.o" | ||
352 | + srv_xmlfiles="microblaze-linux.xml" | ||
353 | + srv_xmlfiles="${srv_xmlfiles} microblaze-core.xml" | ||
354 | + srv_linux_usrregs=yes | ||
355 | + srv_linux_regsets=yes | ||
356 | + srv_linux_thread_db=yes | ||
357 | + ;; | ||
358 | + | ||
359 | mips*-*-linux*) srv_regobj="mips-linux.o" | ||
360 | srv_regobj="${srv_regobj} mips-dsp-linux.o" | ||
361 | srv_regobj="${srv_regobj} mips64-linux.o" | ||
362 | diff --git a/gdbserver/linux-microblaze-low.cc b/gdbserver/linux-microblaze-low.cc | ||
363 | new file mode 100644 | ||
364 | index 00000000000..bf9eecc41ab | ||
365 | --- /dev/null | ||
366 | +++ b/gdbserver/linux-microblaze-low.cc | ||
367 | @@ -0,0 +1,269 @@ | ||
368 | +/* GNU/Linux/Microblaze specific low level interface, for the remote server for | ||
369 | + GDB. | ||
370 | + Copyright (C) 1995-2013 Free Software Foundation, Inc. | ||
371 | + | ||
372 | + This file is part of GDB. | ||
373 | + | ||
374 | + This program is free software; you can redistribute it and/or modify | ||
375 | + it under the terms of the GNU General Public License as published by | ||
376 | + the Free Software Foundation; either version 3 of the License, or | ||
377 | + (at your option) any later version. | ||
378 | + | ||
379 | + This program is distributed in the hope that it will be useful, | ||
380 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
381 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
382 | + GNU General Public License for more details. | ||
383 | + | ||
384 | + You should have received a copy of the GNU General Public License | ||
385 | + along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
386 | + | ||
387 | +#include "server.h" | ||
388 | +#include "linux-low.h" | ||
389 | + | ||
390 | +#include "elf/common.h" | ||
391 | +#include "nat/gdb_ptrace.h" | ||
392 | +#include <endian.h> | ||
393 | + | ||
394 | +#include <asm/ptrace.h> | ||
395 | +#include <sys/procfs.h> | ||
396 | +#include <sys/ptrace.h> | ||
397 | + | ||
398 | +#include "gdb_proc_service.h" | ||
399 | + | ||
400 | + | ||
401 | +static int microblaze_regmap[] = | ||
402 | + {PT_GPR(0), PT_GPR(1), PT_GPR(2), PT_GPR(3), | ||
403 | + PT_GPR(4), PT_GPR(5), PT_GPR(6), PT_GPR(7), | ||
404 | + PT_GPR(8), PT_GPR(9), PT_GPR(10), PT_GPR(11), | ||
405 | + PT_GPR(12), PT_GPR(13), PT_GPR(14), PT_GPR(15), | ||
406 | + PT_GPR(16), PT_GPR(17), PT_GPR(18), PT_GPR(19), | ||
407 | + PT_GPR(20), PT_GPR(21), PT_GPR(22), PT_GPR(23), | ||
408 | + PT_GPR(24), PT_GPR(25), PT_GPR(26), PT_GPR(27), | ||
409 | + PT_GPR(28), PT_GPR(29), PT_GPR(30), PT_GPR(31), | ||
410 | + PT_PC, PT_MSR, PT_EAR, PT_ESR, | ||
411 | + PT_FSR | ||
412 | + }; | ||
413 | + | ||
414 | + | ||
415 | + | ||
416 | +class microblaze_target : public linux_process_target | ||
417 | +{ | ||
418 | +public: | ||
419 | + | ||
420 | + const regs_info *get_regs_info () override; | ||
421 | + | ||
422 | + const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override; | ||
423 | + // CORE_ADDR microblaze_reinsert_addr (regcache *regcache); | ||
424 | + | ||
425 | +protected: | ||
426 | + | ||
427 | + void low_arch_setup () override; | ||
428 | + | ||
429 | + bool low_cannot_fetch_register (int regno) override; | ||
430 | + | ||
431 | + bool low_cannot_store_register (int regno) override; | ||
432 | + | ||
433 | + // bool low_supports_breakpoints () override; | ||
434 | + | ||
435 | + CORE_ADDR low_get_pc (regcache *regcache) override; | ||
436 | + | ||
437 | + void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; | ||
438 | + | ||
439 | + bool low_breakpoint_at (CORE_ADDR pc) override; | ||
440 | +}; | ||
441 | + | ||
442 | +/* The singleton target ops object. */ | ||
443 | + | ||
444 | +static microblaze_target the_microblaze_target; | ||
445 | + | ||
446 | +#define microblaze_num_regs (sizeof (microblaze_regmap) / sizeof (microblaze_regmap[0])) | ||
447 | + | ||
448 | +/* Defined in auto-generated file microblaze-linux.c. */ | ||
449 | +void init_registers_microblaze_linux (void); | ||
450 | +extern const struct target_desc *tdesc_microblaze_linux; | ||
451 | + | ||
452 | +bool | ||
453 | +microblaze_target::low_cannot_store_register (int regno) | ||
454 | +{ | ||
455 | + if (microblaze_regmap[regno] == -1 || regno == 0) | ||
456 | + return 1; | ||
457 | + | ||
458 | + return 0; | ||
459 | +} | ||
460 | + | ||
461 | +bool | ||
462 | +microblaze_target::low_cannot_fetch_register (int regno) | ||
463 | +{ | ||
464 | + return 0; | ||
465 | +} | ||
466 | + | ||
467 | +CORE_ADDR | ||
468 | +microblaze_target::low_get_pc (struct regcache *regcache) | ||
469 | +{ | ||
470 | + unsigned long pc; | ||
471 | + | ||
472 | + collect_register_by_name (regcache, "pc", &pc); | ||
473 | + return (CORE_ADDR) pc; | ||
474 | +} | ||
475 | + | ||
476 | +void | ||
477 | +microblaze_target::low_set_pc (struct regcache *regcache, CORE_ADDR pc) | ||
478 | +{ | ||
479 | + unsigned long newpc = pc; | ||
480 | + | ||
481 | + supply_register_by_name (regcache, "pc", &newpc); | ||
482 | +} | ||
483 | + | ||
484 | +/* dbtrap insn */ | ||
485 | +/* brki r16, 0x18; */ | ||
486 | +static const unsigned long microblaze_breakpoint = 0xba0c0018; | ||
487 | +#define microblaze_breakpoint_len 4 | ||
488 | + | ||
489 | +/* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */ | ||
490 | + | ||
491 | +const gdb_byte * | ||
492 | +microblaze_target::sw_breakpoint_from_kind (int kind, int *size) | ||
493 | +{ | ||
494 | + *size = microblaze_breakpoint_len; | ||
495 | + return (const gdb_byte *) µblaze_breakpoint; | ||
496 | +} | ||
497 | + | ||
498 | +bool | ||
499 | +microblaze_target::low_breakpoint_at (CORE_ADDR where) | ||
500 | +{ | ||
501 | + unsigned long insn; | ||
502 | + | ||
503 | + read_memory (where, (unsigned char *) &insn, 4); | ||
504 | + if (insn == microblaze_breakpoint) | ||
505 | + return 1; | ||
506 | + /* If necessary, recognize more trap instructions here. GDB only uses the | ||
507 | + one. */ | ||
508 | + return 0; | ||
509 | +} | ||
510 | +#if 0 | ||
511 | +CORE_ADDR | ||
512 | +microblaze_target::microblaze_reinsert_addr (struct regcache *regcache) | ||
513 | +{ | ||
514 | + unsigned long pc; | ||
515 | + collect_register_by_name (regcache, "r15", &pc); | ||
516 | + return pc; | ||
517 | +} | ||
518 | +#endif | ||
519 | +#if 0 | ||
520 | +#ifdef HAVE_PTRACE_GETREGS | ||
521 | + | ||
522 | +static void | ||
523 | +microblaze_collect_ptrace_register (struct regcache *regcache, int regno, char *buf) | ||
524 | +{ | ||
525 | + int size = register_size (regcache->tdesc, regno); | ||
526 | + | ||
527 | + memset (buf, 0, sizeof (long)); | ||
528 | + | ||
529 | + if (size < sizeof (long)) | ||
530 | + collect_register (regcache, regno, buf + sizeof (long) - size); | ||
531 | + else | ||
532 | + collect_register (regcache, regno, buf); | ||
533 | +} | ||
534 | + | ||
535 | +static void | ||
536 | +microblaze_supply_ptrace_register (struct regcache *regcache, | ||
537 | + int regno, const char *buf) | ||
538 | +{ | ||
539 | + int size = register_size (regcache->tdesc, regno); | ||
540 | + | ||
541 | + if (regno == 0) { | ||
542 | + unsigned long regbuf_0 = 0; | ||
543 | + /* clobbering r0 so that it is always 0 as enforced by hardware */ | ||
544 | + supply_register (regcache, regno, (const char*)®buf_0); | ||
545 | + } else { | ||
546 | + if (size < sizeof (long)) | ||
547 | + supply_register (regcache, regno, buf + sizeof (long) - size); | ||
548 | + else | ||
549 | + supply_register (regcache, regno, buf); | ||
550 | + } | ||
551 | +} | ||
552 | + | ||
553 | +/* Provide only a fill function for the general register set. ps_lgetregs | ||
554 | + will use this for NPTL support. */ | ||
555 | + | ||
556 | +static void microblaze_fill_gregset (struct regcache *regcache, void *buf) | ||
557 | +{ | ||
558 | + int i; | ||
559 | + | ||
560 | + for (i = 0; i < 32; i++) | ||
561 | + microblaze_collect_ptrace_register (regcache, i, (char *) buf + microblaze_regmap[i]); | ||
562 | +} | ||
563 | + | ||
564 | +static void | ||
565 | +microblaze_store_gregset (struct regcache *regcache, const void *buf) | ||
566 | +{ | ||
567 | + int i; | ||
568 | + | ||
569 | + for (i = 0; i < 32; i++) | ||
570 | + supply_register (regcache, i, (char *) buf + microblaze_regmap[i]); | ||
571 | +} | ||
572 | + | ||
573 | +#endif /* HAVE_PTRACE_GETREGS */ | ||
574 | +#endif | ||
575 | + | ||
576 | +static struct regset_info microblaze_regsets[] = { | ||
577 | +#if 0 | ||
578 | +#ifdef HAVE_PTRACE_GETREGS | ||
579 | + { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS, microblaze_fill_gregset, microblaze_store_gregset }, | ||
580 | + { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL }, | ||
581 | +#endif /* HAVE_PTRACE_GETREGS */ | ||
582 | +#endif | ||
583 | + { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL }, | ||
584 | + NULL_REGSET | ||
585 | +}; | ||
586 | + | ||
587 | +static struct usrregs_info microblaze_usrregs_info = | ||
588 | + { | ||
589 | + microblaze_num_regs, | ||
590 | + microblaze_regmap, | ||
591 | + }; | ||
592 | + | ||
593 | +static struct regsets_info microblaze_regsets_info = | ||
594 | + { | ||
595 | + microblaze_regsets, /* regsets */ | ||
596 | + 0, /* num_regsets */ | ||
597 | + NULL, /* disabled_regsets */ | ||
598 | + }; | ||
599 | + | ||
600 | +static struct regs_info microblaze_regs_info = | ||
601 | + { | ||
602 | + NULL, /* regset_bitmap */ | ||
603 | + µblaze_usrregs_info, | ||
604 | + µblaze_regsets_info | ||
605 | + }; | ||
606 | + | ||
607 | +const regs_info * | ||
608 | +microblaze_target::get_regs_info (void) | ||
609 | +{ | ||
610 | + return µblaze_regs_info; | ||
611 | +} | ||
612 | + | ||
613 | +/* Support for hardware single step. */ | ||
614 | + | ||
615 | +static int | ||
616 | +microblaze_supports_hardware_single_step (void) | ||
617 | +{ | ||
618 | + return 1; | ||
619 | +} | ||
620 | + | ||
621 | + | ||
622 | +void | ||
623 | +microblaze_target::low_arch_setup (void) | ||
624 | +{ | ||
625 | + current_process ()->tdesc = tdesc_microblaze_linux; | ||
626 | +} | ||
627 | + | ||
628 | +linux_process_target *the_linux_target = &the_microblaze_target; | ||
629 | + | ||
630 | +void | ||
631 | +initialize_low_arch (void) | ||
632 | +{ | ||
633 | + init_registers_microblaze_linux (); | ||
634 | + initialize_regsets_info (µblaze_regsets_info); | ||
635 | +} | ||
636 | + | ||
637 | -- | ||
638 | 2.34.1 | ||
639 | |||