GDB (xrefs)
Loading...
Searching...
No Matches
m68k-tdep.c
Go to the documentation of this file.
1/* Target-dependent code for the Motorola 68000 series.
2
3 Copyright (C) 1990-2023 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
21#include "dwarf2/frame.h"
22#include "frame.h"
23#include "frame-base.h"
24#include "frame-unwind.h"
25#include "gdbtypes.h"
26#include "symtab.h"
27#include "gdbcore.h"
28#include "value.h"
29#include "inferior.h"
30#include "regcache.h"
31#include "arch-utils.h"
32#include "osabi.h"
33#include "dis-asm.h"
34#include "target-descriptions.h"
35#include "floatformat.h"
36#include "target-float.h"
37#include "elf-bfd.h"
38#include "elf/m68k.h"
39
40#include "m68k-tdep.h"
41
42
43#define P_LINKL_FP 0x480e
44#define P_LINKW_FP 0x4e56
45#define P_PEA_FP 0x4856
46#define P_MOVEAL_SP_FP 0x2c4f
47#define P_ADDAW_SP 0xdefc
48#define P_ADDAL_SP 0xdffc
49#define P_SUBQW_SP 0x514f
50#define P_SUBQL_SP 0x518f
51#define P_LEA_SP_SP 0x4fef
52#define P_LEA_PC_A5 0x4bfb0170
53#define P_FMOVEMX_SP 0xf227
54#define P_MOVEL_SP 0x2f00
55#define P_MOVEML_SP 0x48e7
56
57/* Offset from SP to first arg on stack at first instruction of a function. */
58#define SP_ARG0 (1 * 4)
59
60#if !defined (BPT_VECTOR)
61#define BPT_VECTOR 0xf
62#endif
63
64constexpr gdb_byte m68k_break_insn[] = {0x4e, (0x40 | BPT_VECTOR)};
65
66typedef BP_MANIPULATION (m68k_break_insn) m68k_breakpoint;
67
68
69/* Construct types for ISA-specific registers. */
70static struct type *
71m68k_ps_type (struct gdbarch *gdbarch)
72{
73 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
74
75 if (!tdep->m68k_ps_type)
76 {
77 struct type *type;
78
79 type = arch_flags_type (gdbarch, "builtin_type_m68k_ps", 32);
87 append_flags_type_flag (type, 10, "I2");
90 append_flags_type_flag (type, 14, "T0");
91 append_flags_type_flag (type, 15, "T1");
92
93 tdep->m68k_ps_type = type;
94 }
95
96 return tdep->m68k_ps_type;
97}
98
99static struct type *
101{
102 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
103
104 if (!tdep->m68881_ext_type)
105 {
106 type_allocator alloc (gdbarch);
107 tdep->m68881_ext_type
108 = init_float_type (alloc, -1, "builtin_type_m68881_ext",
110 }
111
112 return tdep->m68881_ext_type;
113}
114
115/* Return the GDB type object for the "standard" data type of data in
116 register N. This should be int for D0-D7, SR, FPCONTROL and
117 FPSTATUS, long double for FP0-FP7, and void pointer for all others
118 (A0-A7, PC, FPIADDR). Note, for registers which contain
119 addresses return pointer to void, not pointer to char, because we
120 don't want to attempt to print the string after printing the
121 address. */
122
123static struct type *
125{
126 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
127
128 if (tdep->fpregs_present)
129 {
132 {
133 if (tdep->flavour == m68k_coldfire_flavour)
135 else
136 return m68881_ext_type (gdbarch);
137 }
138
139 if (regnum == M68K_FPI_REGNUM)
141
144 }
145 else
146 {
149 }
150
153
156
157 if (regnum == M68K_PS_REGNUM)
158 return m68k_ps_type (gdbarch);
159
161}
162
163static const char * const m68k_register_names[] = {
164 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
165 "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp",
166 "ps", "pc",
167 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
168 "fpcontrol", "fpstatus", "fpiaddr"
169 };
170
171/* Function: m68k_register_name
172 Returns the name of the standard m68k register regnum. */
173
174static const char *
176{
177 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
178
181 && tdep->fpregs_present == 0)
182 return "";
183 else
185}
186
187/* Return nonzero if a value of type TYPE stored in register REGNUM
188 needs any special handling. */
189
190static int
192 int regnum, struct type *type)
193{
194 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
195
196 if (!tdep->fpregs_present)
197 return 0;
198 return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FP0_REGNUM + 7
199 /* We only support floating-point values. */
200 && type->code () == TYPE_CODE_FLT
202}
203
204/* Read a value of type TYPE from register REGNUM in frame FRAME, and
205 return its contents in TO. */
206
207static int
209 struct type *type, gdb_byte *to,
210 int *optimizedp, int *unavailablep)
211{
212 struct gdbarch *gdbarch = get_frame_arch (frame);
213 gdb_byte from[M68K_MAX_REGISTER_SIZE];
214 struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM);
215
216 gdb_assert (type->code () == TYPE_CODE_FLT);
217
218 /* Convert to TYPE. */
219 if (!get_frame_register_bytes (frame, regnum, 0,
220 gdb::make_array_view (from,
222 regnum)),
223 optimizedp, unavailablep))
224 return 0;
225
226 target_float_convert (from, fpreg_type, to, type);
227 *optimizedp = *unavailablep = 0;
228 return 1;
229}
230
231/* Write the contents FROM of a value of type TYPE into register
232 REGNUM in frame FRAME. */
233
234static void
236 struct type *type, const gdb_byte *from)
237{
238 gdb_byte to[M68K_MAX_REGISTER_SIZE];
239 struct type *fpreg_type = register_type (get_frame_arch (frame),
241
242 /* We only support floating-point values. */
243 if (type->code () != TYPE_CODE_FLT)
244 {
245 warning (_("Cannot convert non-floating-point type "
246 "to floating-point register value."));
247 return;
248 }
249
250 /* Convert from TYPE. */
251 target_float_convert (from, type, to, fpreg_type);
252 put_frame_register (frame, regnum, to);
253}
254
255
256/* There is a fair number of calling conventions that are in somewhat
257 wide use. The 68000/08/10 don't support an FPU, not even as a
258 coprocessor. All function return values are stored in %d0/%d1.
259 Structures are returned in a static buffer, a pointer to which is
260 returned in %d0. This means that functions returning a structure
261 are not re-entrant. To avoid this problem some systems use a
262 convention where the caller passes a pointer to a buffer in %a1
263 where the return values is to be stored. This convention is the
264 default, and is implemented in the function m68k_return_value.
265
266 The 68020/030/040/060 do support an FPU, either as a coprocessor
267 (68881/2) or built-in (68040/68060). That's why System V release 4
268 (SVR4) introduces a new calling convention specified by the SVR4
269 psABI. Integer values are returned in %d0/%d1, pointer return
270 values in %a0 and floating values in %fp0. When calling functions
271 returning a structure the caller should pass a pointer to a buffer
272 for the return value in %a0. This convention is implemented in the
273 function m68k_svr4_return_value, and by appropriately setting the
274 struct_value_regnum member of `struct gdbarch_tdep'.
275
276 GNU/Linux returns values in the same way as SVR4 does, but uses %a1
277 for passing the structure return value buffer.
278
279 GCC can also generate code where small structures are returned in
280 %d0/%d1 instead of in memory by using -freg-struct-return. This is
281 the default on NetBSD a.out, OpenBSD and GNU/Linux and several
282 embedded systems. This convention is implemented by setting the
283 struct_return member of `struct gdbarch_tdep' to reg_struct_return.
284
285 GCC also has an "embedded" ABI. This works like the SVR4 ABI,
286 except that pointers are returned in %D0. This is implemented by
287 setting the pointer_result_regnum member of `struct gdbarch_tdep'
288 as appropriate. */
289
290/* Read a function return value of TYPE from REGCACHE, and copy that
291 into VALBUF. */
292
293static void
295 gdb_byte *valbuf)
296{
297 int len = type->length ();
298 gdb_byte buf[M68K_MAX_REGISTER_SIZE];
299
300 if (type->code () == TYPE_CODE_PTR && len == 4)
301 {
302 struct gdbarch *gdbarch = regcache->arch ();
303 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
304 regcache->raw_read (tdep->pointer_result_regnum, valbuf);
305 }
306 else if (len <= 4)
307 {
309 memcpy (valbuf, buf + (4 - len), len);
310 }
311 else if (len <= 8)
312 {
314 memcpy (valbuf, buf + (8 - len), len - 4);
315 regcache->raw_read (M68K_D1_REGNUM, valbuf + (len - 4));
316 }
317 else
318 internal_error (_("Cannot extract return value of %d bytes long."), len);
319}
320
321static void
323 gdb_byte *valbuf)
324{
325 gdb_byte buf[M68K_MAX_REGISTER_SIZE];
326 struct gdbarch *gdbarch = regcache->arch ();
327 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
328
329 if (tdep->float_return && type->code () == TYPE_CODE_FLT)
330 {
331 struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM);
333 target_float_convert (buf, fpreg_type, valbuf, type);
334 }
335 else
337}
338
339/* Write a function return value of TYPE from VALBUF into REGCACHE. */
340
341static void
343 const gdb_byte *valbuf)
344{
345 int len = type->length ();
346
347 if (type->code () == TYPE_CODE_PTR && len == 4)
348 {
349 struct gdbarch *gdbarch = regcache->arch ();
350 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
352 /* gdb historically also set D0 in the SVR4 case. */
355 }
356 else if (len <= 4)
357 regcache->raw_write_part (M68K_D0_REGNUM, 4 - len, len, valbuf);
358 else if (len <= 8)
359 {
360 regcache->raw_write_part (M68K_D0_REGNUM, 8 - len, len - 4, valbuf);
361 regcache->raw_write (M68K_D1_REGNUM, valbuf + (len - 4));
362 }
363 else
364 internal_error (_("Cannot store return value of %d bytes long."), len);
365}
366
367static void
369 const gdb_byte *valbuf)
370{
371 struct gdbarch *gdbarch = regcache->arch ();
372 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
373
374 if (tdep->float_return && type->code () == TYPE_CODE_FLT)
375 {
376 struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM);
377 gdb_byte buf[M68K_MAX_REGISTER_SIZE];
378 target_float_convert (valbuf, type, buf, fpreg_type);
380 }
381 else
383}
384
385/* Return non-zero if TYPE, which is assumed to be a structure, union or
386 complex type, should be returned in registers for architecture
387 GDBARCH. */
388
389static int
391{
392 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
393 enum type_code code = type->code ();
394 int len = type->length ();
395
396 gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
397 || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY);
398
399 if (tdep->struct_return == pcc_struct_return)
400 return 0;
401
402 const bool is_vector = code == TYPE_CODE_ARRAY && type->is_vector ();
403
404 if (is_vector
405 && check_typedef (type->target_type ())->code () == TYPE_CODE_FLT)
406 return 0;
407
408 /* According to m68k_return_in_memory in the m68k GCC back-end,
409 strange things happen for small aggregate types. Aggregate types
410 with only one component are always returned like the type of the
411 component. Aggregate types whose size is 2, 4, or 8 are returned
412 in registers if their natural alignment is at least 16 bits.
413
414 We reject vectors here, as experimentally this gives the correct
415 answer. */
416 if (!is_vector && (len == 2 || len == 4 || len == 8))
417 return type_align (type) >= 2;
418
419 return (len == 1 || len == 2 || len == 4 || len == 8);
420}
421
422/* Determine, for architecture GDBARCH, how a return value of TYPE
423 should be returned. If it is supposed to be returned in registers,
424 and READBUF is non-zero, read the appropriate value from REGCACHE,
425 and copy it into READBUF. If WRITEBUF is non-zero, write the value
426 from WRITEBUF into REGCACHE. */
427
428static enum return_value_convention
429m68k_return_value (struct gdbarch *gdbarch, struct value *function,
430 struct type *type, struct regcache *regcache,
431 gdb_byte *readbuf, const gdb_byte *writebuf)
432{
433 enum type_code code = type->code ();
434
435 /* GCC returns a `long double' in memory too. */
436 if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
437 || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY)
439 || (code == TYPE_CODE_FLT && type->length () == 12))
440 {
441 /* The default on m68k is to return structures in static memory.
442 Consequently a function must return the address where we can
443 find the return value. */
444
445 if (readbuf)
446 {
447 ULONGEST addr;
448
450 read_memory (addr, readbuf, type->length ());
451 }
452
454 }
455
456 if (readbuf)
458 if (writebuf)
460
462}
463
464static enum return_value_convention
465m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function,
466 struct type *type, struct regcache *regcache,
467 gdb_byte *readbuf, const gdb_byte *writebuf)
468{
469 enum type_code code = type->code ();
470 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
471
472 /* Aggregates with a single member are always returned like their
473 sole element. */
474 if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
475 && type->num_fields () == 1)
476 {
477 type = check_typedef (type->field (0).type ());
478 return m68k_svr4_return_value (gdbarch, function, type, regcache,
479 readbuf, writebuf);
480 }
481
482 if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
483 || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY)
485 /* GCC may return a `long double' in memory too. */
486 || (!tdep->float_return
487 && code == TYPE_CODE_FLT
488 && type->length () == 12))
489 {
490 /* The System V ABI says that:
491
492 "A function returning a structure or union also sets %a0 to
493 the value it finds in %a0. Thus when the caller receives
494 control again, the address of the returned object resides in
495 register %a0."
496
497 So the ABI guarantees that we can always find the return
498 value just after the function has returned.
499
500 However, GCC also implements the "embedded" ABI. That ABI
501 does not preserve %a0 across calls, but does write the value
502 back to %d0. */
503
504 if (readbuf)
505 {
506 ULONGEST addr;
507
509 &addr);
510 read_memory (addr, readbuf, type->length ());
511 }
512
514 }
515
516 if (readbuf)
518 if (writebuf)
520
522}
523
524
525/* Always align the frame to a 4-byte boundary. This is required on
526 coldfire and harmless on the rest. */
527
528static CORE_ADDR
529m68k_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
530{
531 /* Align the stack to four bytes. */
532 return sp & ~3;
533}
534
535static CORE_ADDR
536m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
537 struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
538 struct value **args, CORE_ADDR sp,
539 function_call_return_method return_method,
540 CORE_ADDR struct_addr)
541{
542 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
543 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
544 gdb_byte buf[4];
545 int i;
546
547 /* Push arguments in reverse order. */
548 for (i = nargs - 1; i >= 0; i--)
549 {
550 struct type *value_type = args[i]->enclosing_type ();
551 int len = value_type->length ();
552 int container_len = (len + 3) & ~3;
553 int offset;
554
555 /* Non-scalars bigger than 4 bytes are left aligned, others are
556 right aligned. */
557 if ((value_type->code () == TYPE_CODE_STRUCT
558 || value_type->code () == TYPE_CODE_UNION
559 || value_type->code () == TYPE_CODE_ARRAY)
560 && len > 4)
561 offset = 0;
562 else
563 offset = container_len - len;
564 sp -= container_len;
565 write_memory (sp + offset, args[i]->contents_all ().data (), len);
566 }
567
568 /* Store struct value address. */
569 if (return_method == return_method_struct)
570 {
571 store_unsigned_integer (buf, 4, byte_order, struct_addr);
573 }
574
575 /* Store return address. */
576 sp -= 4;
577 store_unsigned_integer (buf, 4, byte_order, bp_addr);
578 write_memory (sp, buf, 4);
579
580 /* Finally, update the stack pointer... */
581 store_unsigned_integer (buf, 4, byte_order, sp);
583
584 /* ...and fake a frame pointer. */
586
587 /* DWARF2/GCC uses the stack address *before* the function call as a
588 frame's CFA. */
589 return sp + 8;
590}
591
592/* Convert a dwarf or dwarf2 regnumber to a GDB regnum. */
593
594static int
596{
597 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
598
599 if (num < 8)
600 /* d0..7 */
601 return (num - 0) + M68K_D0_REGNUM;
602 else if (num < 16)
603 /* a0..7 */
604 return (num - 8) + M68K_A0_REGNUM;
605 else if (num < 24 && tdep->fpregs_present)
606 /* fp0..7 */
607 return (num - 16) + M68K_FP0_REGNUM;
608 else if (num == 25)
609 /* pc */
610 return M68K_PC_REGNUM;
611 else
612 return -1;
613}
614
615
617{
618 /* Base address. */
619 CORE_ADDR base;
620 CORE_ADDR sp_offset;
621 CORE_ADDR pc;
622
623 /* Saved registers. */
625 CORE_ADDR saved_sp;
626
627 /* Stack space reserved for local variables. */
628 long locals;
629};
630
631/* Allocate and initialize a frame cache. */
632
633static struct m68k_frame_cache *
635{
636 struct m68k_frame_cache *cache;
637 int i;
638
639 cache = FRAME_OBSTACK_ZALLOC (struct m68k_frame_cache);
640
641 /* Base address. */
642 cache->base = 0;
643 cache->sp_offset = -4;
644 cache->pc = 0;
645
646 /* Saved registers. We initialize these to -1 since zero is a valid
647 offset (that's where %fp is supposed to be stored). */
648 for (i = 0; i < M68K_NUM_REGS; i++)
649 cache->saved_regs[i] = -1;
650
651 /* Frameless until proven otherwise. */
652 cache->locals = -1;
653
654 return cache;
655}
656
657/* Check whether PC points at a code that sets up a new stack frame.
658 If so, it updates CACHE and returns the address of the first
659 instruction after the sequence that sets removes the "hidden"
660 argument from the stack or CURRENT_PC, whichever is smaller.
661 Otherwise, return PC. */
662
663static CORE_ADDR
665 CORE_ADDR pc, CORE_ADDR current_pc,
666 struct m68k_frame_cache *cache)
667{
668 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
669 int op;
670
671 if (pc >= current_pc)
672 return current_pc;
673
674 op = read_memory_unsigned_integer (pc, 2, byte_order);
675
676 if (op == P_LINKW_FP || op == P_LINKL_FP || op == P_PEA_FP)
677 {
678 cache->saved_regs[M68K_FP_REGNUM] = 0;
679 cache->sp_offset += 4;
680 if (op == P_LINKW_FP)
681 {
682 /* link.w %fp, #-N */
683 /* link.w %fp, #0; adda.l #-N, %sp */
684 cache->locals = -read_memory_integer (pc + 2, 2, byte_order);
685
686 if (pc + 4 < current_pc && cache->locals == 0)
687 {
688 op = read_memory_unsigned_integer (pc + 4, 2, byte_order);
689 if (op == P_ADDAL_SP)
690 {
691 cache->locals = read_memory_integer (pc + 6, 4, byte_order);
692 return pc + 10;
693 }
694 }
695
696 return pc + 4;
697 }
698 else if (op == P_LINKL_FP)
699 {
700 /* link.l %fp, #-N */
701 cache->locals = -read_memory_integer (pc + 2, 4, byte_order);
702 return pc + 6;
703 }
704 else
705 {
706 /* pea (%fp); movea.l %sp, %fp */
707 cache->locals = 0;
708
709 if (pc + 2 < current_pc)
710 {
711 op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
712
713 if (op == P_MOVEAL_SP_FP)
714 {
715 /* move.l %sp, %fp */
716 return pc + 4;
717 }
718 }
719
720 return pc + 2;
721 }
722 }
723 else if ((op & 0170777) == P_SUBQW_SP || (op & 0170777) == P_SUBQL_SP)
724 {
725 /* subq.[wl] #N,%sp */
726 /* subq.[wl] #8,%sp; subq.[wl] #N,%sp */
727 cache->locals = (op & 07000) == 0 ? 8 : (op & 07000) >> 9;
728 if (pc + 2 < current_pc)
729 {
730 op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
731 if ((op & 0170777) == P_SUBQW_SP || (op & 0170777) == P_SUBQL_SP)
732 {
733 cache->locals += (op & 07000) == 0 ? 8 : (op & 07000) >> 9;
734 return pc + 4;
735 }
736 }
737 return pc + 2;
738 }
739 else if (op == P_ADDAW_SP || op == P_LEA_SP_SP)
740 {
741 /* adda.w #-N,%sp */
742 /* lea (-N,%sp),%sp */
743 cache->locals = -read_memory_integer (pc + 2, 2, byte_order);
744 return pc + 4;
745 }
746 else if (op == P_ADDAL_SP)
747 {
748 /* adda.l #-N,%sp */
749 cache->locals = -read_memory_integer (pc + 2, 4, byte_order);
750 return pc + 6;
751 }
752
753 return pc;
754}
755
756/* Check whether PC points at code that saves registers on the stack.
757 If so, it updates CACHE and returns the address of the first
758 instruction after the register saves or CURRENT_PC, whichever is
759 smaller. Otherwise, return PC. */
760
761static CORE_ADDR
763 CORE_ADDR current_pc,
764 struct m68k_frame_cache *cache)
765{
766 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
767 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
768
769 if (cache->locals >= 0)
770 {
771 CORE_ADDR offset;
772 int op;
773 int i, mask, regno;
774
775 offset = -4 - cache->locals;
776 while (pc < current_pc)
777 {
778 op = read_memory_unsigned_integer (pc, 2, byte_order);
779 if (op == P_FMOVEMX_SP
780 && tdep->fpregs_present)
781 {
782 /* fmovem.x REGS,-(%sp) */
783 op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
784 if ((op & 0xff00) == 0xe000)
785 {
786 mask = op & 0xff;
787 for (i = 0; i < 16; i++, mask >>= 1)
788 {
789 if (mask & 1)
790 {
791 cache->saved_regs[i + M68K_FP0_REGNUM] = offset;
792 offset -= 12;
793 }
794 }
795 pc += 4;
796 }
797 else
798 break;
799 }
800 else if ((op & 0177760) == P_MOVEL_SP)
801 {
802 /* move.l %R,-(%sp) */
803 regno = op & 017;
804 cache->saved_regs[regno] = offset;
805 offset -= 4;
806 pc += 2;
807 }
808 else if (op == P_MOVEML_SP)
809 {
810 /* movem.l REGS,-(%sp) */
811 mask = read_memory_unsigned_integer (pc + 2, 2, byte_order);
812 for (i = 0; i < 16; i++, mask >>= 1)
813 {
814 if (mask & 1)
815 {
816 cache->saved_regs[15 - i] = offset;
817 offset -= 4;
818 }
819 }
820 pc += 4;
821 }
822 else
823 break;
824 }
825 }
826
827 return pc;
828}
829
830
831/* Do a full analysis of the prologue at PC and update CACHE
832 accordingly. Bail out early if CURRENT_PC is reached. Return the
833 address where the analysis stopped.
834
835 We handle all cases that can be generated by gcc.
836
837 For allocating a stack frame:
838
839 link.w %a6,#-N
840 link.l %a6,#-N
841 pea (%fp); move.l %sp,%fp
842 link.w %a6,#0; add.l #-N,%sp
843 subq.l #N,%sp
844 subq.w #N,%sp
845 subq.w #8,%sp; subq.w #N-8,%sp
846 add.w #-N,%sp
847 lea (-N,%sp),%sp
848 add.l #-N,%sp
849
850 For saving registers:
851
852 fmovem.x REGS,-(%sp)
853 move.l R1,-(%sp)
854 move.l R1,-(%sp); move.l R2,-(%sp)
855 movem.l REGS,-(%sp)
856
857 For setting up the PIC register:
858
859 lea (%pc,N),%a5
860
861 */
862
863static CORE_ADDR
865 CORE_ADDR current_pc, struct m68k_frame_cache *cache)
866{
867 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
868 unsigned int op;
869
870 pc = m68k_analyze_frame_setup (gdbarch, pc, current_pc, cache);
871 pc = m68k_analyze_register_saves (gdbarch, pc, current_pc, cache);
872 if (pc >= current_pc)
873 return current_pc;
874
875 /* Check for GOT setup. */
876 op = read_memory_unsigned_integer (pc, 4, byte_order);
877 if (op == P_LEA_PC_A5)
878 {
879 /* lea (%pc,N),%a5 */
880 return pc + 8;
881 }
882
883 return pc;
884}
885
886/* Return PC of first real instruction. */
887
888static CORE_ADDR
889m68k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
890{
891 struct m68k_frame_cache cache;
892 CORE_ADDR pc;
893
894 cache.locals = -1;
895 pc = m68k_analyze_prologue (gdbarch, start_pc, (CORE_ADDR) -1, &cache);
896 if (cache.locals < 0)
897 return start_pc;
898 return pc;
899}
900
901static CORE_ADDR
903{
904 gdb_byte buf[8];
905
907 return extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
908}
909
910/* Normal frames. */
911
912static struct m68k_frame_cache *
913m68k_frame_cache (frame_info_ptr this_frame, void **this_cache)
914{
915 struct gdbarch *gdbarch = get_frame_arch (this_frame);
916 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
917 struct m68k_frame_cache *cache;
918 gdb_byte buf[4];
919 int i;
920
921 if (*this_cache)
922 return (struct m68k_frame_cache *) *this_cache;
923
924 cache = m68k_alloc_frame_cache ();
925 *this_cache = cache;
926
927 /* In principle, for normal frames, %fp holds the frame pointer,
928 which holds the base address for the current stack frame.
929 However, for functions that don't need it, the frame pointer is
930 optional. For these "frameless" functions the frame pointer is
931 actually the frame pointer of the calling frame. Signal
932 trampolines are just a special case of a "frameless" function.
933 They (usually) share their frame pointer with the frame that was
934 in progress when the signal occurred. */
935
936 get_frame_register (this_frame, M68K_FP_REGNUM, buf);
937 cache->base = extract_unsigned_integer (buf, 4, byte_order);
938 if (cache->base == 0)
939 return cache;
940
941 /* For normal frames, %pc is stored at 4(%fp). */
942 cache->saved_regs[M68K_PC_REGNUM] = 4;
943
944 cache->pc = get_frame_func (this_frame);
945 if (cache->pc != 0)
946 m68k_analyze_prologue (get_frame_arch (this_frame), cache->pc,
947 get_frame_pc (this_frame), cache);
948
949 if (cache->locals < 0)
950 {
951 /* We didn't find a valid frame, which means that CACHE->base
952 currently holds the frame pointer for our calling frame. If
953 we're at the start of a function, or somewhere half-way its
954 prologue, the function's frame probably hasn't been fully
955 setup yet. Try to reconstruct the base address for the stack
956 frame by looking at the stack pointer. For truly "frameless"
957 functions this might work too. */
958
959 get_frame_register (this_frame, M68K_SP_REGNUM, buf);
960 cache->base = extract_unsigned_integer (buf, 4, byte_order)
961 + cache->sp_offset;
962 }
963
964 /* Now that we have the base address for the stack frame we can
965 calculate the value of %sp in the calling frame. */
966 cache->saved_sp = cache->base + 8;
967
968 /* Adjust all the saved registers such that they contain addresses
969 instead of offsets. */
970 for (i = 0; i < M68K_NUM_REGS; i++)
971 if (cache->saved_regs[i] != -1)
972 cache->saved_regs[i] += cache->base;
973
974 return cache;
975}
976
977static void
978m68k_frame_this_id (frame_info_ptr this_frame, void **this_cache,
979 struct frame_id *this_id)
980{
981 struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
982
983 /* This marks the outermost frame. */
984 if (cache->base == 0)
985 return;
986
987 /* See the end of m68k_push_dummy_call. */
988 *this_id = frame_id_build (cache->base + 8, cache->pc);
989}
990
991static struct value *
992m68k_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
993 int regnum)
994{
995 struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
996
997 gdb_assert (regnum >= 0);
998
999 if (regnum == M68K_SP_REGNUM && cache->saved_sp)
1000 return frame_unwind_got_constant (this_frame, regnum, cache->saved_sp);
1001
1002 if (regnum < M68K_NUM_REGS && cache->saved_regs[regnum] != -1)
1003 return frame_unwind_got_memory (this_frame, regnum,
1004 cache->saved_regs[regnum]);
1005
1006 return frame_unwind_got_register (this_frame, regnum, regnum);
1007}
1008
1009static const struct frame_unwind m68k_frame_unwind =
1010{
1011 "m68k prologue",
1016 NULL,
1018};
1019
1020static CORE_ADDR
1021m68k_frame_base_address (frame_info_ptr this_frame, void **this_cache)
1022{
1023 struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
1024
1025 return cache->base;
1026}
1027
1035
1036static struct frame_id
1038{
1039 CORE_ADDR fp;
1040
1042
1043 /* See the end of m68k_push_dummy_call. */
1044 return frame_id_build (fp + 8, get_frame_pc (this_frame));
1045}
1046
1047
1048/* Figure out where the longjmp will land. Slurp the args out of the stack.
1049 We expect the first arg to be a pointer to the jmp_buf structure from which
1050 we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
1051 This routine returns true on success. */
1052
1053static int
1055{
1056 gdb_byte *buf;
1057 CORE_ADDR sp, jb_addr;
1058 struct gdbarch *gdbarch = get_frame_arch (frame);
1059 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1060 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1061
1062 if (tdep->jb_pc < 0)
1063 {
1064 internal_error (_("m68k_get_longjmp_target: not implemented"));
1065 return 0;
1066 }
1067
1068 buf = (gdb_byte *) alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
1070
1071 if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack. */
1072 buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT))
1073 return 0;
1074
1076 / TARGET_CHAR_BIT, byte_order);
1077
1078 if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf,
1079 gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT),
1080 byte_order)
1081 return 0;
1082
1084 / TARGET_CHAR_BIT, byte_order);
1085 return 1;
1086}
1087
1088
1089/* This is the implementation of gdbarch method
1090 return_in_first_hidden_param_p. */
1091
1092static int
1094 struct type *type)
1095{
1096 return 0;
1097}
1098
1099/* System V Release 4 (SVR4). */
1100
1101void
1103{
1104 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1105
1106 /* SVR4 uses a different calling convention. */
1108
1109 /* SVR4 uses %a0 instead of %a1. */
1111
1112 /* SVR4 returns pointers in %a0. */
1114}
1115
1116/* GCC's m68k "embedded" ABI. This is like the SVR4 ABI, but pointer
1117 values are returned in %d0, not %a0. */
1118
1119static void
1121{
1122 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1123
1126}
1127
1128
1129
1130/* Function: m68k_gdbarch_init
1131 Initializer function for the m68k gdbarch vector.
1132 Called by gdbarch. Sets up the gdbarch vector(s) for this target. */
1133
1134static struct gdbarch *
1136{
1137 struct gdbarch_list *best_arch;
1139 int i;
1140 enum m68k_flavour flavour = m68k_no_flavour;
1141 int has_fp = 1;
1142 const struct floatformat **long_double_format = floatformats_m68881_ext;
1143
1144 /* Check any target description for validity. */
1145 if (tdesc_has_registers (info.target_desc))
1146 {
1147 const struct tdesc_feature *feature;
1148 int valid_p;
1149
1150 feature = tdesc_find_feature (info.target_desc,
1151 "org.gnu.gdb.m68k.core");
1152
1153 if (feature == NULL)
1154 {
1155 feature = tdesc_find_feature (info.target_desc,
1156 "org.gnu.gdb.coldfire.core");
1157 if (feature != NULL)
1158 flavour = m68k_coldfire_flavour;
1159 }
1160
1161 if (feature == NULL)
1162 {
1163 feature = tdesc_find_feature (info.target_desc,
1164 "org.gnu.gdb.fido.core");
1165 if (feature != NULL)
1166 flavour = m68k_fido_flavour;
1167 }
1168
1169 if (feature == NULL)
1170 return NULL;
1171
1173
1174 valid_p = 1;
1175 for (i = 0; i <= M68K_PC_REGNUM; i++)
1176 valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
1178
1179 if (!valid_p)
1180 return NULL;
1181
1182 feature = tdesc_find_feature (info.target_desc,
1183 "org.gnu.gdb.coldfire.fp");
1184 if (feature != NULL)
1185 {
1186 valid_p = 1;
1187 for (i = M68K_FP0_REGNUM; i <= M68K_FPI_REGNUM; i++)
1188 valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
1190 if (!valid_p)
1191 return NULL;
1192 }
1193 else
1194 has_fp = 0;
1195 }
1196
1197 /* The mechanism for returning floating values from function
1198 and the type of long double depend on whether we're
1199 on ColdFire or standard m68k. */
1200
1201 if (info.bfd_arch_info && info.bfd_arch_info->mach != 0)
1202 {
1203 const bfd_arch_info_type *coldfire_arch =
1204 bfd_lookup_arch (bfd_arch_m68k, bfd_mach_mcf_isa_a_nodiv);
1205
1206 if (coldfire_arch
1207 && ((*info.bfd_arch_info->compatible)
1208 (info.bfd_arch_info, coldfire_arch)))
1209 flavour = m68k_coldfire_flavour;
1210 }
1211
1212 /* Try to figure out if the arch uses floating registers to return
1213 floating point values from functions. On ColdFire, floating
1214 point values are returned in D0. */
1215 int float_return = 0;
1216 if (has_fp && flavour != m68k_coldfire_flavour)
1217 float_return = 1;
1218#ifdef HAVE_ELF
1219 if (info.abfd && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
1220 {
1221 int fp_abi = bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
1222 Tag_GNU_M68K_ABI_FP);
1223 if (fp_abi == 1)
1224 float_return = 1;
1225 else if (fp_abi == 2)
1226 float_return = 0;
1227 }
1228#endif /* HAVE_ELF */
1229
1230 /* If there is already a candidate, use it. */
1231 for (best_arch = gdbarch_list_lookup_by_info (arches, &info);
1232 best_arch != NULL;
1233 best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info))
1234 {
1235 m68k_gdbarch_tdep *tdep
1236 = gdbarch_tdep<m68k_gdbarch_tdep> (best_arch->gdbarch);
1237
1238 if (flavour != tdep->flavour)
1239 continue;
1240
1241 if (has_fp != tdep->fpregs_present)
1242 continue;
1243
1244 if (float_return != tdep->float_return)
1245 continue;
1246
1247 break;
1248 }
1249
1250 if (best_arch != NULL)
1251 return best_arch->gdbarch;
1252
1255 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1256
1257 tdep->fpregs_present = has_fp;
1258 tdep->float_return = float_return;
1259 tdep->flavour = flavour;
1260
1261 if (flavour == m68k_coldfire_flavour || flavour == m68k_fido_flavour)
1262 long_double_format = floatformats_ieee_double;
1263 set_gdbarch_long_double_format (gdbarch, long_double_format);
1264 set_gdbarch_long_double_bit (gdbarch, long_double_format[0]->totalsize);
1265
1267 set_gdbarch_breakpoint_kind_from_pc (gdbarch, m68k_breakpoint::kind_from_pc);
1268 set_gdbarch_sw_breakpoint_from_kind (gdbarch, m68k_breakpoint::bp_from_kind);
1269
1270 /* Stack grows down. */
1273
1275 if (flavour == m68k_coldfire_flavour || flavour == m68k_fido_flavour)
1277
1280
1290
1291 if (has_fp)
1293
1294 /* Function call & return. */
1299
1300#if defined JB_PC && defined JB_ELEMENT_SIZE
1301 tdep->jb_pc = JB_PC;
1302 tdep->jb_elt_size = JB_ELEMENT_SIZE;
1303#else
1304 tdep->jb_pc = -1;
1305#endif
1308 tdep->struct_return = reg_struct_return;
1309
1310 /* Frame unwinder. */
1313
1314 /* Hook in the DWARF CFI frame unwinder. */
1316
1318
1319 /* Hook in ABI-specific overrides, if they have been registered. */
1321
1322 /* Now we have tuned the configuration, set a few final things,
1323 based on what the OS ABI has told us. */
1324
1325 if (tdep->jb_pc >= 0)
1327
1329
1330 if (tdesc_data != nullptr)
1331 tdesc_use_registers (gdbarch, info.target_desc, std::move (tdesc_data));
1332
1333 return gdbarch;
1334}
1335
1336
1337static void
1338m68k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
1339{
1340 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1341
1342 if (tdep == NULL)
1343 return;
1344}
1345
1346/* OSABI sniffer for m68k. */
1347
1348static enum gdb_osabi
1350{
1351 unsigned int elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
1352
1353 if (elfosabi == ELFOSABI_NONE)
1354 return GDB_OSABI_SVR4;
1355
1356 return GDB_OSABI_UNKNOWN;
1357}
1358
1359void _initialize_m68k_tdep ();
1360void
1362{
1364
1365 gdbarch_register_osabi_sniffer (bfd_arch_m68k, bfd_target_elf_flavour,
1367 gdbarch_register_osabi (bfd_arch_m68k, 0, GDB_OSABI_SVR4,
1369}
int regnum
int code
Definition ada-lex.l:670
gdb_static_assert(sizeof(splay_tree_key) >=sizeof(CORE_ADDR *))
void gdbarch_register(enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init, gdbarch_dump_tdep_ftype *dump_tdep, gdbarch_supports_arch_info_ftype *supports_arch_info)
static std::vector< const char * > arches
Definition arch-utils.c:685
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
Definition arch-utils.c:177
struct gdbarch_list * gdbarch_list_lookup_by_info(struct gdbarch_list *arches, const struct gdbarch_info *info)
#define BP_MANIPULATION(BREAK_INSN)
Definition arch-utils.h:70
@ pcc_struct_return
Definition arm-tdep.h:85
@ reg_struct_return
Definition arm-tdep.h:86
enum register_status raw_read(int regnum, gdb_byte *buf)
Definition regcache.c:611
gdbarch * arch() const
Definition regcache.c:231
void cooked_write(int regnum, const gdb_byte *buf)
Definition regcache.c:870
void raw_write_part(int regnum, int offset, int len, const gdb_byte *buf)
Definition regcache.c:1032
void raw_write(int regnum, const gdb_byte *buf)
Definition regcache.c:833
void * get(unsigned key)
Definition registry.h:211
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
Definition corefile.c:347
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition corefile.c:306
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition corefile.c:238
LONGEST read_memory_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition corefile.c:296
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
Definition defs.h:515
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
Definition findvar.c:152
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
Definition defs.h:480
return_value_convention
Definition defs.h:257
@ RETURN_VALUE_ABI_RETURNS_ADDRESS
Definition defs.h:273
@ RETURN_VALUE_REGISTER_CONVENTION
Definition defs.h:260
void dwarf2_append_unwinders(struct gdbarch *gdbarch)
Definition frame.c:1369
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
Definition frame-base.c:93
int default_frame_sniffer(const struct frame_unwind *self, frame_info_ptr this_frame, void **this_prologue_cache)
struct value * frame_unwind_got_memory(frame_info_ptr frame, int regnum, CORE_ADDR addr)
struct value * frame_unwind_got_register(frame_info_ptr frame, int regnum, int new_regnum)
enum unwind_stop_reason default_frame_unwind_stop_reason(frame_info_ptr this_frame, void **this_cache)
struct value * frame_unwind_got_constant(frame_info_ptr frame, int regnum, ULONGEST val)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
ULONGEST get_frame_register_unsigned(frame_info_ptr frame, int regnum)
Definition frame.c:1399
CORE_ADDR get_frame_pc(frame_info_ptr frame)
Definition frame.c:2712
void get_frame_register(frame_info_ptr frame, int regnum, gdb_byte *buf)
Definition frame.c:1263
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition frame.c:736
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
Definition frame.c:3027
void frame_unwind_register(frame_info_ptr next_frame, int regnum, gdb_byte *buf)
Definition frame.c:1243
CORE_ADDR get_frame_func(frame_info_ptr this_frame)
Definition frame.c:1098
bool get_frame_register_bytes(frame_info_ptr frame, int regnum, CORE_ADDR offset, gdb::array_view< gdb_byte > buffer, int *optimizedp, int *unavailablep)
Definition frame.c:1480
void put_frame_register(frame_info_ptr frame, int regnum, const gdb_byte *buf)
Definition frame.c:1426
@ NORMAL_FRAME
Definition frame.h:187
#define FRAME_OBSTACK_ZALLOC(TYPE)
Definition frame.h:825
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2054
void set_gdbarch_unwind_pc(struct gdbarch *gdbarch, gdbarch_unwind_pc_ftype *unwind_pc)
void set_gdbarch_ps_regnum(struct gdbarch *gdbarch, int ps_regnum)
Definition gdbarch.c:2081
void set_gdbarch_register_to_value(struct gdbarch *gdbarch, gdbarch_register_to_value_ftype *register_to_value)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition gdbarch.c:1396
void set_gdbarch_value_to_register(struct gdbarch *gdbarch, gdbarch_value_to_register_ftype *value_to_register)
void set_gdbarch_breakpoint_kind_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_kind_from_pc_ftype *breakpoint_kind_from_pc)
void set_gdbarch_frame_align(struct gdbarch *gdbarch, gdbarch_frame_align_ftype *frame_align)
void set_gdbarch_get_longjmp_target(struct gdbarch *gdbarch, gdbarch_get_longjmp_target_ftype *get_longjmp_target)
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype *skip_prologue)
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype *register_name)
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype *return_value)
void set_gdbarch_decr_pc_after_break(struct gdbarch *gdbarch, CORE_ADDR decr_pc_after_break)
Definition gdbarch.c:2913
void set_gdbarch_return_in_first_hidden_param_p(struct gdbarch *gdbarch, gdbarch_return_in_first_hidden_param_p_ftype *return_in_first_hidden_param_p)
void set_gdbarch_believe_pcc_promotion(struct gdbarch *gdbarch, int believe_pcc_promotion)
Definition gdbarch.c:2470
void set_gdbarch_fp0_regnum(struct gdbarch *gdbarch, int fp0_regnum)
Definition gdbarch.c:2098
void set_gdbarch_inner_than(struct gdbarch *gdbarch, gdbarch_inner_than_ftype *inner_than)
void set_gdbarch_sp_regnum(struct gdbarch *gdbarch, int sp_regnum)
Definition gdbarch.c:2047
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2037
void set_gdbarch_long_double_format(struct gdbarch *gdbarch, const struct floatformat **long_double_format)
Definition gdbarch.c:1663
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
Definition gdbarch.c:2064
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype *register_type)
void set_gdbarch_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, gdbarch_dwarf2_reg_to_regnum_ftype *dwarf2_reg_to_regnum)
void set_gdbarch_convert_register_p(struct gdbarch *gdbarch, gdbarch_convert_register_p_ftype *convert_register_p)
int gdbarch_fp0_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2088
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
Definition gdbarch.c:1941
void set_gdbarch_long_double_bit(struct gdbarch *gdbarch, int long_double_bit)
Definition gdbarch.c:1646
void set_gdbarch_sw_breakpoint_from_kind(struct gdbarch *gdbarch, gdbarch_sw_breakpoint_from_kind_ftype *sw_breakpoint_from_kind)
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
Definition gdbarch.c:1722
void set_gdbarch_dummy_id(struct gdbarch *gdbarch, gdbarch_dummy_id_ftype *dummy_id)
void set_gdbarch_push_dummy_call(struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype *push_dummy_call)
void set_gdbarch_frame_args_skip(struct gdbarch *gdbarch, CORE_ADDR frame_args_skip)
Definition gdbarch.c:3012
struct gdbarch * gdbarch_alloc(const struct gdbarch_info *info, gdbarch_tdep_up tdep)
Definition gdbarch.c:266
std::unique_ptr< gdbarch_tdep_base > gdbarch_tdep_up
Definition gdbarch.h:73
function_call_return_method
Definition gdbarch.h:114
@ return_method_struct
Definition gdbarch.h:126
void append_flags_type_flag(struct type *type, int bitpos, const char *name)
Definition gdbtypes.c:5723
const struct floatformat * floatformats_m68881_ext[BFD_ENDIAN_UNKNOWN]
Definition gdbtypes.c:105
struct type * arch_flags_type(struct gdbarch *gdbarch, const char *name, int bit)
Definition gdbtypes.c:5681
struct type * init_float_type(type_allocator &alloc, int bit, const char *name, const struct floatformat **floatformats, enum bfd_endian byte_order)
Definition gdbtypes.c:3408
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
Definition gdbtypes.c:6168
unsigned type_align(struct type *type)
Definition gdbtypes.c:3527
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
Definition gdbtypes.c:89
struct type * check_typedef(struct type *type)
Definition gdbtypes.c:2966
type_code
Definition gdbtypes.h:82
static void m68k_frame_this_id(frame_info_ptr this_frame, void **this_cache, struct frame_id *this_id)
Definition m68k-tdep.c:978
static struct type * m68881_ext_type(struct gdbarch *gdbarch)
Definition m68k-tdep.c:100
static void m68k_embedded_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition m68k-tdep.c:1120
void _initialize_m68k_tdep()
Definition m68k-tdep.c:1361
static CORE_ADDR m68k_unwind_pc(struct gdbarch *gdbarch, frame_info_ptr next_frame)
Definition m68k-tdep.c:902
static enum return_value_convention m68k_svr4_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
Definition m68k-tdep.c:465
static void m68k_store_return_value(struct type *type, struct regcache *regcache, const gdb_byte *valbuf)
Definition m68k-tdep.c:342
static CORE_ADDR m68k_analyze_register_saves(struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR current_pc, struct m68k_frame_cache *cache)
Definition m68k-tdep.c:762
static struct type * m68k_register_type(struct gdbarch *gdbarch, int regnum)
Definition m68k-tdep.c:124
static void m68k_svr4_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *valbuf)
Definition m68k-tdep.c:322
void m68k_svr4_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition m68k-tdep.c:1102
static struct m68k_frame_cache * m68k_frame_cache(frame_info_ptr this_frame, void **this_cache)
Definition m68k-tdep.c:913
static void m68k_dump_tdep(struct gdbarch *gdbarch, struct ui_file *file)
Definition m68k-tdep.c:1338
#define P_LEA_SP_SP
Definition m68k-tdep.c:51
static CORE_ADDR m68k_push_dummy_call(struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, function_call_return_method return_method, CORE_ADDR struct_addr)
Definition m68k-tdep.c:536
static const struct frame_unwind m68k_frame_unwind
Definition m68k-tdep.c:1009
#define P_SUBQL_SP
Definition m68k-tdep.c:50
static struct value * m68k_frame_prev_register(frame_info_ptr this_frame, void **this_cache, int regnum)
Definition m68k-tdep.c:992
static int m68k_dwarf_reg_to_regnum(struct gdbarch *gdbarch, int num)
Definition m68k-tdep.c:595
static CORE_ADDR m68k_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR start_pc)
Definition m68k-tdep.c:889
static int m68k_reg_struct_return_p(struct gdbarch *gdbarch, struct type *type)
Definition m68k-tdep.c:390
static enum gdb_osabi m68k_osabi_sniffer(bfd *abfd)
Definition m68k-tdep.c:1349
static const char * m68k_register_name(struct gdbarch *gdbarch, int regnum)
Definition m68k-tdep.c:175
#define P_LEA_PC_A5
Definition m68k-tdep.c:52
static int m68k_return_in_first_hidden_param_p(struct gdbarch *gdbarch, struct type *type)
Definition m68k-tdep.c:1093
#define P_FMOVEMX_SP
Definition m68k-tdep.c:53
static enum return_value_convention m68k_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
Definition m68k-tdep.c:429
#define P_MOVEL_SP
Definition m68k-tdep.c:54
#define P_ADDAL_SP
Definition m68k-tdep.c:48
static void m68k_value_to_register(frame_info_ptr frame, int regnum, struct type *type, const gdb_byte *from)
Definition m68k-tdep.c:235
static const struct frame_base m68k_frame_base
Definition m68k-tdep.c:1028
static int m68k_get_longjmp_target(frame_info_ptr frame, CORE_ADDR *pc)
Definition m68k-tdep.c:1054
#define P_ADDAW_SP
Definition m68k-tdep.c:47
static void m68k_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *valbuf)
Definition m68k-tdep.c:294
constexpr gdb_byte m68k_break_insn[]
Definition m68k-tdep.c:64
static void m68k_svr4_store_return_value(struct type *type, struct regcache *regcache, const gdb_byte *valbuf)
Definition m68k-tdep.c:368
static CORE_ADDR m68k_analyze_frame_setup(struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR current_pc, struct m68k_frame_cache *cache)
Definition m68k-tdep.c:664
static struct gdbarch * m68k_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
Definition m68k-tdep.c:1135
static struct m68k_frame_cache * m68k_alloc_frame_cache(void)
Definition m68k-tdep.c:634
#define P_MOVEAL_SP_FP
Definition m68k-tdep.c:46
static int m68k_register_to_value(frame_info_ptr frame, int regnum, struct type *type, gdb_byte *to, int *optimizedp, int *unavailablep)
Definition m68k-tdep.c:208
#define P_SUBQW_SP
Definition m68k-tdep.c:49
static int m68k_convert_register_p(struct gdbarch *gdbarch, int regnum, struct type *type)
Definition m68k-tdep.c:191
#define P_LINKL_FP
Definition m68k-tdep.c:43
static struct frame_id m68k_dummy_id(struct gdbarch *gdbarch, frame_info_ptr this_frame)
Definition m68k-tdep.c:1037
static const char *const m68k_register_names[]
Definition m68k-tdep.c:163
#define P_MOVEML_SP
Definition m68k-tdep.c:55
static CORE_ADDR m68k_analyze_prologue(struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR current_pc, struct m68k_frame_cache *cache)
Definition m68k-tdep.c:864
#define P_PEA_FP
Definition m68k-tdep.c:45
static CORE_ADDR m68k_frame_base_address(frame_info_ptr this_frame, void **this_cache)
Definition m68k-tdep.c:1021
#define SP_ARG0
Definition m68k-tdep.c:58
#define BPT_VECTOR
Definition m68k-tdep.c:61
#define P_LINKW_FP
Definition m68k-tdep.c:44
static CORE_ADDR m68k_frame_align(struct gdbarch *gdbarch, CORE_ADDR sp)
Definition m68k-tdep.c:529
#define M68K_MAX_REGISTER_SIZE
Definition m68k-tdep.h:52
m68k_flavour
Definition m68k-tdep.h:64
@ m68k_no_flavour
Definition m68k-tdep.h:65
@ m68k_coldfire_flavour
Definition m68k-tdep.h:66
@ m68k_fido_flavour
Definition m68k-tdep.h:67
@ M68K_PC_REGNUM
Definition m68k-tdep.h:41
@ M68K_FP0_REGNUM
Definition m68k-tdep.h:42
@ M68K_FP_REGNUM
Definition m68k-tdep.h:38
@ M68K_PS_REGNUM
Definition m68k-tdep.h:40
@ M68K_A0_REGNUM
Definition m68k-tdep.h:35
@ M68K_D0_REGNUM
Definition m68k-tdep.h:31
@ M68K_A1_REGNUM
Definition m68k-tdep.h:36
@ M68K_FPS_REGNUM
Definition m68k-tdep.h:44
@ M68K_FPI_REGNUM
Definition m68k-tdep.h:45
@ M68K_FPC_REGNUM
Definition m68k-tdep.h:43
@ M68K_D1_REGNUM
Definition m68k-tdep.h:32
@ M68K_SP_REGNUM
Definition m68k-tdep.h:39
#define M68K_NUM_REGS
Definition m68k-tdep.h:49
info(Component c)
Definition gdbarch.py:41
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
Definition osabi.c:146
void gdbarch_init_osabi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition osabi.c:382
void gdbarch_register_osabi_sniffer(enum bfd_architecture arch, enum bfd_flavour flavour, enum gdb_osabi(*sniffer_fn)(bfd *))
Definition osabi.c:220
gdb_osabi
Definition osabi.h:25
@ GDB_OSABI_SVR4
Definition osabi.h:29
@ GDB_OSABI_UNKNOWN
Definition osabi.h:26
enum register_status regcache_raw_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
Definition regcache.c:649
int register_size(struct gdbarch *gdbarch, int regnum)
Definition regcache.c:170
struct type * register_type(struct gdbarch *gdbarch, int regnum)
Definition regcache.c:158
enum var_types type
Definition scm-param.c:142
struct type * builtin_int0
Definition gdbtypes.h:2112
struct type * builtin_double
Definition gdbtypes.h:2090
struct type * builtin_func_ptr
Definition gdbtypes.h:2146
struct type * builtin_data_ptr
Definition gdbtypes.h:2135
struct type * builtin_int32
Definition gdbtypes.h:2119
struct type * type() const
Definition gdbtypes.h:547
struct gdbarch * gdbarch
Definition gdbarch.h:243
struct gdbarch_list * next
Definition gdbarch.h:244
CORE_ADDR base
Definition m68k-tdep.c:619
CORE_ADDR sp_offset
Definition m68k-tdep.c:620
CORE_ADDR saved_sp
Definition m68k-tdep.c:625
CORE_ADDR saved_regs[M68K_NUM_REGS]
Definition m68k-tdep.c:624
int pointer_result_regnum
Definition m68k-tdep.h:86
struct type * m68881_ext_type
Definition m68k-tdep.h:103
struct type * m68k_ps_type
Definition m68k-tdep.h:102
struct type * target_type() const
Definition gdbtypes.h:1037
type_code code() const
Definition gdbtypes.h:956
ULONGEST length() const
Definition gdbtypes.h:983
struct field & field(int idx) const
Definition gdbtypes.h:1012
bool is_vector() const
Definition gdbtypes.h:1186
unsigned int num_fields() const
Definition gdbtypes.h:994
Definition value.h:130
tdesc_arch_data_up tdesc_data_alloc(void)
const struct tdesc_feature * tdesc_find_feature(const struct target_desc *target_desc, const char *name)
int tdesc_numbered_register(const struct tdesc_feature *feature, struct tdesc_arch_data *data, int regno, const char *name)
static const registry< gdbarch >::key< tdesc_arch_data > tdesc_data
void tdesc_use_registers(struct gdbarch *gdbarch, const struct target_desc *target_desc, tdesc_arch_data_up &&early_data, tdesc_unknown_register_ftype unk_reg_cb)
int tdesc_has_registers(const struct target_desc *target_desc)
std::unique_ptr< tdesc_arch_data, tdesc_arch_data_deleter > tdesc_arch_data_up
void target_float_convert(const gdb_byte *from, const struct type *from_type, gdb_byte *to, const struct type *to_type)
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition target.c:1785