1 /* Target dependent code for the Motorola 68000 series.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001
3 Free Software Foundation, Inc.
5 This file is part of GDB.
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 2 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
27 #include "gdb_string.h"
30 #include "arch-utils.h"
33 #define P_LINKL_FP 0x480e
34 #define P_LINKW_FP 0x4e56
35 #define P_PEA_FP 0x4856
36 #define P_MOVL_SP_FP 0x2c4f
41 #define P_MOVML 0x48ef
42 #define P_FMOVM 0xf237
45 void m68k_frame_init_saved_regs (struct frame_info
*frame_info
);
47 /* Number of bytes of storage in the actual machine representation
48 for register regnum. On the 68000, all regs are 4 bytes
49 except the floating point regs which are 12 bytes. */
50 /* Note that the unsigned cast here forces the result of the
51 subtraction to very high positive values if regnum < FP0_REGNUM */
54 m68k_register_raw_size (int regnum
)
56 return (((unsigned) (regnum
) - FP0_REGNUM
) < 8 ? 12 : 4);
59 /* Number of bytes of storage in the program's representation
60 for register regnum. On the 68000, all regs are 4 bytes
61 except the floating point regs which are 12-byte long doubles. */
64 m68k_register_virtual_size (int regnum
)
66 return (((unsigned) (regnum
) - FP0_REGNUM
) < 8 ? 12 : 4);
69 /* Return the GDB type object for the "standard" data type of data
70 in register N. This should be int for D0-D7, long double for FP0-FP7,
71 and void pointer for all others (A0-A7, PC, SR, FPCONTROL etc).
72 Note, for registers which contain addresses return pointer to void,
73 not pointer to char, because we don't want to attempt to print
74 the string after printing the address. */
77 m68k_register_virtual_type (int regnum
)
79 if ((unsigned) regnum
>= FPC_REGNUM
)
80 return lookup_pointer_type (builtin_type_void
);
81 else if ((unsigned) regnum
>= FP0_REGNUM
)
82 return builtin_type_long_double
;
83 else if ((unsigned) regnum
>= A0_REGNUM
)
84 return lookup_pointer_type (builtin_type_void
);
86 return builtin_type_int
;
89 /* Function: m68k_register_name
90 Returns the name of the standard m68k register regnum. */
93 m68k_register_name (int regnum
)
95 static char *register_names
[] = {
96 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
97 "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp",
99 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
100 "fpcontrol", "fpstatus", "fpiaddr", "fpcode", "fpflags"
104 regnum
>= sizeof (register_names
) / sizeof (register_names
[0]))
105 internal_error (__FILE__
, __LINE__
,
106 "m68k_register_name: illegal register number %d", regnum
);
108 return register_names
[regnum
];
111 /* Stack must be kept short aligned when doing function calls. */
114 m68k_stack_align (CORE_ADDR addr
)
116 return ((addr
+ 1) & ~1);
119 /* Index within `registers' of the first byte of the space for
123 m68k_register_byte (int regnum
)
125 if (regnum
>= FPC_REGNUM
)
126 return (((regnum
- FPC_REGNUM
) * 4) + 168);
127 else if (regnum
>= FP0_REGNUM
)
128 return (((regnum
- FP0_REGNUM
) * 12) + 72);
133 /* The only reason this is here is the tm-altos.h reference below. It
134 was moved back here from tm-m68k.h. FIXME? */
137 altos_skip_prologue (CORE_ADDR pc
)
139 register int op
= read_memory_integer (pc
, 2);
140 if (op
== P_LINKW_FP
)
141 pc
+= 4; /* Skip link #word */
142 else if (op
== P_LINKL_FP
)
143 pc
+= 6; /* Skip link #long */
144 /* Not sure why branches are here. */
145 /* From tm-altos.h */
146 else if (op
== 0060000)
147 pc
+= 4; /* Skip bra #word */
148 else if (op
== 00600377)
149 pc
+= 6; /* skip bra #long */
150 else if ((op
& 0177400) == 0060000)
151 pc
+= 2; /* skip bra #char */
156 delta68_in_sigtramp (CORE_ADDR pc
, char *name
)
159 return strcmp (name
, "_sigcode") == 0;
165 delta68_frame_args_address (struct frame_info
*frame_info
)
167 /* we assume here that the only frameless functions are the system calls
168 or other functions who do not put anything on the stack. */
169 if (frame_info
->signal_handler_caller
)
170 return frame_info
->frame
+ 12;
171 else if (frameless_look_for_prologue (frame_info
))
173 /* Check for an interrupted system call */
174 if (frame_info
->next
&& frame_info
->next
->signal_handler_caller
)
175 return frame_info
->next
->frame
+ 16;
177 return frame_info
->frame
+ 4;
180 return frame_info
->frame
;
184 delta68_frame_saved_pc (struct frame_info
*frame_info
)
186 return read_memory_integer (delta68_frame_args_address (frame_info
) + 4, 4);
189 /* Return number of args passed to a frame.
190 Can return -1, meaning no way to tell. */
193 isi_frame_num_args (struct frame_info
*fi
)
196 CORE_ADDR pc
= FRAME_SAVED_PC (fi
);
197 int insn
= 0177777 & read_memory_integer (pc
, 2);
199 if (insn
== 0047757 || insn
== 0157374) /* lea W(sp),sp or addaw #W,sp */
200 val
= read_memory_integer (pc
+ 2, 2);
201 else if ((insn
& 0170777) == 0050217 /* addql #N, sp */
202 || (insn
& 0170777) == 0050117) /* addqw */
204 val
= (insn
>> 9) & 7;
208 else if (insn
== 0157774) /* addal #WW, sp */
209 val
= read_memory_integer (pc
+ 2, 4);
215 delta68_frame_num_args (struct frame_info
*fi
)
218 CORE_ADDR pc
= FRAME_SAVED_PC (fi
);
219 int insn
= 0177777 & read_memory_integer (pc
, 2);
221 if (insn
== 0047757 || insn
== 0157374) /* lea W(sp),sp or addaw #W,sp */
222 val
= read_memory_integer (pc
+ 2, 2);
223 else if ((insn
& 0170777) == 0050217 /* addql #N, sp */
224 || (insn
& 0170777) == 0050117) /* addqw */
226 val
= (insn
>> 9) & 7;
230 else if (insn
== 0157774) /* addal #WW, sp */
231 val
= read_memory_integer (pc
+ 2, 4);
237 news_frame_num_args (struct frame_info
*fi
)
240 CORE_ADDR pc
= FRAME_SAVED_PC (fi
);
241 int insn
= 0177777 & read_memory_integer (pc
, 2);
243 if (insn
== 0047757 || insn
== 0157374) /* lea W(sp),sp or addaw #W,sp */
244 val
= read_memory_integer (pc
+ 2, 2);
245 else if ((insn
& 0170777) == 0050217 /* addql #N, sp */
246 || (insn
& 0170777) == 0050117) /* addqw */
248 val
= (insn
>> 9) & 7;
252 else if (insn
== 0157774) /* addal #WW, sp */
253 val
= read_memory_integer (pc
+ 2, 4);
258 /* Insert the specified number of args and function address
259 into a call sequence of the above form stored at DUMMYNAME.
260 We use the BFD routines to store a big-endian value of known size. */
263 m68k_fix_call_dummy (char *dummy
, CORE_ADDR pc
, CORE_ADDR fun
, int nargs
,
264 struct value
**args
, struct type
*type
, int gcc_p
)
266 bfd_putb32 (fun
, (unsigned char *) dummy
+ CALL_DUMMY_START_OFFSET
+ 2);
267 bfd_putb32 (nargs
* 4,
268 (unsigned char *) dummy
+ CALL_DUMMY_START_OFFSET
+ 8);
272 /* Push an empty stack frame, to record the current PC, etc. */
275 m68k_push_dummy_frame (void)
277 register CORE_ADDR sp
= read_register (SP_REGNUM
);
281 sp
= push_word (sp
, read_register (PC_REGNUM
));
282 sp
= push_word (sp
, read_register (FP_REGNUM
));
283 write_register (FP_REGNUM
, sp
);
285 /* Always save the floating-point registers, whether they exist on
286 this target or not. */
287 for (regnum
= FP0_REGNUM
+ 7; regnum
>= FP0_REGNUM
; regnum
--)
289 read_register_bytes (REGISTER_BYTE (regnum
), raw_buffer
, 12);
290 sp
= push_bytes (sp
, raw_buffer
, 12);
293 for (regnum
= FP_REGNUM
- 1; regnum
>= 0; regnum
--)
295 sp
= push_word (sp
, read_register (regnum
));
297 sp
= push_word (sp
, read_register (PS_REGNUM
));
298 write_register (SP_REGNUM
, sp
);
301 /* Discard from the stack the innermost frame,
302 restoring all saved registers. */
305 m68k_pop_frame (void)
307 register struct frame_info
*frame
= get_current_frame ();
308 register CORE_ADDR fp
;
312 fp
= FRAME_FP (frame
);
313 m68k_frame_init_saved_regs (frame
);
314 for (regnum
= FP0_REGNUM
+ 7; regnum
>= FP0_REGNUM
; regnum
--)
316 if (frame
->saved_regs
[regnum
])
318 read_memory (frame
->saved_regs
[regnum
], raw_buffer
, 12);
319 write_register_bytes (REGISTER_BYTE (regnum
), raw_buffer
, 12);
322 for (regnum
= FP_REGNUM
- 1; regnum
>= 0; regnum
--)
324 if (frame
->saved_regs
[regnum
])
326 write_register (regnum
,
327 read_memory_integer (frame
->saved_regs
[regnum
], 4));
330 if (frame
->saved_regs
[PS_REGNUM
])
332 write_register (PS_REGNUM
,
333 read_memory_integer (frame
->saved_regs
[PS_REGNUM
], 4));
335 write_register (FP_REGNUM
, read_memory_integer (fp
, 4));
336 write_register (PC_REGNUM
, read_memory_integer (fp
+ 4, 4));
337 write_register (SP_REGNUM
, fp
+ 8);
338 flush_cached_frames ();
342 /* Given an ip value corresponding to the start of a function,
343 return the ip of the first instruction after the function
344 prologue. This is the generic m68k support. Machines which
345 require something different can override the SKIP_PROLOGUE
346 macro to point elsewhere.
348 Some instructions which typically may appear in a function
351 A link instruction, word form:
353 link.w %a6,&0 4e56 XXXX
355 A link instruction, long form:
357 link.l %fp,&F%1 480e XXXX XXXX
359 A movm instruction to preserve integer regs:
361 movm.l &M%1,(4,%sp) 48ef XXXX XXXX
363 A fmovm instruction to preserve float regs:
365 fmovm &FPM%1,(FPO%1,%sp) f237 XXXX XXXX XXXX XXXX
367 Some profiling setup code (FIXME, not recognized yet):
369 lea.l (.L3,%pc),%a1 43fb XXXX XXXX XXXX
370 bsr _mcount 61ff XXXX XXXX
375 m68k_skip_prologue (CORE_ADDR ip
)
377 register CORE_ADDR limit
;
378 struct symtab_and_line sal
;
381 /* Find out if there is a known limit for the extent of the prologue.
382 If so, ensure we don't go past it. If not, assume "infinity". */
384 sal
= find_pc_line (ip
, 0);
385 limit
= (sal
.end
) ? sal
.end
: (CORE_ADDR
) ~0;
389 op
= read_memory_integer (ip
, 2);
392 if (op
== P_LINKW_FP
)
393 ip
+= 4; /* Skip link.w */
394 else if (op
== P_PEA_FP
)
395 ip
+= 2; /* Skip pea %fp */
396 else if (op
== P_MOVL_SP_FP
)
397 ip
+= 2; /* Skip move.l %sp, %fp */
398 else if (op
== P_LINKL_FP
)
399 ip
+= 6; /* Skip link.l */
400 else if (op
== P_MOVML
)
401 ip
+= 6; /* Skip movm.l */
402 else if (op
== P_FMOVM
)
403 ip
+= 10; /* Skip fmovm */
405 break; /* Found unknown code, bail out. */
410 /* Store the addresses of the saved registers of the frame described by
411 FRAME_INFO in its saved_regs field.
412 This includes special registers such as pc and fp saved in special
413 ways in the stack frame. sp is even more special:
414 the address we return for it IS the sp for the next frame. */
417 m68k_frame_init_saved_regs (struct frame_info
*frame_info
)
420 register int regmask
;
421 register CORE_ADDR next_addr
;
422 register CORE_ADDR pc
;
424 /* First possible address for a pc in a call dummy for this frame. */
425 CORE_ADDR possible_call_dummy_start
=
426 (frame_info
)->frame
- 28 - FP_REGNUM
* 4 - 4 - 8 * 12;
430 if (frame_info
->saved_regs
)
433 frame_saved_regs_zalloc (frame_info
);
435 memset (frame_info
->saved_regs
, 0, SIZEOF_FRAME_SAVED_REGS
);
437 if ((frame_info
)->pc
>= possible_call_dummy_start
438 && (frame_info
)->pc
<= (frame_info
)->frame
)
441 /* It is a call dummy. We could just stop now, since we know
442 what the call dummy saves and where. But this code proceeds
443 to parse the "prologue" which is part of the call dummy.
444 This is needlessly complex and confusing. FIXME. */
446 next_addr
= (frame_info
)->frame
;
447 pc
= possible_call_dummy_start
;
451 pc
= get_pc_function_start ((frame_info
)->pc
);
453 nextinsn
= read_memory_integer (pc
, 2);
454 if (P_PEA_FP
== nextinsn
455 && P_MOVL_SP_FP
== read_memory_integer (pc
+ 2, 2))
459 next_addr
= frame_info
->frame
;
462 else if (P_LINKL_FP
== nextinsn
)
464 /* Find the address above the saved
465 regs using the amount of storage from the link instruction. */
467 next_addr
= (frame_info
)->frame
+ read_memory_integer (pc
+ 2, 4);
470 else if (P_LINKW_FP
== nextinsn
)
472 /* Find the address above the saved
473 regs using the amount of storage from the link instruction. */
475 next_addr
= (frame_info
)->frame
+ read_memory_integer (pc
+ 2, 2);
481 /* If have an addal #-n, sp next, adjust next_addr. */
482 if ((0177777 & read_memory_integer (pc
, 2)) == 0157774)
483 next_addr
+= read_memory_integer (pc
+= 2, 4), pc
+= 4;
488 nextinsn
= 0xffff & read_memory_integer (pc
, 2);
489 regmask
= read_memory_integer (pc
+ 2, 2);
490 /* fmovemx to -(sp) */
491 if (0xf227 == nextinsn
&& (regmask
& 0xff00) == 0xe000)
493 /* Regmask's low bit is for register fp7, the first pushed */
494 for (regnum
= FP0_REGNUM
+ 8; --regnum
>= FP0_REGNUM
; regmask
>>= 1)
496 frame_info
->saved_regs
[regnum
] = (next_addr
-= 12);
499 /* fmovemx to (fp + displacement) */
500 else if (0171056 == nextinsn
&& (regmask
& 0xff00) == 0xf000)
502 register CORE_ADDR addr
;
504 addr
= (frame_info
)->frame
+ read_memory_integer (pc
+ 4, 2);
505 /* Regmask's low bit is for register fp7, the first pushed */
506 for (regnum
= FP0_REGNUM
+ 8; --regnum
>= FP0_REGNUM
; regmask
>>= 1)
509 frame_info
->saved_regs
[regnum
] = addr
;
515 else if (0044327 == nextinsn
)
517 /* Regmask's low bit is for register 0, the first written */
518 for (regnum
= 0; regnum
< 16; regnum
++, regmask
>>= 1)
521 frame_info
->saved_regs
[regnum
] = next_addr
;
526 /* moveml to (fp + displacement) */
527 else if (0044356 == nextinsn
)
529 register CORE_ADDR addr
;
531 addr
= (frame_info
)->frame
+ read_memory_integer (pc
+ 4, 2);
532 /* Regmask's low bit is for register 0, the first written */
533 for (regnum
= 0; regnum
< 16; regnum
++, regmask
>>= 1)
536 frame_info
->saved_regs
[regnum
] = addr
;
541 /* moveml to -(sp) */
542 else if (0044347 == nextinsn
)
544 /* Regmask's low bit is for register 15, the first pushed */
545 for (regnum
= 16; --regnum
>= 0; regmask
>>= 1)
547 frame_info
->saved_regs
[regnum
] = (next_addr
-= 4);
551 else if (0x2f00 == (0xfff0 & nextinsn
))
553 regnum
= 0xf & nextinsn
;
554 frame_info
->saved_regs
[regnum
] = (next_addr
-= 4);
557 /* fmovemx to index of sp */
558 else if (0xf236 == nextinsn
&& (regmask
& 0xff00) == 0xf000)
560 /* Regmask's low bit is for register fp0, the first written */
561 for (regnum
= FP0_REGNUM
+ 8; --regnum
>= FP0_REGNUM
; regmask
>>= 1)
564 frame_info
->saved_regs
[regnum
] = next_addr
;
569 /* clrw -(sp); movw ccr,-(sp) */
570 else if (0x4267 == nextinsn
&& 0x42e7 == regmask
)
572 frame_info
->saved_regs
[PS_REGNUM
] = (next_addr
-= 4);
579 frame_info
->saved_regs
[SP_REGNUM
] = (frame_info
)->frame
+ 8;
580 frame_info
->saved_regs
[FP_REGNUM
] = (frame_info
)->frame
;
581 frame_info
->saved_regs
[PC_REGNUM
] = (frame_info
)->frame
+ 4;
582 #ifdef SIG_SP_FP_OFFSET
583 /* Adjust saved SP_REGNUM for fake _sigtramp frames. */
584 if (frame_info
->signal_handler_caller
&& frame_info
->next
)
585 frame_info
->saved_regs
[SP_REGNUM
] =
586 frame_info
->next
->frame
+ SIG_SP_FP_OFFSET
;
591 #ifdef USE_PROC_FS /* Target dependent support for /proc */
593 #include <sys/procfs.h>
595 /* Prototypes for supply_gregset etc. */
598 /* The /proc interface divides the target machine's register set up into
599 two different sets, the general register set (gregset) and the floating
600 point register set (fpregset). For each set, there is an ioctl to get
601 the current register set and another ioctl to set the current values.
603 The actual structure passed through the ioctl interface is, of course,
604 naturally machine dependent, and is different for each set of registers.
605 For the m68k for example, the general register set is typically defined
608 typedef int gregset_t[18];
614 and the floating point set by:
616 typedef struct fpregset {
620 int f_fpregs[8][3]; (8 regs, 96 bits each)
623 These routines provide the packing and unpacking of gregset_t and
624 fpregset_t formatted data.
628 /* Atari SVR4 has R_SR but not R_PS */
630 #if !defined (R_PS) && defined (R_SR)
634 /* Given a pointer to a general register set in /proc format (gregset_t *),
635 unpack the register contents and supply them as gdb's idea of the current
639 supply_gregset (gregset_t
*gregsetp
)
642 register greg_t
*regp
= (greg_t
*) gregsetp
;
644 for (regi
= 0; regi
< R_PC
; regi
++)
646 supply_register (regi
, (char *) (regp
+ regi
));
648 supply_register (PS_REGNUM
, (char *) (regp
+ R_PS
));
649 supply_register (PC_REGNUM
, (char *) (regp
+ R_PC
));
653 fill_gregset (gregset_t
*gregsetp
, int regno
)
656 register greg_t
*regp
= (greg_t
*) gregsetp
;
658 for (regi
= 0; regi
< R_PC
; regi
++)
660 if ((regno
== -1) || (regno
== regi
))
662 *(regp
+ regi
) = *(int *) ®isters
[REGISTER_BYTE (regi
)];
665 if ((regno
== -1) || (regno
== PS_REGNUM
))
667 *(regp
+ R_PS
) = *(int *) ®isters
[REGISTER_BYTE (PS_REGNUM
)];
669 if ((regno
== -1) || (regno
== PC_REGNUM
))
671 *(regp
+ R_PC
) = *(int *) ®isters
[REGISTER_BYTE (PC_REGNUM
)];
675 #if defined (FP0_REGNUM)
677 /* Given a pointer to a floating point register set in /proc format
678 (fpregset_t *), unpack the register contents and supply them as gdb's
679 idea of the current floating point register values. */
682 supply_fpregset (fpregset_t
*fpregsetp
)
687 for (regi
= FP0_REGNUM
; regi
< FPC_REGNUM
; regi
++)
689 from
= (char *) &(fpregsetp
->f_fpregs
[regi
- FP0_REGNUM
][0]);
690 supply_register (regi
, from
);
692 supply_register (FPC_REGNUM
, (char *) &(fpregsetp
->f_pcr
));
693 supply_register (FPS_REGNUM
, (char *) &(fpregsetp
->f_psr
));
694 supply_register (FPI_REGNUM
, (char *) &(fpregsetp
->f_fpiaddr
));
697 /* Given a pointer to a floating point register set in /proc format
698 (fpregset_t *), update the register specified by REGNO from gdb's idea
699 of the current floating point register set. If REGNO is -1, update
703 fill_fpregset (fpregset_t
*fpregsetp
, int regno
)
709 for (regi
= FP0_REGNUM
; regi
< FPC_REGNUM
; regi
++)
711 if ((regno
== -1) || (regno
== regi
))
713 from
= (char *) ®isters
[REGISTER_BYTE (regi
)];
714 to
= (char *) &(fpregsetp
->f_fpregs
[regi
- FP0_REGNUM
][0]);
715 memcpy (to
, from
, REGISTER_RAW_SIZE (regi
));
718 if ((regno
== -1) || (regno
== FPC_REGNUM
))
720 fpregsetp
->f_pcr
= *(int *) ®isters
[REGISTER_BYTE (FPC_REGNUM
)];
722 if ((regno
== -1) || (regno
== FPS_REGNUM
))
724 fpregsetp
->f_psr
= *(int *) ®isters
[REGISTER_BYTE (FPS_REGNUM
)];
726 if ((regno
== -1) || (regno
== FPI_REGNUM
))
728 fpregsetp
->f_fpiaddr
= *(int *) ®isters
[REGISTER_BYTE (FPI_REGNUM
)];
732 #endif /* defined (FP0_REGNUM) */
734 #endif /* USE_PROC_FS */
736 /* Figure out where the longjmp will land. Slurp the args out of the stack.
737 We expect the first arg to be a pointer to the jmp_buf structure from which
738 we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
739 This routine returns true on success. */
741 /* NOTE: cagney/2000-11-08: For this function to be fully multi-arched
742 the macro's JB_PC and JB_ELEMENT_SIZE would need to be moved into
743 the ``struct gdbarch_tdep'' object and then set on a target ISA/ABI
747 m68k_get_longjmp_target (CORE_ADDR
*pc
)
749 #if defined (JB_PC) && defined (JB_ELEMENT_SIZE)
751 CORE_ADDR sp
, jb_addr
;
753 buf
= alloca (TARGET_PTR_BIT
/ TARGET_CHAR_BIT
);
754 sp
= read_register (SP_REGNUM
);
756 if (target_read_memory (sp
+ SP_ARG0
, /* Offset of first arg on stack */
757 buf
, TARGET_PTR_BIT
/ TARGET_CHAR_BIT
))
760 jb_addr
= extract_address (buf
, TARGET_PTR_BIT
/ TARGET_CHAR_BIT
);
762 if (target_read_memory (jb_addr
+ JB_PC
* JB_ELEMENT_SIZE
, buf
,
763 TARGET_PTR_BIT
/ TARGET_CHAR_BIT
))
766 *pc
= extract_address (buf
, TARGET_PTR_BIT
/ TARGET_CHAR_BIT
);
770 internal_error (__FILE__
, __LINE__
,
771 "m68k_get_longjmp_target: not implemented");
776 /* Immediately after a function call, return the saved pc before the frame
777 is setup. For sun3's, we check for the common case of being inside of a
778 system call, and if so, we know that Sun pushes the call # on the stack
779 prior to doing the trap. */
782 m68k_saved_pc_after_call (struct frame_info
*frame
)
787 op
= read_memory_integer (frame
->pc
- SYSCALL_TRAP_OFFSET
, 2);
789 if (op
== SYSCALL_TRAP
)
790 return read_memory_integer (read_register (SP_REGNUM
) + 4, 4);
792 #endif /* SYSCALL_TRAP */
793 return read_memory_integer (read_register (SP_REGNUM
), 4);
796 /* Function: m68k_gdbarch_init
797 Initializer function for the m68k gdbarch vector.
798 Called by gdbarch. Sets up the gdbarch vector(s) for this target. */
800 static struct gdbarch
*
801 m68k_gdbarch_init (struct gdbarch_info info
, struct gdbarch_list
*arches
)
803 static LONGEST call_dummy_words
[7] = { 0xf227e0ff, 0x48e7fffc, 0x426742e7,
804 0x4eb93232, 0x3232dffc, 0x69696969,
805 (0x4e404e71 | (BPT_VECTOR
<< 16))
807 struct gdbarch_tdep
*tdep
= NULL
;
808 struct gdbarch
*gdbarch
;
810 /* find a candidate among the list of pre-declared architectures. */
811 arches
= gdbarch_list_lookup_by_info (arches
, &info
);
813 return (arches
->gdbarch
);
816 tdep
= (struct gdbarch_tdep
*) xmalloc (sizeof (struct gdbarch_tdep
));
819 gdbarch
= gdbarch_alloc (&info
, 0);
821 set_gdbarch_long_double_format (gdbarch
, &floatformat_m68881_ext
);
822 set_gdbarch_long_double_bit (gdbarch
, 96);
824 set_gdbarch_function_start_offset (gdbarch
, 0);
826 set_gdbarch_skip_prologue (gdbarch
, m68k_skip_prologue
);
827 set_gdbarch_saved_pc_after_call (gdbarch
, m68k_saved_pc_after_call
);
829 /* Stack grows down. */
830 set_gdbarch_inner_than (gdbarch
, core_addr_lessthan
);
831 set_gdbarch_stack_align (gdbarch
, m68k_stack_align
);
833 set_gdbarch_register_raw_size (gdbarch
, m68k_register_raw_size
);
834 set_gdbarch_register_virtual_size (gdbarch
, m68k_register_virtual_size
);
835 set_gdbarch_max_register_raw_size (gdbarch
, 12);
836 set_gdbarch_max_register_virtual_size (gdbarch
, 12);
837 set_gdbarch_register_virtual_type (gdbarch
, m68k_register_virtual_type
);
838 set_gdbarch_register_name (gdbarch
, m68k_register_name
);
839 set_gdbarch_register_size (gdbarch
, 4);
840 set_gdbarch_register_byte (gdbarch
, m68k_register_byte
);
842 set_gdbarch_frame_init_saved_regs (gdbarch
, m68k_frame_init_saved_regs
);
844 set_gdbarch_use_generic_dummy_frames (gdbarch
, 0);
845 set_gdbarch_call_dummy_location (gdbarch
, ON_STACK
);
846 set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch
, 1);
847 set_gdbarch_call_dummy_breakpoint_offset (gdbarch
, 24);
848 set_gdbarch_pc_in_call_dummy (gdbarch
, pc_in_call_dummy_on_stack
);
849 set_gdbarch_call_dummy_p (gdbarch
, 1);
850 set_gdbarch_call_dummy_stack_adjust_p (gdbarch
, 0);
851 set_gdbarch_call_dummy_length (gdbarch
, 28);
852 set_gdbarch_call_dummy_start_offset (gdbarch
, 12);
854 set_gdbarch_call_dummy_words (gdbarch
, call_dummy_words
);
855 set_gdbarch_sizeof_call_dummy_words (gdbarch
, sizeof (call_dummy_words
));
856 set_gdbarch_call_dummy_stack_adjust_p (gdbarch
, 0);
857 set_gdbarch_fix_call_dummy (gdbarch
, m68k_fix_call_dummy
);
858 set_gdbarch_push_dummy_frame (gdbarch
, m68k_push_dummy_frame
);
859 set_gdbarch_pop_frame (gdbarch
, m68k_pop_frame
);
866 m68k_dump_tdep (struct gdbarch
*current_gdbarch
, struct ui_file
*file
)
872 _initialize_m68k_tdep (void)
874 gdbarch_register (bfd_arch_m68k
, m68k_gdbarch_init
, m68k_dump_tdep
);
875 tm_print_insn
= print_insn_m68k
;