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 tdep->m68881_ext_type
106 = arch_float_type (gdbarch, -1, "builtin_type_m68881_ext",
108
109 return tdep->m68881_ext_type;
110}
111
112/* Return the GDB type object for the "standard" data type of data in
113 register N. This should be int for D0-D7, SR, FPCONTROL and
114 FPSTATUS, long double for FP0-FP7, and void pointer for all others
115 (A0-A7, PC, FPIADDR). Note, for registers which contain
116 addresses return pointer to void, not pointer to char, because we
117 don't want to attempt to print the string after printing the
118 address. */
119
120static struct type *
122{
123 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
124
125 if (tdep->fpregs_present)
126 {
129 {
130 if (tdep->flavour == m68k_coldfire_flavour)
132 else
133 return m68881_ext_type (gdbarch);
134 }
135
136 if (regnum == M68K_FPI_REGNUM)
138
141 }
142 else
143 {
146 }
147
150
153
154 if (regnum == M68K_PS_REGNUM)
155 return m68k_ps_type (gdbarch);
156
158}
159
160static const char * const m68k_register_names[] = {
161 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
162 "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp",
163 "ps", "pc",
164 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
165 "fpcontrol", "fpstatus", "fpiaddr"
166 };
167
168/* Function: m68k_register_name
169 Returns the name of the standard m68k register regnum. */
170
171static const char *
173{
174 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
175
178 && tdep->fpregs_present == 0)
179 return "";
180 else
182}
183
184/* Return nonzero if a value of type TYPE stored in register REGNUM
185 needs any special handling. */
186
187static int
189 int regnum, struct type *type)
190{
191 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
192
193 if (!tdep->fpregs_present)
194 return 0;
195 return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FP0_REGNUM + 7
196 /* We only support floating-point values. */
197 && type->code () == TYPE_CODE_FLT
199}
200
201/* Read a value of type TYPE from register REGNUM in frame FRAME, and
202 return its contents in TO. */
203
204static int
206 struct type *type, gdb_byte *to,
207 int *optimizedp, int *unavailablep)
208{
209 struct gdbarch *gdbarch = get_frame_arch (frame);
210 gdb_byte from[M68K_MAX_REGISTER_SIZE];
211 struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM);
212
213 gdb_assert (type->code () == TYPE_CODE_FLT);
214
215 /* Convert to TYPE. */
216 if (!get_frame_register_bytes (frame, regnum, 0,
217 gdb::make_array_view (from,
219 regnum)),
220 optimizedp, unavailablep))
221 return 0;
222
223 target_float_convert (from, fpreg_type, to, type);
224 *optimizedp = *unavailablep = 0;
225 return 1;
226}
227
228/* Write the contents FROM of a value of type TYPE into register
229 REGNUM in frame FRAME. */
230
231static void
233 struct type *type, const gdb_byte *from)
234{
235 gdb_byte to[M68K_MAX_REGISTER_SIZE];
236 struct type *fpreg_type = register_type (get_frame_arch (frame),
238
239 /* We only support floating-point values. */
240 if (type->code () != TYPE_CODE_FLT)
241 {
242 warning (_("Cannot convert non-floating-point type "
243 "to floating-point register value."));
244 return;
245 }
246
247 /* Convert from TYPE. */
248 target_float_convert (from, type, to, fpreg_type);
249 put_frame_register (frame, regnum, to);
250}
251
252
253/* There is a fair number of calling conventions that are in somewhat
254 wide use. The 68000/08/10 don't support an FPU, not even as a
255 coprocessor. All function return values are stored in %d0/%d1.
256 Structures are returned in a static buffer, a pointer to which is
257 returned in %d0. This means that functions returning a structure
258 are not re-entrant. To avoid this problem some systems use a
259 convention where the caller passes a pointer to a buffer in %a1
260 where the return values is to be stored. This convention is the
261 default, and is implemented in the function m68k_return_value.
262
263 The 68020/030/040/060 do support an FPU, either as a coprocessor
264 (68881/2) or built-in (68040/68060). That's why System V release 4
265 (SVR4) introduces a new calling convention specified by the SVR4
266 psABI. Integer values are returned in %d0/%d1, pointer return
267 values in %a0 and floating values in %fp0. When calling functions
268 returning a structure the caller should pass a pointer to a buffer
269 for the return value in %a0. This convention is implemented in the
270 function m68k_svr4_return_value, and by appropriately setting the
271 struct_value_regnum member of `struct gdbarch_tdep'.
272
273 GNU/Linux returns values in the same way as SVR4 does, but uses %a1
274 for passing the structure return value buffer.
275
276 GCC can also generate code where small structures are returned in
277 %d0/%d1 instead of in memory by using -freg-struct-return. This is
278 the default on NetBSD a.out, OpenBSD and GNU/Linux and several
279 embedded systems. This convention is implemented by setting the
280 struct_return member of `struct gdbarch_tdep' to reg_struct_return.
281
282 GCC also has an "embedded" ABI. This works like the SVR4 ABI,
283 except that pointers are returned in %D0. This is implemented by
284 setting the pointer_result_regnum member of `struct gdbarch_tdep'
285 as appropriate. */
286
287/* Read a function return value of TYPE from REGCACHE, and copy that
288 into VALBUF. */
289
290static void
292 gdb_byte *valbuf)
293{
294 int len = type->length ();
295 gdb_byte buf[M68K_MAX_REGISTER_SIZE];
296
297 if (type->code () == TYPE_CODE_PTR && len == 4)
298 {
299 struct gdbarch *gdbarch = regcache->arch ();
300 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
301 regcache->raw_read (tdep->pointer_result_regnum, valbuf);
302 }
303 else if (len <= 4)
304 {
306 memcpy (valbuf, buf + (4 - len), len);
307 }
308 else if (len <= 8)
309 {
311 memcpy (valbuf, buf + (8 - len), len - 4);
312 regcache->raw_read (M68K_D1_REGNUM, valbuf + (len - 4));
313 }
314 else
315 internal_error (_("Cannot extract return value of %d bytes long."), len);
316}
317
318static void
320 gdb_byte *valbuf)
321{
322 gdb_byte buf[M68K_MAX_REGISTER_SIZE];
323 struct gdbarch *gdbarch = regcache->arch ();
324 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
325
326 if (tdep->float_return && type->code () == TYPE_CODE_FLT)
327 {
328 struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM);
330 target_float_convert (buf, fpreg_type, valbuf, type);
331 }
332 else
334}
335
336/* Write a function return value of TYPE from VALBUF into REGCACHE. */
337
338static void
340 const gdb_byte *valbuf)
341{
342 int len = type->length ();
343
344 if (type->code () == TYPE_CODE_PTR && len == 4)
345 {
346 struct gdbarch *gdbarch = regcache->arch ();
347 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
349 /* gdb historically also set D0 in the SVR4 case. */
352 }
353 else if (len <= 4)
354 regcache->raw_write_part (M68K_D0_REGNUM, 4 - len, len, valbuf);
355 else if (len <= 8)
356 {
357 regcache->raw_write_part (M68K_D0_REGNUM, 8 - len, len - 4, valbuf);
358 regcache->raw_write (M68K_D1_REGNUM, valbuf + (len - 4));
359 }
360 else
361 internal_error (_("Cannot store return value of %d bytes long."), len);
362}
363
364static void
366 const gdb_byte *valbuf)
367{
368 struct gdbarch *gdbarch = regcache->arch ();
369 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
370
371 if (tdep->float_return && type->code () == TYPE_CODE_FLT)
372 {
373 struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM);
374 gdb_byte buf[M68K_MAX_REGISTER_SIZE];
375 target_float_convert (valbuf, type, buf, fpreg_type);
377 }
378 else
380}
381
382/* Return non-zero if TYPE, which is assumed to be a structure, union or
383 complex type, should be returned in registers for architecture
384 GDBARCH. */
385
386static int
388{
389 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
390 enum type_code code = type->code ();
391 int len = type->length ();
392
393 gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
394 || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY);
395
396 if (tdep->struct_return == pcc_struct_return)
397 return 0;
398
399 const bool is_vector = code == TYPE_CODE_ARRAY && type->is_vector ();
400
401 if (is_vector
402 && check_typedef (type->target_type ())->code () == TYPE_CODE_FLT)
403 return 0;
404
405 /* According to m68k_return_in_memory in the m68k GCC back-end,
406 strange things happen for small aggregate types. Aggregate types
407 with only one component are always returned like the type of the
408 component. Aggregate types whose size is 2, 4, or 8 are returned
409 in registers if their natural alignment is at least 16 bits.
410
411 We reject vectors here, as experimentally this gives the correct
412 answer. */
413 if (!is_vector && (len == 2 || len == 4 || len == 8))
414 return type_align (type) >= 2;
415
416 return (len == 1 || len == 2 || len == 4 || len == 8);
417}
418
419/* Determine, for architecture GDBARCH, how a return value of TYPE
420 should be returned. If it is supposed to be returned in registers,
421 and READBUF is non-zero, read the appropriate value from REGCACHE,
422 and copy it into READBUF. If WRITEBUF is non-zero, write the value
423 from WRITEBUF into REGCACHE. */
424
425static enum return_value_convention
426m68k_return_value (struct gdbarch *gdbarch, struct value *function,
427 struct type *type, struct regcache *regcache,
428 gdb_byte *readbuf, const gdb_byte *writebuf)
429{
430 enum type_code code = type->code ();
431
432 /* GCC returns a `long double' in memory too. */
433 if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
434 || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY)
436 || (code == TYPE_CODE_FLT && type->length () == 12))
437 {
438 /* The default on m68k is to return structures in static memory.
439 Consequently a function must return the address where we can
440 find the return value. */
441
442 if (readbuf)
443 {
444 ULONGEST addr;
445
447 read_memory (addr, readbuf, type->length ());
448 }
449
451 }
452
453 if (readbuf)
455 if (writebuf)
457
459}
460
461static enum return_value_convention
462m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function,
463 struct type *type, struct regcache *regcache,
464 gdb_byte *readbuf, const gdb_byte *writebuf)
465{
466 enum type_code code = type->code ();
467 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
468
469 /* Aggregates with a single member are always returned like their
470 sole element. */
471 if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
472 && type->num_fields () == 1)
473 {
474 type = check_typedef (type->field (0).type ());
475 return m68k_svr4_return_value (gdbarch, function, type, regcache,
476 readbuf, writebuf);
477 }
478
479 if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
480 || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY)
482 /* GCC may return a `long double' in memory too. */
483 || (!tdep->float_return
484 && code == TYPE_CODE_FLT
485 && type->length () == 12))
486 {
487 /* The System V ABI says that:
488
489 "A function returning a structure or union also sets %a0 to
490 the value it finds in %a0. Thus when the caller receives
491 control again, the address of the returned object resides in
492 register %a0."
493
494 So the ABI guarantees that we can always find the return
495 value just after the function has returned.
496
497 However, GCC also implements the "embedded" ABI. That ABI
498 does not preserve %a0 across calls, but does write the value
499 back to %d0. */
500
501 if (readbuf)
502 {
503 ULONGEST addr;
504
506 &addr);
507 read_memory (addr, readbuf, type->length ());
508 }
509
511 }
512
513 if (readbuf)
515 if (writebuf)
517
519}
520
521
522/* Always align the frame to a 4-byte boundary. This is required on
523 coldfire and harmless on the rest. */
524
525static CORE_ADDR
526m68k_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
527{
528 /* Align the stack to four bytes. */
529 return sp & ~3;
530}
531
532static CORE_ADDR
533m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
534 struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
535 struct value **args, CORE_ADDR sp,
536 function_call_return_method return_method,
537 CORE_ADDR struct_addr)
538{
539 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
540 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
541 gdb_byte buf[4];
542 int i;
543
544 /* Push arguments in reverse order. */
545 for (i = nargs - 1; i >= 0; i--)
546 {
547 struct type *value_type = value_enclosing_type (args[i]);
548 int len = value_type->length ();
549 int container_len = (len + 3) & ~3;
550 int offset;
551
552 /* Non-scalars bigger than 4 bytes are left aligned, others are
553 right aligned. */
554 if ((value_type->code () == TYPE_CODE_STRUCT
555 || value_type->code () == TYPE_CODE_UNION
556 || value_type->code () == TYPE_CODE_ARRAY)
557 && len > 4)
558 offset = 0;
559 else
560 offset = container_len - len;
561 sp -= container_len;
562 write_memory (sp + offset, value_contents_all (args[i]).data (), len);
563 }
564
565 /* Store struct value address. */
566 if (return_method == return_method_struct)
567 {
568 store_unsigned_integer (buf, 4, byte_order, struct_addr);
570 }
571
572 /* Store return address. */
573 sp -= 4;
574 store_unsigned_integer (buf, 4, byte_order, bp_addr);
575 write_memory (sp, buf, 4);
576
577 /* Finally, update the stack pointer... */
578 store_unsigned_integer (buf, 4, byte_order, sp);
580
581 /* ...and fake a frame pointer. */
583
584 /* DWARF2/GCC uses the stack address *before* the function call as a
585 frame's CFA. */
586 return sp + 8;
587}
588
589/* Convert a dwarf or dwarf2 regnumber to a GDB regnum. */
590
591static int
593{
594 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
595
596 if (num < 8)
597 /* d0..7 */
598 return (num - 0) + M68K_D0_REGNUM;
599 else if (num < 16)
600 /* a0..7 */
601 return (num - 8) + M68K_A0_REGNUM;
602 else if (num < 24 && tdep->fpregs_present)
603 /* fp0..7 */
604 return (num - 16) + M68K_FP0_REGNUM;
605 else if (num == 25)
606 /* pc */
607 return M68K_PC_REGNUM;
608 else
609 return -1;
610}
611
612
614{
615 /* Base address. */
616 CORE_ADDR base;
617 CORE_ADDR sp_offset;
618 CORE_ADDR pc;
619
620 /* Saved registers. */
622 CORE_ADDR saved_sp;
623
624 /* Stack space reserved for local variables. */
625 long locals;
626};
627
628/* Allocate and initialize a frame cache. */
629
630static struct m68k_frame_cache *
632{
633 struct m68k_frame_cache *cache;
634 int i;
635
636 cache = FRAME_OBSTACK_ZALLOC (struct m68k_frame_cache);
637
638 /* Base address. */
639 cache->base = 0;
640 cache->sp_offset = -4;
641 cache->pc = 0;
642
643 /* Saved registers. We initialize these to -1 since zero is a valid
644 offset (that's where %fp is supposed to be stored). */
645 for (i = 0; i < M68K_NUM_REGS; i++)
646 cache->saved_regs[i] = -1;
647
648 /* Frameless until proven otherwise. */
649 cache->locals = -1;
650
651 return cache;
652}
653
654/* Check whether PC points at a code that sets up a new stack frame.
655 If so, it updates CACHE and returns the address of the first
656 instruction after the sequence that sets removes the "hidden"
657 argument from the stack or CURRENT_PC, whichever is smaller.
658 Otherwise, return PC. */
659
660static CORE_ADDR
662 CORE_ADDR pc, CORE_ADDR current_pc,
663 struct m68k_frame_cache *cache)
664{
665 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
666 int op;
667
668 if (pc >= current_pc)
669 return current_pc;
670
671 op = read_memory_unsigned_integer (pc, 2, byte_order);
672
673 if (op == P_LINKW_FP || op == P_LINKL_FP || op == P_PEA_FP)
674 {
675 cache->saved_regs[M68K_FP_REGNUM] = 0;
676 cache->sp_offset += 4;
677 if (op == P_LINKW_FP)
678 {
679 /* link.w %fp, #-N */
680 /* link.w %fp, #0; adda.l #-N, %sp */
681 cache->locals = -read_memory_integer (pc + 2, 2, byte_order);
682
683 if (pc + 4 < current_pc && cache->locals == 0)
684 {
685 op = read_memory_unsigned_integer (pc + 4, 2, byte_order);
686 if (op == P_ADDAL_SP)
687 {
688 cache->locals = read_memory_integer (pc + 6, 4, byte_order);
689 return pc + 10;
690 }
691 }
692
693 return pc + 4;
694 }
695 else if (op == P_LINKL_FP)
696 {
697 /* link.l %fp, #-N */
698 cache->locals = -read_memory_integer (pc + 2, 4, byte_order);
699 return pc + 6;
700 }
701 else
702 {
703 /* pea (%fp); movea.l %sp, %fp */
704 cache->locals = 0;
705
706 if (pc + 2 < current_pc)
707 {
708 op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
709
710 if (op == P_MOVEAL_SP_FP)
711 {
712 /* move.l %sp, %fp */
713 return pc + 4;
714 }
715 }
716
717 return pc + 2;
718 }
719 }
720 else if ((op & 0170777) == P_SUBQW_SP || (op & 0170777) == P_SUBQL_SP)
721 {
722 /* subq.[wl] #N,%sp */
723 /* subq.[wl] #8,%sp; subq.[wl] #N,%sp */
724 cache->locals = (op & 07000) == 0 ? 8 : (op & 07000) >> 9;
725 if (pc + 2 < current_pc)
726 {
727 op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
728 if ((op & 0170777) == P_SUBQW_SP || (op & 0170777) == P_SUBQL_SP)
729 {
730 cache->locals += (op & 07000) == 0 ? 8 : (op & 07000) >> 9;
731 return pc + 4;
732 }
733 }
734 return pc + 2;
735 }
736 else if (op == P_ADDAW_SP || op == P_LEA_SP_SP)
737 {
738 /* adda.w #-N,%sp */
739 /* lea (-N,%sp),%sp */
740 cache->locals = -read_memory_integer (pc + 2, 2, byte_order);
741 return pc + 4;
742 }
743 else if (op == P_ADDAL_SP)
744 {
745 /* adda.l #-N,%sp */
746 cache->locals = -read_memory_integer (pc + 2, 4, byte_order);
747 return pc + 6;
748 }
749
750 return pc;
751}
752
753/* Check whether PC points at code that saves registers on the stack.
754 If so, it updates CACHE and returns the address of the first
755 instruction after the register saves or CURRENT_PC, whichever is
756 smaller. Otherwise, return PC. */
757
758static CORE_ADDR
760 CORE_ADDR current_pc,
761 struct m68k_frame_cache *cache)
762{
763 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
764 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
765
766 if (cache->locals >= 0)
767 {
768 CORE_ADDR offset;
769 int op;
770 int i, mask, regno;
771
772 offset = -4 - cache->locals;
773 while (pc < current_pc)
774 {
775 op = read_memory_unsigned_integer (pc, 2, byte_order);
776 if (op == P_FMOVEMX_SP
777 && tdep->fpregs_present)
778 {
779 /* fmovem.x REGS,-(%sp) */
780 op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
781 if ((op & 0xff00) == 0xe000)
782 {
783 mask = op & 0xff;
784 for (i = 0; i < 16; i++, mask >>= 1)
785 {
786 if (mask & 1)
787 {
788 cache->saved_regs[i + M68K_FP0_REGNUM] = offset;
789 offset -= 12;
790 }
791 }
792 pc += 4;
793 }
794 else
795 break;
796 }
797 else if ((op & 0177760) == P_MOVEL_SP)
798 {
799 /* move.l %R,-(%sp) */
800 regno = op & 017;
801 cache->saved_regs[regno] = offset;
802 offset -= 4;
803 pc += 2;
804 }
805 else if (op == P_MOVEML_SP)
806 {
807 /* movem.l REGS,-(%sp) */
808 mask = read_memory_unsigned_integer (pc + 2, 2, byte_order);
809 for (i = 0; i < 16; i++, mask >>= 1)
810 {
811 if (mask & 1)
812 {
813 cache->saved_regs[15 - i] = offset;
814 offset -= 4;
815 }
816 }
817 pc += 4;
818 }
819 else
820 break;
821 }
822 }
823
824 return pc;
825}
826
827
828/* Do a full analysis of the prologue at PC and update CACHE
829 accordingly. Bail out early if CURRENT_PC is reached. Return the
830 address where the analysis stopped.
831
832 We handle all cases that can be generated by gcc.
833
834 For allocating a stack frame:
835
836 link.w %a6,#-N
837 link.l %a6,#-N
838 pea (%fp); move.l %sp,%fp
839 link.w %a6,#0; add.l #-N,%sp
840 subq.l #N,%sp
841 subq.w #N,%sp
842 subq.w #8,%sp; subq.w #N-8,%sp
843 add.w #-N,%sp
844 lea (-N,%sp),%sp
845 add.l #-N,%sp
846
847 For saving registers:
848
849 fmovem.x REGS,-(%sp)
850 move.l R1,-(%sp)
851 move.l R1,-(%sp); move.l R2,-(%sp)
852 movem.l REGS,-(%sp)
853
854 For setting up the PIC register:
855
856 lea (%pc,N),%a5
857
858 */
859
860static CORE_ADDR
862 CORE_ADDR current_pc, struct m68k_frame_cache *cache)
863{
864 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
865 unsigned int op;
866
867 pc = m68k_analyze_frame_setup (gdbarch, pc, current_pc, cache);
868 pc = m68k_analyze_register_saves (gdbarch, pc, current_pc, cache);
869 if (pc >= current_pc)
870 return current_pc;
871
872 /* Check for GOT setup. */
873 op = read_memory_unsigned_integer (pc, 4, byte_order);
874 if (op == P_LEA_PC_A5)
875 {
876 /* lea (%pc,N),%a5 */
877 return pc + 8;
878 }
879
880 return pc;
881}
882
883/* Return PC of first real instruction. */
884
885static CORE_ADDR
886m68k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
887{
888 struct m68k_frame_cache cache;
889 CORE_ADDR pc;
890
891 cache.locals = -1;
892 pc = m68k_analyze_prologue (gdbarch, start_pc, (CORE_ADDR) -1, &cache);
893 if (cache.locals < 0)
894 return start_pc;
895 return pc;
896}
897
898static CORE_ADDR
900{
901 gdb_byte buf[8];
902
904 return extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
905}
906
907/* Normal frames. */
908
909static struct m68k_frame_cache *
910m68k_frame_cache (frame_info_ptr this_frame, void **this_cache)
911{
912 struct gdbarch *gdbarch = get_frame_arch (this_frame);
913 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
914 struct m68k_frame_cache *cache;
915 gdb_byte buf[4];
916 int i;
917
918 if (*this_cache)
919 return (struct m68k_frame_cache *) *this_cache;
920
921 cache = m68k_alloc_frame_cache ();
922 *this_cache = cache;
923
924 /* In principle, for normal frames, %fp holds the frame pointer,
925 which holds the base address for the current stack frame.
926 However, for functions that don't need it, the frame pointer is
927 optional. For these "frameless" functions the frame pointer is
928 actually the frame pointer of the calling frame. Signal
929 trampolines are just a special case of a "frameless" function.
930 They (usually) share their frame pointer with the frame that was
931 in progress when the signal occurred. */
932
933 get_frame_register (this_frame, M68K_FP_REGNUM, buf);
934 cache->base = extract_unsigned_integer (buf, 4, byte_order);
935 if (cache->base == 0)
936 return cache;
937
938 /* For normal frames, %pc is stored at 4(%fp). */
939 cache->saved_regs[M68K_PC_REGNUM] = 4;
940
941 cache->pc = get_frame_func (this_frame);
942 if (cache->pc != 0)
943 m68k_analyze_prologue (get_frame_arch (this_frame), cache->pc,
944 get_frame_pc (this_frame), cache);
945
946 if (cache->locals < 0)
947 {
948 /* We didn't find a valid frame, which means that CACHE->base
949 currently holds the frame pointer for our calling frame. If
950 we're at the start of a function, or somewhere half-way its
951 prologue, the function's frame probably hasn't been fully
952 setup yet. Try to reconstruct the base address for the stack
953 frame by looking at the stack pointer. For truly "frameless"
954 functions this might work too. */
955
956 get_frame_register (this_frame, M68K_SP_REGNUM, buf);
957 cache->base = extract_unsigned_integer (buf, 4, byte_order)
958 + cache->sp_offset;
959 }
960
961 /* Now that we have the base address for the stack frame we can
962 calculate the value of %sp in the calling frame. */
963 cache->saved_sp = cache->base + 8;
964
965 /* Adjust all the saved registers such that they contain addresses
966 instead of offsets. */
967 for (i = 0; i < M68K_NUM_REGS; i++)
968 if (cache->saved_regs[i] != -1)
969 cache->saved_regs[i] += cache->base;
970
971 return cache;
972}
973
974static void
975m68k_frame_this_id (frame_info_ptr this_frame, void **this_cache,
976 struct frame_id *this_id)
977{
978 struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
979
980 /* This marks the outermost frame. */
981 if (cache->base == 0)
982 return;
983
984 /* See the end of m68k_push_dummy_call. */
985 *this_id = frame_id_build (cache->base + 8, cache->pc);
986}
987
988static struct value *
989m68k_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
990 int regnum)
991{
992 struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
993
994 gdb_assert (regnum >= 0);
995
996 if (regnum == M68K_SP_REGNUM && cache->saved_sp)
997 return frame_unwind_got_constant (this_frame, regnum, cache->saved_sp);
998
999 if (regnum < M68K_NUM_REGS && cache->saved_regs[regnum] != -1)
1000 return frame_unwind_got_memory (this_frame, regnum,
1001 cache->saved_regs[regnum]);
1002
1003 return frame_unwind_got_register (this_frame, regnum, regnum);
1004}
1005
1006static const struct frame_unwind m68k_frame_unwind =
1007{
1008 "m68k prologue",
1013 NULL,
1015};
1016
1017static CORE_ADDR
1018m68k_frame_base_address (frame_info_ptr this_frame, void **this_cache)
1019{
1020 struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
1021
1022 return cache->base;
1023}
1024
1025static const struct frame_base m68k_frame_base =
1026{
1031};
1032
1033static struct frame_id
1035{
1036 CORE_ADDR fp;
1037
1039
1040 /* See the end of m68k_push_dummy_call. */
1041 return frame_id_build (fp + 8, get_frame_pc (this_frame));
1042}
1043
1044
1045/* Figure out where the longjmp will land. Slurp the args out of the stack.
1046 We expect the first arg to be a pointer to the jmp_buf structure from which
1047 we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
1048 This routine returns true on success. */
1049
1050static int
1052{
1053 gdb_byte *buf;
1054 CORE_ADDR sp, jb_addr;
1055 struct gdbarch *gdbarch = get_frame_arch (frame);
1056 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1057 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1058
1059 if (tdep->jb_pc < 0)
1060 {
1061 internal_error (_("m68k_get_longjmp_target: not implemented"));
1062 return 0;
1063 }
1064
1065 buf = (gdb_byte *) alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
1067
1068 if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack. */
1069 buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT))
1070 return 0;
1071
1073 / TARGET_CHAR_BIT, byte_order);
1074
1075 if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf,
1076 gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT),
1077 byte_order)
1078 return 0;
1079
1081 / TARGET_CHAR_BIT, byte_order);
1082 return 1;
1083}
1084
1085
1086/* This is the implementation of gdbarch method
1087 return_in_first_hidden_param_p. */
1088
1089static int
1091 struct type *type)
1092{
1093 return 0;
1094}
1095
1096/* System V Release 4 (SVR4). */
1097
1098void
1100{
1101 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1102
1103 /* SVR4 uses a different calling convention. */
1105
1106 /* SVR4 uses %a0 instead of %a1. */
1108
1109 /* SVR4 returns pointers in %a0. */
1111}
1112
1113/* GCC's m68k "embedded" ABI. This is like the SVR4 ABI, but pointer
1114 values are returned in %d0, not %a0. */
1115
1116static void
1118{
1119 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1120
1123}
1124
1125
1126
1127/* Function: m68k_gdbarch_init
1128 Initializer function for the m68k gdbarch vector.
1129 Called by gdbarch. Sets up the gdbarch vector(s) for this target. */
1130
1131static struct gdbarch *
1133{
1134 struct gdbarch *gdbarch;
1135 struct gdbarch_list *best_arch;
1137 int i;
1138 enum m68k_flavour flavour = m68k_no_flavour;
1139 int has_fp = 1;
1140 const struct floatformat **long_double_format = floatformats_m68881_ext;
1141
1142 /* Check any target description for validity. */
1143 if (tdesc_has_registers (info.target_desc))
1144 {
1145 const struct tdesc_feature *feature;
1146 int valid_p;
1147
1148 feature = tdesc_find_feature (info.target_desc,
1149 "org.gnu.gdb.m68k.core");
1150
1151 if (feature == NULL)
1152 {
1153 feature = tdesc_find_feature (info.target_desc,
1154 "org.gnu.gdb.coldfire.core");
1155 if (feature != NULL)
1156 flavour = m68k_coldfire_flavour;
1157 }
1158
1159 if (feature == NULL)
1160 {
1161 feature = tdesc_find_feature (info.target_desc,
1162 "org.gnu.gdb.fido.core");
1163 if (feature != NULL)
1164 flavour = m68k_fido_flavour;
1165 }
1166
1167 if (feature == NULL)
1168 return NULL;
1169
1171
1172 valid_p = 1;
1173 for (i = 0; i <= M68K_PC_REGNUM; i++)
1174 valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
1176
1177 if (!valid_p)
1178 return NULL;
1179
1180 feature = tdesc_find_feature (info.target_desc,
1181 "org.gnu.gdb.coldfire.fp");
1182 if (feature != NULL)
1183 {
1184 valid_p = 1;
1185 for (i = M68K_FP0_REGNUM; i <= M68K_FPI_REGNUM; i++)
1186 valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
1188 if (!valid_p)
1189 return NULL;
1190 }
1191 else
1192 has_fp = 0;
1193 }
1194
1195 /* The mechanism for returning floating values from function
1196 and the type of long double depend on whether we're
1197 on ColdFire or standard m68k. */
1198
1199 if (info.bfd_arch_info && info.bfd_arch_info->mach != 0)
1200 {
1201 const bfd_arch_info_type *coldfire_arch =
1202 bfd_lookup_arch (bfd_arch_m68k, bfd_mach_mcf_isa_a_nodiv);
1203
1204 if (coldfire_arch
1205 && ((*info.bfd_arch_info->compatible)
1206 (info.bfd_arch_info, coldfire_arch)))
1207 flavour = m68k_coldfire_flavour;
1208 }
1209
1210 /* Try to figure out if the arch uses floating registers to return
1211 floating point values from functions. On ColdFire, floating
1212 point values are returned in D0. */
1213 int float_return = 0;
1214 if (has_fp && flavour != m68k_coldfire_flavour)
1215 float_return = 1;
1216#ifdef HAVE_ELF
1217 if (info.abfd && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
1218 {
1219 int fp_abi = bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
1220 Tag_GNU_M68K_ABI_FP);
1221 if (fp_abi == 1)
1222 float_return = 1;
1223 else if (fp_abi == 2)
1224 float_return = 0;
1225 }
1226#endif /* HAVE_ELF */
1227
1228 /* If there is already a candidate, use it. */
1229 for (best_arch = gdbarch_list_lookup_by_info (arches, &info);
1230 best_arch != NULL;
1231 best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info))
1232 {
1233 m68k_gdbarch_tdep *tdep
1234 = gdbarch_tdep<m68k_gdbarch_tdep> (best_arch->gdbarch);
1235
1236 if (flavour != tdep->flavour)
1237 continue;
1238
1239 if (has_fp != tdep->fpregs_present)
1240 continue;
1241
1242 if (float_return != tdep->float_return)
1243 continue;
1244
1245 break;
1246 }
1247
1248 if (best_arch != NULL)
1249 return best_arch->gdbarch;
1250
1252 gdbarch = gdbarch_alloc (&info, tdep);
1253 tdep->fpregs_present = has_fp;
1254 tdep->float_return = float_return;
1255 tdep->flavour = flavour;
1256
1257 if (flavour == m68k_coldfire_flavour || flavour == m68k_fido_flavour)
1258 long_double_format = floatformats_ieee_double;
1259 set_gdbarch_long_double_format (gdbarch, long_double_format);
1260 set_gdbarch_long_double_bit (gdbarch, long_double_format[0]->totalsize);
1261
1263 set_gdbarch_breakpoint_kind_from_pc (gdbarch, m68k_breakpoint::kind_from_pc);
1264 set_gdbarch_sw_breakpoint_from_kind (gdbarch, m68k_breakpoint::bp_from_kind);
1265
1266 /* Stack grows down. */
1269
1271 if (flavour == m68k_coldfire_flavour || flavour == m68k_fido_flavour)
1273
1276
1286
1287 if (has_fp)
1289
1290 /* Function call & return. */
1295
1296#if defined JB_PC && defined JB_ELEMENT_SIZE
1297 tdep->jb_pc = JB_PC;
1298 tdep->jb_elt_size = JB_ELEMENT_SIZE;
1299#else
1300 tdep->jb_pc = -1;
1301#endif
1304 tdep->struct_return = reg_struct_return;
1305
1306 /* Frame unwinder. */
1309
1310 /* Hook in the DWARF CFI frame unwinder. */
1312
1314
1315 /* Hook in ABI-specific overrides, if they have been registered. */
1317
1318 /* Now we have tuned the configuration, set a few final things,
1319 based on what the OS ABI has told us. */
1320
1321 if (tdep->jb_pc >= 0)
1323
1325
1326 if (tdesc_data != nullptr)
1327 tdesc_use_registers (gdbarch, info.target_desc, std::move (tdesc_data));
1328
1329 return gdbarch;
1330}
1331
1332
1333static void
1334m68k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
1335{
1336 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1337
1338 if (tdep == NULL)
1339 return;
1340}
1341
1342/* OSABI sniffer for m68k. */
1343
1344static enum gdb_osabi
1346{
1347 unsigned int elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
1348
1349 if (elfosabi == ELFOSABI_NONE)
1350 return GDB_OSABI_SVR4;
1351
1352 return GDB_OSABI_UNKNOWN;
1353}
1354
1355void _initialize_m68k_tdep ();
1356void
1358{
1360
1361 gdbarch_register_osabi_sniffer (bfd_arch_m68k, bfd_target_elf_flavour,
1363 gdbarch_register_osabi (bfd_arch_m68k, 0, GDB_OSABI_SVR4,
1365}
int regnum
int code
Definition ada-lex.l:688
gdb_static_assert(sizeof(splay_tree_key) >=sizeof(CORE_ADDR *))
static std::vector< const char * > arches
Definition arch-utils.c:685
void gdbarch_register(enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init, gdbarch_dump_tdep_ftype *dump_tdep)
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:605
gdbarch * arch() const
Definition regcache.c:230
void cooked_write(int regnum, const gdb_byte *buf)
Definition regcache.c:861
void raw_write_part(int regnum, int offset, int len, const gdb_byte *buf)
Definition regcache.c:1023
void raw_write(int regnum, const gdb_byte *buf)
Definition regcache.c:827
void * get(unsigned key)
Definition registry.h:211
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
Definition corefile.c:346
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition corefile.c:305
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition corefile.c:237
LONGEST read_memory_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition corefile.c:295
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
Definition defs.h:561
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
Definition findvar.c:153
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
Definition defs.h:526
return_value_convention
Definition defs.h:258
@ RETURN_VALUE_ABI_RETURNS_ADDRESS
Definition defs.h:274
@ RETURN_VALUE_REGISTER_CONVENTION
Definition defs.h:261
void dwarf2_append_unwinders(struct gdbarch *gdbarch)
Definition frame.c:1361
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:1351
CORE_ADDR get_frame_pc(frame_info_ptr frame)
Definition frame.c:2592
void get_frame_register(frame_info_ptr frame, int regnum, gdb_byte *buf)
Definition frame.c:1215
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition frame.c:713
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
Definition frame.c:2907
void frame_unwind_register(frame_info_ptr next_frame, int regnum, gdb_byte *buf)
Definition frame.c:1195
CORE_ADDR get_frame_func(frame_info_ptr this_frame)
Definition frame.c:1050
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:1432
void put_frame_register(frame_info_ptr frame, int regnum, const gdb_byte *buf)
Definition frame.c:1378
@ NORMAL_FRAME
Definition frame.h:179
#define FRAME_OBSTACK_ZALLOC(TYPE)
Definition frame.h:608
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2023
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:2050
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:1370
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:2848
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:2439
void set_gdbarch_fp0_regnum(struct gdbarch *gdbarch, int fp0_regnum)
Definition gdbarch.c:2067
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:2016
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2006
void set_gdbarch_long_double_format(struct gdbarch *gdbarch, const struct floatformat **long_double_format)
Definition gdbarch.c:1632
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
Definition gdbarch.c:2033
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:2057
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
Definition gdbarch.c:1910
void set_gdbarch_long_double_bit(struct gdbarch *gdbarch, int long_double_bit)
Definition gdbarch.c:1616
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:1691
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:2947
struct gdbarch * gdbarch_alloc(const struct gdbarch_info *info, struct gdbarch_tdep_base *tdep)
Definition gdbarch.c:264
function_call_return_method
Definition gdbarch.h:112
@ return_method_struct
Definition gdbarch.h:124
void append_flags_type_flag(struct type *type, int bitpos, const char *name)
Definition gdbtypes.c:5978
const struct floatformat * floatformats_m68881_ext[BFD_ENDIAN_UNKNOWN]
Definition gdbtypes.c:103
struct type * arch_flags_type(struct gdbarch *gdbarch, const char *name, int bit)
Definition gdbtypes.c:5935
struct type * arch_float_type(struct gdbarch *gdbarch, int bit, const char *name, const struct floatformat **floatformats)
Definition gdbtypes.c:5888
unsigned type_align(struct type *type)
Definition gdbtypes.c:3645
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
Definition gdbtypes.c:87
struct type * check_typedef(struct type *type)
Definition gdbtypes.c:3010
type_code
Definition gdbtypes.h:99
static void m68k_frame_this_id(frame_info_ptr this_frame, void **this_cache, struct frame_id *this_id)
Definition m68k-tdep.c:975
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:1117
void _initialize_m68k_tdep()
Definition m68k-tdep.c:1357
static CORE_ADDR m68k_unwind_pc(struct gdbarch *gdbarch, frame_info_ptr next_frame)
Definition m68k-tdep.c:899
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:462
static void m68k_store_return_value(struct type *type, struct regcache *regcache, const gdb_byte *valbuf)
Definition m68k-tdep.c:339
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:759
static struct type * m68k_register_type(struct gdbarch *gdbarch, int regnum)
Definition m68k-tdep.c:121
static void m68k_svr4_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *valbuf)
Definition m68k-tdep.c:319
void m68k_svr4_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition m68k-tdep.c:1099
static void m68k_dump_tdep(struct gdbarch *gdbarch, struct ui_file *file)
Definition m68k-tdep.c:1334
#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:533
static const struct frame_unwind m68k_frame_unwind
Definition m68k-tdep.c:1006
#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:989
static int m68k_dwarf_reg_to_regnum(struct gdbarch *gdbarch, int num)
Definition m68k-tdep.c:592
static CORE_ADDR m68k_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR start_pc)
Definition m68k-tdep.c:886
static int m68k_reg_struct_return_p(struct gdbarch *gdbarch, struct type *type)
Definition m68k-tdep.c:387
static enum gdb_osabi m68k_osabi_sniffer(bfd *abfd)
Definition m68k-tdep.c:1345
static const char * m68k_register_name(struct gdbarch *gdbarch, int regnum)
Definition m68k-tdep.c:172
#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:1090
#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:426
#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:232
static const struct frame_base m68k_frame_base
Definition m68k-tdep.c:1025
static int m68k_get_longjmp_target(frame_info_ptr frame, CORE_ADDR *pc)
Definition m68k-tdep.c:1051
#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:291
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:365
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:661
static struct gdbarch * m68k_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
Definition m68k-tdep.c:1132
static struct m68k_frame_cache * m68k_alloc_frame_cache(void)
Definition m68k-tdep.c:631
#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:205
#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:188
#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:1034
static const char *const m68k_register_names[]
Definition m68k-tdep.c:160
#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:861
#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:1018
#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:526
#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(c)
Definition gdbarch.py:184
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:643
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
struct type * builtin_int0
Definition gdbtypes.h:2280
struct type * builtin_double
Definition gdbtypes.h:2258
struct type * builtin_func_ptr
Definition gdbtypes.h:2314
struct type * builtin_data_ptr
Definition gdbtypes.h:2303
struct type * builtin_int32
Definition gdbtypes.h:2287
struct type * type() const
Definition gdbtypes.h:559
struct gdbarch * gdbarch
Definition gdbarch.h:241
struct gdbarch_list * next
Definition gdbarch.h:242
CORE_ADDR base
Definition m68k-tdep.c:616
CORE_ADDR sp_offset
Definition m68k-tdep.c:617
CORE_ADDR saved_sp
Definition m68k-tdep.c:622
CORE_ADDR saved_regs[M68K_NUM_REGS]
Definition m68k-tdep.c:621
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:1000
type_code code() const
Definition gdbtypes.h:927
ULONGEST length() const
Definition gdbtypes.h:954
struct field & field(int idx) const
Definition gdbtypes.h:983
bool is_vector() const
Definition gdbtypes.h:1149
int num_fields() const
Definition gdbtypes.h:965
Definition value.c:181
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:1771
struct type * value_type(const struct value *value)
Definition value.c:1109
gdb::array_view< const gdb_byte > value_contents_all(struct value *value)
Definition value.c:1284
struct type * value_enclosing_type(const struct value *value)
Definition value.c:1189