]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Target dependent code for the Motorola 68000 series. |
b6ba6518 | 2 | Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001 |
a1de33a8 | 3 | Free Software Foundation, Inc. |
c906108c | 4 | |
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
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. | |
c906108c | 11 | |
c5aa993b JM |
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. | |
c906108c | 16 | |
c5aa993b JM |
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. */ | |
c906108c SS |
21 | |
22 | #include "defs.h" | |
23 | #include "frame.h" | |
24 | #include "symtab.h" | |
25 | #include "gdbcore.h" | |
26 | #include "value.h" | |
27 | #include "gdb_string.h" | |
7a292a7a | 28 | #include "inferior.h" |
4e052eda | 29 | #include "regcache.h" |
5d3ed2e3 | 30 | #include "arch-utils.h" |
32eeb91a AS |
31 | |
32 | #include "m68k-tdep.h" | |
c906108c | 33 | \f |
c5aa993b | 34 | |
89c3b6d3 PDM |
35 | #define P_LINKL_FP 0x480e |
36 | #define P_LINKW_FP 0x4e56 | |
37 | #define P_PEA_FP 0x4856 | |
38 | #define P_MOVL_SP_FP 0x2c4f | |
39 | #define P_MOVL 0x207c | |
40 | #define P_JSR 0x4eb9 | |
41 | #define P_BSR 0x61ff | |
42 | #define P_LEAL 0x43fb | |
43 | #define P_MOVML 0x48ef | |
44 | #define P_FMOVM 0xf237 | |
45 | #define P_TRAP 0x4e40 | |
46 | ||
103a1597 | 47 | |
103a1597 GS |
48 | #define REGISTER_BYTES_FP (16*4 + 8 + 8*12 + 3*4) |
49 | #define REGISTER_BYTES_NOFP (16*4 + 8) | |
50 | ||
51 | #define NUM_FREGS (NUM_REGS-24) | |
52 | ||
53 | /* Offset from SP to first arg on stack at first instruction of a function */ | |
54 | ||
55 | #define SP_ARG0 (1 * 4) | |
56 | ||
57 | /* This was determined by experimentation on hp300 BSD 4.3. Perhaps | |
58 | it corresponds to some offset in /usr/include/sys/user.h or | |
59 | something like that. Using some system include file would | |
60 | have the advantage of probably being more robust in the face | |
61 | of OS upgrades, but the disadvantage of being wrong for | |
62 | cross-debugging. */ | |
63 | ||
64 | #define SIG_PC_FP_OFFSET 530 | |
65 | ||
66 | #define TARGET_M68K | |
67 | ||
68 | ||
69 | #if !defined (BPT_VECTOR) | |
70 | #define BPT_VECTOR 0xf | |
71 | #endif | |
72 | ||
73 | #if !defined (REMOTE_BPT_VECTOR) | |
74 | #define REMOTE_BPT_VECTOR 1 | |
75 | #endif | |
76 | ||
77 | ||
7f8e7424 GS |
78 | void m68k_frame_init_saved_regs (struct frame_info *frame_info); |
79 | ||
103a1597 GS |
80 | |
81 | /* gdbarch_breakpoint_from_pc is set to m68k_local_breakpoint_from_pc | |
82 | so m68k_remote_breakpoint_from_pc is currently not used. */ | |
83 | ||
84 | const static unsigned char * | |
85 | m68k_remote_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr) | |
86 | { | |
87 | static unsigned char break_insn[] = {0x4e, (0x40 | REMOTE_BPT_VECTOR)}; | |
88 | *lenptr = sizeof (break_insn); | |
89 | return break_insn; | |
90 | } | |
91 | ||
92 | const static unsigned char * | |
93 | m68k_local_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr) | |
94 | { | |
95 | static unsigned char break_insn[] = {0x4e, (0x40 | BPT_VECTOR)}; | |
96 | *lenptr = sizeof (break_insn); | |
97 | return break_insn; | |
98 | } | |
99 | ||
100 | ||
942dc0e9 | 101 | static int |
5ae5f592 | 102 | m68k_register_bytes_ok (long numbytes) |
942dc0e9 GS |
103 | { |
104 | return ((numbytes == REGISTER_BYTES_FP) | |
105 | || (numbytes == REGISTER_BYTES_NOFP)); | |
106 | } | |
107 | ||
5d3ed2e3 GS |
108 | /* Number of bytes of storage in the actual machine representation |
109 | for register regnum. On the 68000, all regs are 4 bytes | |
110 | except the floating point regs which are 12 bytes. */ | |
111 | /* Note that the unsigned cast here forces the result of the | |
112 | subtraction to very high positive values if regnum < FP0_REGNUM */ | |
113 | ||
114 | static int | |
115 | m68k_register_raw_size (int regnum) | |
116 | { | |
117 | return (((unsigned) (regnum) - FP0_REGNUM) < 8 ? 12 : 4); | |
118 | } | |
119 | ||
120 | /* Number of bytes of storage in the program's representation | |
121 | for register regnum. On the 68000, all regs are 4 bytes | |
122 | except the floating point regs which are 12-byte long doubles. */ | |
123 | ||
124 | static int | |
125 | m68k_register_virtual_size (int regnum) | |
126 | { | |
127 | return (((unsigned) (regnum) - FP0_REGNUM) < 8 ? 12 : 4); | |
128 | } | |
129 | ||
d85fe7f7 AS |
130 | /* Return the GDB type object for the "standard" data type of data in |
131 | register N. This should be int for D0-D7, SR, FPCONTROL and | |
132 | FPSTATUS, long double for FP0-FP7, and void pointer for all others | |
133 | (A0-A7, PC, FPIADDR). Note, for registers which contain | |
134 | addresses return pointer to void, not pointer to char, because we | |
135 | don't want to attempt to print the string after printing the | |
136 | address. */ | |
5d3ed2e3 GS |
137 | |
138 | static struct type * | |
139 | m68k_register_virtual_type (int regnum) | |
140 | { | |
03dac896 AS |
141 | if (regnum >= FP0_REGNUM && regnum <= FP0_REGNUM + 7) |
142 | return builtin_type_m68881_ext; | |
143 | ||
32eeb91a | 144 | if (regnum == M68K_FPI_REGNUM || regnum == PC_REGNUM) |
03dac896 AS |
145 | return builtin_type_void_func_ptr; |
146 | ||
32eeb91a AS |
147 | if (regnum == M68K_FPC_REGNUM || regnum == M68K_FPS_REGNUM |
148 | || regnum == PS_REGNUM) | |
03dac896 AS |
149 | return builtin_type_int32; |
150 | ||
32eeb91a | 151 | if (regnum >= M68K_A0_REGNUM && regnum <= M68K_A0_REGNUM + 7) |
03dac896 AS |
152 | return builtin_type_void_data_ptr; |
153 | ||
154 | return builtin_type_int32; | |
5d3ed2e3 GS |
155 | } |
156 | ||
157 | /* Function: m68k_register_name | |
158 | Returns the name of the standard m68k register regnum. */ | |
159 | ||
160 | static const char * | |
161 | m68k_register_name (int regnum) | |
162 | { | |
163 | static char *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", "fpcode", "fpflags" | |
169 | }; | |
170 | ||
171 | if (regnum < 0 || | |
172 | regnum >= sizeof (register_names) / sizeof (register_names[0])) | |
173 | internal_error (__FILE__, __LINE__, | |
174 | "m68k_register_name: illegal register number %d", regnum); | |
175 | else | |
176 | return register_names[regnum]; | |
177 | } | |
178 | ||
179 | /* Stack must be kept short aligned when doing function calls. */ | |
180 | ||
181 | static CORE_ADDR | |
182 | m68k_stack_align (CORE_ADDR addr) | |
183 | { | |
184 | return ((addr + 1) & ~1); | |
185 | } | |
186 | ||
187 | /* Index within `registers' of the first byte of the space for | |
188 | register regnum. */ | |
189 | ||
190 | static int | |
191 | m68k_register_byte (int regnum) | |
192 | { | |
32eeb91a AS |
193 | if (regnum >= M68K_FPC_REGNUM) |
194 | return (((regnum - M68K_FPC_REGNUM) * 4) + 168); | |
5d3ed2e3 GS |
195 | else if (regnum >= FP0_REGNUM) |
196 | return (((regnum - FP0_REGNUM) * 12) + 72); | |
197 | else | |
198 | return (regnum * 4); | |
199 | } | |
200 | ||
942dc0e9 GS |
201 | /* Store the address of the place in which to copy the structure the |
202 | subroutine will return. This is called from call_function. */ | |
203 | ||
204 | static void | |
205 | m68k_store_struct_return (CORE_ADDR addr, CORE_ADDR sp) | |
206 | { | |
32eeb91a | 207 | write_register (M68K_A1_REGNUM, addr); |
942dc0e9 GS |
208 | } |
209 | ||
210 | /* Extract from an array regbuf containing the (raw) register state | |
211 | a function return value of type type, and copy that, in virtual format, | |
212 | into valbuf. This is assuming that floating point values are returned | |
213 | as doubles in d0/d1. */ | |
214 | ||
215 | static void | |
216 | m68k_deprecated_extract_return_value (struct type *type, char *regbuf, | |
217 | char *valbuf) | |
218 | { | |
219 | int offset = 0; | |
220 | int typeLength = TYPE_LENGTH (type); | |
221 | ||
222 | if (typeLength < 4) | |
223 | offset = 4 - typeLength; | |
224 | ||
225 | memcpy (valbuf, regbuf + offset, typeLength); | |
226 | } | |
227 | ||
228 | static CORE_ADDR | |
229 | m68k_deprecated_extract_struct_value_address (char *regbuf) | |
230 | { | |
231 | return (*(CORE_ADDR *) (regbuf)); | |
232 | } | |
233 | ||
234 | /* Write into appropriate registers a function return value | |
235 | of type TYPE, given in virtual format. Assumes floats are passed | |
236 | in d0/d1. */ | |
237 | ||
238 | static void | |
239 | m68k_store_return_value (struct type *type, char *valbuf) | |
240 | { | |
73937e03 | 241 | deprecated_write_register_bytes (0, valbuf, TYPE_LENGTH (type)); |
942dc0e9 GS |
242 | } |
243 | ||
244 | /* Describe the pointer in each stack frame to the previous stack frame | |
245 | (its caller). */ | |
246 | ||
247 | /* FRAME_CHAIN takes a frame's nominal address and produces the frame's | |
248 | chain-pointer. | |
249 | In the case of the 68000, the frame's nominal address | |
250 | is the address of a 4-byte word containing the calling frame's address. */ | |
251 | ||
252 | /* If we are chaining from sigtramp, then manufacture a sigtramp frame | |
253 | (which isn't really on the stack. I'm not sure this is right for anything | |
254 | but BSD4.3 on an hp300. */ | |
255 | ||
256 | static CORE_ADDR | |
257 | m68k_frame_chain (struct frame_info *thisframe) | |
258 | { | |
32eeb91a | 259 | if (get_frame_type (thisframe) == SIGTRAMP_FRAME) |
942dc0e9 | 260 | return thisframe->frame; |
32eeb91a AS |
261 | else if (!inside_entry_file (thisframe->pc)) |
262 | return read_memory_integer (thisframe->frame, 4); | |
942dc0e9 GS |
263 | else |
264 | return 0; | |
265 | } | |
266 | ||
267 | /* A function that tells us whether the function invocation represented | |
268 | by fi does not have a frame on the stack associated with it. If it | |
269 | does not, FRAMELESS is set to 1, else 0. */ | |
270 | ||
271 | static int | |
272 | m68k_frameless_function_invocation (struct frame_info *fi) | |
273 | { | |
32eeb91a | 274 | if (get_frame_type (fi) == SIGTRAMP_FRAME) |
942dc0e9 GS |
275 | return 0; |
276 | else | |
277 | return frameless_look_for_prologue (fi); | |
278 | } | |
279 | ||
280 | static CORE_ADDR | |
281 | m68k_frame_saved_pc (struct frame_info *frame) | |
282 | { | |
32eeb91a | 283 | if (get_frame_type (frame) == SIGTRAMP_FRAME) |
942dc0e9 GS |
284 | { |
285 | if (frame->next) | |
286 | return read_memory_integer (frame->next->frame + SIG_PC_FP_OFFSET, 4); | |
287 | else | |
288 | return read_memory_integer (read_register (SP_REGNUM) | |
289 | + SIG_PC_FP_OFFSET - 8, 4); | |
290 | } | |
291 | else | |
292 | return read_memory_integer (frame->frame + 4, 4); | |
293 | } | |
294 | ||
295 | ||
b83266a0 SS |
296 | /* The only reason this is here is the tm-altos.h reference below. It |
297 | was moved back here from tm-m68k.h. FIXME? */ | |
298 | ||
299 | extern CORE_ADDR | |
fba45db2 | 300 | altos_skip_prologue (CORE_ADDR pc) |
b83266a0 SS |
301 | { |
302 | register int op = read_memory_integer (pc, 2); | |
89c3b6d3 | 303 | if (op == P_LINKW_FP) |
c5aa993b | 304 | pc += 4; /* Skip link #word */ |
89c3b6d3 | 305 | else if (op == P_LINKL_FP) |
c5aa993b | 306 | pc += 6; /* Skip link #long */ |
b83266a0 | 307 | /* Not sure why branches are here. */ |
514e603d | 308 | /* From tm-altos.h */ |
b83266a0 | 309 | else if (op == 0060000) |
c5aa993b | 310 | pc += 4; /* Skip bra #word */ |
b83266a0 | 311 | else if (op == 00600377) |
c5aa993b | 312 | pc += 6; /* skip bra #long */ |
b83266a0 | 313 | else if ((op & 0177400) == 0060000) |
c5aa993b | 314 | pc += 2; /* skip bra #char */ |
b83266a0 SS |
315 | return pc; |
316 | } | |
317 | ||
89c3b6d3 | 318 | int |
fba45db2 | 319 | delta68_in_sigtramp (CORE_ADDR pc, char *name) |
89c3b6d3 | 320 | { |
1bd54964 AC |
321 | if (name != NULL) |
322 | return strcmp (name, "_sigcode") == 0; | |
323 | else | |
324 | return 0; | |
89c3b6d3 PDM |
325 | } |
326 | ||
327 | CORE_ADDR | |
fba45db2 | 328 | delta68_frame_args_address (struct frame_info *frame_info) |
89c3b6d3 PDM |
329 | { |
330 | /* we assume here that the only frameless functions are the system calls | |
331 | or other functions who do not put anything on the stack. */ | |
32eeb91a | 332 | if (get_frame_type (frame_info) == SIGTRAMP_FRAME) |
89c3b6d3 PDM |
333 | return frame_info->frame + 12; |
334 | else if (frameless_look_for_prologue (frame_info)) | |
335 | { | |
b5d78d39 | 336 | /* Check for an interrupted system call */ |
5a203e44 | 337 | if (frame_info->next && (get_frame_type (frame_info->next) == SIGTRAMP_FRAME)) |
b5d78d39 GS |
338 | return frame_info->next->frame + 16; |
339 | else | |
340 | return frame_info->frame + 4; | |
89c3b6d3 PDM |
341 | } |
342 | else | |
343 | return frame_info->frame; | |
344 | } | |
345 | ||
346 | CORE_ADDR | |
fba45db2 | 347 | delta68_frame_saved_pc (struct frame_info *frame_info) |
89c3b6d3 PDM |
348 | { |
349 | return read_memory_integer (delta68_frame_args_address (frame_info) + 4, 4); | |
350 | } | |
351 | ||
392a587b JM |
352 | /* Return number of args passed to a frame. |
353 | Can return -1, meaning no way to tell. */ | |
354 | ||
355 | int | |
fba45db2 | 356 | isi_frame_num_args (struct frame_info *fi) |
392a587b JM |
357 | { |
358 | int val; | |
359 | CORE_ADDR pc = FRAME_SAVED_PC (fi); | |
360 | int insn = 0177777 & read_memory_integer (pc, 2); | |
361 | val = 0; | |
c5aa993b | 362 | if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ |
392a587b | 363 | val = read_memory_integer (pc + 2, 2); |
c5aa993b JM |
364 | else if ((insn & 0170777) == 0050217 /* addql #N, sp */ |
365 | || (insn & 0170777) == 0050117) /* addqw */ | |
392a587b JM |
366 | { |
367 | val = (insn >> 9) & 7; | |
368 | if (val == 0) | |
369 | val = 8; | |
370 | } | |
c5aa993b | 371 | else if (insn == 0157774) /* addal #WW, sp */ |
392a587b JM |
372 | val = read_memory_integer (pc + 2, 4); |
373 | val >>= 2; | |
374 | return val; | |
375 | } | |
376 | ||
377 | int | |
fba45db2 | 378 | delta68_frame_num_args (struct frame_info *fi) |
392a587b JM |
379 | { |
380 | int val; | |
381 | CORE_ADDR pc = FRAME_SAVED_PC (fi); | |
382 | int insn = 0177777 & read_memory_integer (pc, 2); | |
383 | val = 0; | |
c5aa993b | 384 | if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ |
392a587b | 385 | val = read_memory_integer (pc + 2, 2); |
c5aa993b JM |
386 | else if ((insn & 0170777) == 0050217 /* addql #N, sp */ |
387 | || (insn & 0170777) == 0050117) /* addqw */ | |
392a587b JM |
388 | { |
389 | val = (insn >> 9) & 7; | |
390 | if (val == 0) | |
391 | val = 8; | |
392 | } | |
c5aa993b | 393 | else if (insn == 0157774) /* addal #WW, sp */ |
392a587b JM |
394 | val = read_memory_integer (pc + 2, 4); |
395 | val >>= 2; | |
396 | return val; | |
397 | } | |
398 | ||
399 | int | |
fba45db2 | 400 | news_frame_num_args (struct frame_info *fi) |
392a587b JM |
401 | { |
402 | int val; | |
403 | CORE_ADDR pc = FRAME_SAVED_PC (fi); | |
404 | int insn = 0177777 & read_memory_integer (pc, 2); | |
405 | val = 0; | |
c5aa993b | 406 | if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ |
392a587b | 407 | val = read_memory_integer (pc + 2, 2); |
c5aa993b JM |
408 | else if ((insn & 0170777) == 0050217 /* addql #N, sp */ |
409 | || (insn & 0170777) == 0050117) /* addqw */ | |
392a587b JM |
410 | { |
411 | val = (insn >> 9) & 7; | |
412 | if (val == 0) | |
413 | val = 8; | |
414 | } | |
c5aa993b | 415 | else if (insn == 0157774) /* addal #WW, sp */ |
392a587b JM |
416 | val = read_memory_integer (pc + 2, 4); |
417 | val >>= 2; | |
418 | return val; | |
419 | } | |
b83266a0 | 420 | |
7f8e7424 GS |
421 | /* Insert the specified number of args and function address |
422 | into a call sequence of the above form stored at DUMMYNAME. | |
423 | We use the BFD routines to store a big-endian value of known size. */ | |
424 | ||
425 | void | |
a2c6a6d5 GS |
426 | m68k_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs, |
427 | struct value **args, struct type *type, int gcc_p) | |
7f8e7424 | 428 | { |
a2c6a6d5 GS |
429 | bfd_putb32 (fun, (unsigned char *) dummy + CALL_DUMMY_START_OFFSET + 2); |
430 | bfd_putb32 (nargs * 4, | |
431 | (unsigned char *) dummy + CALL_DUMMY_START_OFFSET + 8); | |
7f8e7424 GS |
432 | } |
433 | ||
434 | ||
c906108c SS |
435 | /* Push an empty stack frame, to record the current PC, etc. */ |
436 | ||
437 | void | |
fba45db2 | 438 | m68k_push_dummy_frame (void) |
c906108c SS |
439 | { |
440 | register CORE_ADDR sp = read_register (SP_REGNUM); | |
441 | register int regnum; | |
442 | char raw_buffer[12]; | |
443 | ||
444 | sp = push_word (sp, read_register (PC_REGNUM)); | |
445 | sp = push_word (sp, read_register (FP_REGNUM)); | |
446 | write_register (FP_REGNUM, sp); | |
447 | ||
448 | /* Always save the floating-point registers, whether they exist on | |
449 | this target or not. */ | |
450 | for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) | |
451 | { | |
73937e03 | 452 | deprecated_read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); |
c906108c SS |
453 | sp = push_bytes (sp, raw_buffer, 12); |
454 | } | |
455 | ||
456 | for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) | |
457 | { | |
458 | sp = push_word (sp, read_register (regnum)); | |
459 | } | |
460 | sp = push_word (sp, read_register (PS_REGNUM)); | |
461 | write_register (SP_REGNUM, sp); | |
462 | } | |
463 | ||
464 | /* Discard from the stack the innermost frame, | |
465 | restoring all saved registers. */ | |
466 | ||
467 | void | |
fba45db2 | 468 | m68k_pop_frame (void) |
c906108c SS |
469 | { |
470 | register struct frame_info *frame = get_current_frame (); | |
471 | register CORE_ADDR fp; | |
472 | register int regnum; | |
c906108c SS |
473 | char raw_buffer[12]; |
474 | ||
c193f6ac | 475 | fp = get_frame_base (frame); |
7f8e7424 | 476 | m68k_frame_init_saved_regs (frame); |
c5aa993b | 477 | for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) |
c906108c | 478 | { |
7f8e7424 | 479 | if (frame->saved_regs[regnum]) |
c906108c | 480 | { |
7f8e7424 | 481 | read_memory (frame->saved_regs[regnum], raw_buffer, 12); |
73937e03 AC |
482 | deprecated_write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, |
483 | 12); | |
c906108c SS |
484 | } |
485 | } | |
c5aa993b | 486 | for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) |
c906108c | 487 | { |
7f8e7424 | 488 | if (frame->saved_regs[regnum]) |
c906108c | 489 | { |
a2c6a6d5 GS |
490 | write_register (regnum, |
491 | read_memory_integer (frame->saved_regs[regnum], 4)); | |
c906108c SS |
492 | } |
493 | } | |
7f8e7424 | 494 | if (frame->saved_regs[PS_REGNUM]) |
c906108c | 495 | { |
b5d78d39 | 496 | write_register (PS_REGNUM, |
7f8e7424 | 497 | read_memory_integer (frame->saved_regs[PS_REGNUM], 4)); |
c906108c SS |
498 | } |
499 | write_register (FP_REGNUM, read_memory_integer (fp, 4)); | |
500 | write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); | |
501 | write_register (SP_REGNUM, fp + 8); | |
502 | flush_cached_frames (); | |
503 | } | |
c906108c | 504 | \f |
c5aa993b | 505 | |
c906108c SS |
506 | /* Given an ip value corresponding to the start of a function, |
507 | return the ip of the first instruction after the function | |
508 | prologue. This is the generic m68k support. Machines which | |
509 | require something different can override the SKIP_PROLOGUE | |
510 | macro to point elsewhere. | |
511 | ||
512 | Some instructions which typically may appear in a function | |
513 | prologue include: | |
514 | ||
515 | A link instruction, word form: | |
516 | ||
c5aa993b | 517 | link.w %a6,&0 4e56 XXXX |
c906108c SS |
518 | |
519 | A link instruction, long form: | |
520 | ||
c5aa993b | 521 | link.l %fp,&F%1 480e XXXX XXXX |
c906108c SS |
522 | |
523 | A movm instruction to preserve integer regs: | |
524 | ||
c5aa993b | 525 | movm.l &M%1,(4,%sp) 48ef XXXX XXXX |
c906108c SS |
526 | |
527 | A fmovm instruction to preserve float regs: | |
528 | ||
c5aa993b | 529 | fmovm &FPM%1,(FPO%1,%sp) f237 XXXX XXXX XXXX XXXX |
c906108c SS |
530 | |
531 | Some profiling setup code (FIXME, not recognized yet): | |
532 | ||
c5aa993b JM |
533 | lea.l (.L3,%pc),%a1 43fb XXXX XXXX XXXX |
534 | bsr _mcount 61ff XXXX XXXX | |
c906108c | 535 | |
c5aa993b | 536 | */ |
c906108c | 537 | |
c906108c | 538 | CORE_ADDR |
fba45db2 | 539 | m68k_skip_prologue (CORE_ADDR ip) |
c906108c SS |
540 | { |
541 | register CORE_ADDR limit; | |
542 | struct symtab_and_line sal; | |
543 | register int op; | |
544 | ||
545 | /* Find out if there is a known limit for the extent of the prologue. | |
546 | If so, ensure we don't go past it. If not, assume "infinity". */ | |
547 | ||
548 | sal = find_pc_line (ip, 0); | |
b5d78d39 | 549 | limit = (sal.end) ? sal.end : (CORE_ADDR) ~0; |
c906108c SS |
550 | |
551 | while (ip < limit) | |
552 | { | |
553 | op = read_memory_integer (ip, 2); | |
554 | op &= 0xFFFF; | |
c5aa993b | 555 | |
89c3b6d3 PDM |
556 | if (op == P_LINKW_FP) |
557 | ip += 4; /* Skip link.w */ | |
558 | else if (op == P_PEA_FP) | |
c5aa993b | 559 | ip += 2; /* Skip pea %fp */ |
89c3b6d3 | 560 | else if (op == P_MOVL_SP_FP) |
c5aa993b | 561 | ip += 2; /* Skip move.l %sp, %fp */ |
89c3b6d3 PDM |
562 | else if (op == P_LINKL_FP) |
563 | ip += 6; /* Skip link.l */ | |
564 | else if (op == P_MOVML) | |
565 | ip += 6; /* Skip movm.l */ | |
c906108c | 566 | else if (op == P_FMOVM) |
89c3b6d3 | 567 | ip += 10; /* Skip fmovm */ |
c906108c | 568 | else |
b5d78d39 | 569 | break; /* Found unknown code, bail out. */ |
c906108c SS |
570 | } |
571 | return (ip); | |
572 | } | |
573 | ||
7f8e7424 GS |
574 | /* Store the addresses of the saved registers of the frame described by |
575 | FRAME_INFO in its saved_regs field. | |
576 | This includes special registers such as pc and fp saved in special | |
577 | ways in the stack frame. sp is even more special: | |
578 | the address we return for it IS the sp for the next frame. */ | |
579 | ||
c906108c | 580 | void |
7f8e7424 | 581 | m68k_frame_init_saved_regs (struct frame_info *frame_info) |
c906108c | 582 | { |
c5aa993b JM |
583 | register int regnum; |
584 | register int regmask; | |
585 | register CORE_ADDR next_addr; | |
c906108c SS |
586 | register CORE_ADDR pc; |
587 | ||
588 | /* First possible address for a pc in a call dummy for this frame. */ | |
589 | CORE_ADDR possible_call_dummy_start = | |
7f8e7424 | 590 | (frame_info)->frame - 28 - FP_REGNUM * 4 - 4 - 8 * 12; |
c906108c SS |
591 | |
592 | int nextinsn; | |
7f8e7424 GS |
593 | |
594 | if (frame_info->saved_regs) | |
595 | return; | |
596 | ||
597 | frame_saved_regs_zalloc (frame_info); | |
598 | ||
599 | memset (frame_info->saved_regs, 0, SIZEOF_FRAME_SAVED_REGS); | |
600 | ||
c906108c SS |
601 | if ((frame_info)->pc >= possible_call_dummy_start |
602 | && (frame_info)->pc <= (frame_info)->frame) | |
603 | { | |
604 | ||
605 | /* It is a call dummy. We could just stop now, since we know | |
c5aa993b JM |
606 | what the call dummy saves and where. But this code proceeds |
607 | to parse the "prologue" which is part of the call dummy. | |
608 | This is needlessly complex and confusing. FIXME. */ | |
c906108c SS |
609 | |
610 | next_addr = (frame_info)->frame; | |
611 | pc = possible_call_dummy_start; | |
612 | } | |
c5aa993b | 613 | else |
c906108c | 614 | { |
c5aa993b | 615 | pc = get_pc_function_start ((frame_info)->pc); |
c906108c | 616 | |
89c3b6d3 PDM |
617 | nextinsn = read_memory_integer (pc, 2); |
618 | if (P_PEA_FP == nextinsn | |
619 | && P_MOVL_SP_FP == read_memory_integer (pc + 2, 2)) | |
c906108c | 620 | { |
89c3b6d3 | 621 | /* pea %fp |
c5aa993b | 622 | move.l %sp, %fp */ |
c906108c | 623 | next_addr = frame_info->frame; |
89c3b6d3 | 624 | pc += 4; |
c906108c | 625 | } |
89c3b6d3 | 626 | else if (P_LINKL_FP == nextinsn) |
c906108c SS |
627 | /* link.l %fp */ |
628 | /* Find the address above the saved | |
629 | regs using the amount of storage from the link instruction. */ | |
89c3b6d3 PDM |
630 | { |
631 | next_addr = (frame_info)->frame + read_memory_integer (pc + 2, 4); | |
632 | pc += 6; | |
633 | } | |
634 | else if (P_LINKW_FP == nextinsn) | |
c906108c SS |
635 | /* link.w %fp */ |
636 | /* Find the address above the saved | |
637 | regs using the amount of storage from the link instruction. */ | |
89c3b6d3 PDM |
638 | { |
639 | next_addr = (frame_info)->frame + read_memory_integer (pc + 2, 2); | |
640 | pc += 4; | |
641 | } | |
c5aa993b JM |
642 | else |
643 | goto lose; | |
644 | ||
645 | /* If have an addal #-n, sp next, adjust next_addr. */ | |
646 | if ((0177777 & read_memory_integer (pc, 2)) == 0157774) | |
647 | next_addr += read_memory_integer (pc += 2, 4), pc += 4; | |
648 | } | |
c5aa993b | 649 | |
b5d78d39 | 650 | for (;;) |
c5aa993b | 651 | { |
89c3b6d3 | 652 | nextinsn = 0xffff & read_memory_integer (pc, 2); |
c5aa993b | 653 | regmask = read_memory_integer (pc + 2, 2); |
89c3b6d3 PDM |
654 | /* fmovemx to -(sp) */ |
655 | if (0xf227 == nextinsn && (regmask & 0xff00) == 0xe000) | |
c906108c | 656 | { |
89c3b6d3 PDM |
657 | /* Regmask's low bit is for register fp7, the first pushed */ |
658 | for (regnum = FP0_REGNUM + 8; --regnum >= FP0_REGNUM; regmask >>= 1) | |
659 | if (regmask & 1) | |
7f8e7424 | 660 | frame_info->saved_regs[regnum] = (next_addr -= 12); |
89c3b6d3 PDM |
661 | pc += 4; |
662 | } | |
663 | /* fmovemx to (fp + displacement) */ | |
664 | else if (0171056 == nextinsn && (regmask & 0xff00) == 0xf000) | |
665 | { | |
666 | register CORE_ADDR addr; | |
667 | ||
668 | addr = (frame_info)->frame + read_memory_integer (pc + 4, 2); | |
669 | /* Regmask's low bit is for register fp7, the first pushed */ | |
670 | for (regnum = FP0_REGNUM + 8; --regnum >= FP0_REGNUM; regmask >>= 1) | |
671 | if (regmask & 1) | |
672 | { | |
7f8e7424 | 673 | frame_info->saved_regs[regnum] = addr; |
89c3b6d3 PDM |
674 | addr += 12; |
675 | } | |
676 | pc += 6; | |
677 | } | |
678 | /* moveml to (sp) */ | |
679 | else if (0044327 == nextinsn) | |
680 | { | |
681 | /* Regmask's low bit is for register 0, the first written */ | |
682 | for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) | |
683 | if (regmask & 1) | |
684 | { | |
7f8e7424 | 685 | frame_info->saved_regs[regnum] = next_addr; |
89c3b6d3 PDM |
686 | next_addr += 4; |
687 | } | |
688 | pc += 4; | |
689 | } | |
690 | /* moveml to (fp + displacement) */ | |
691 | else if (0044356 == nextinsn) | |
692 | { | |
693 | register CORE_ADDR addr; | |
694 | ||
695 | addr = (frame_info)->frame + read_memory_integer (pc + 4, 2); | |
696 | /* Regmask's low bit is for register 0, the first written */ | |
697 | for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) | |
698 | if (regmask & 1) | |
699 | { | |
7f8e7424 | 700 | frame_info->saved_regs[regnum] = addr; |
89c3b6d3 PDM |
701 | addr += 4; |
702 | } | |
703 | pc += 6; | |
704 | } | |
705 | /* moveml to -(sp) */ | |
706 | else if (0044347 == nextinsn) | |
707 | { | |
708 | /* Regmask's low bit is for register 15, the first pushed */ | |
709 | for (regnum = 16; --regnum >= 0; regmask >>= 1) | |
710 | if (regmask & 1) | |
7f8e7424 | 711 | frame_info->saved_regs[regnum] = (next_addr -= 4); |
89c3b6d3 PDM |
712 | pc += 4; |
713 | } | |
714 | /* movl r,-(sp) */ | |
715 | else if (0x2f00 == (0xfff0 & nextinsn)) | |
716 | { | |
717 | regnum = 0xf & nextinsn; | |
7f8e7424 | 718 | frame_info->saved_regs[regnum] = (next_addr -= 4); |
89c3b6d3 | 719 | pc += 2; |
c906108c | 720 | } |
89c3b6d3 PDM |
721 | /* fmovemx to index of sp */ |
722 | else if (0xf236 == nextinsn && (regmask & 0xff00) == 0xf000) | |
723 | { | |
724 | /* Regmask's low bit is for register fp0, the first written */ | |
725 | for (regnum = FP0_REGNUM + 8; --regnum >= FP0_REGNUM; regmask >>= 1) | |
726 | if (regmask & 1) | |
727 | { | |
7f8e7424 | 728 | frame_info->saved_regs[regnum] = next_addr; |
89c3b6d3 PDM |
729 | next_addr += 12; |
730 | } | |
731 | pc += 10; | |
732 | } | |
733 | /* clrw -(sp); movw ccr,-(sp) */ | |
734 | else if (0x4267 == nextinsn && 0x42e7 == regmask) | |
735 | { | |
7f8e7424 | 736 | frame_info->saved_regs[PS_REGNUM] = (next_addr -= 4); |
89c3b6d3 PDM |
737 | pc += 4; |
738 | } | |
739 | else | |
740 | break; | |
c906108c | 741 | } |
c5aa993b | 742 | lose:; |
7f8e7424 GS |
743 | frame_info->saved_regs[SP_REGNUM] = (frame_info)->frame + 8; |
744 | frame_info->saved_regs[FP_REGNUM] = (frame_info)->frame; | |
745 | frame_info->saved_regs[PC_REGNUM] = (frame_info)->frame + 4; | |
c906108c SS |
746 | #ifdef SIG_SP_FP_OFFSET |
747 | /* Adjust saved SP_REGNUM for fake _sigtramp frames. */ | |
5a203e44 | 748 | if ((get_frame_type (frame_info) == SIGTRAMP_FRAME) && frame_info->next) |
7f8e7424 GS |
749 | frame_info->saved_regs[SP_REGNUM] = |
750 | frame_info->next->frame + SIG_SP_FP_OFFSET; | |
c906108c SS |
751 | #endif |
752 | } | |
753 | ||
754 | ||
c5aa993b | 755 | #ifdef USE_PROC_FS /* Target dependent support for /proc */ |
c906108c SS |
756 | |
757 | #include <sys/procfs.h> | |
758 | ||
c60c0f5f MS |
759 | /* Prototypes for supply_gregset etc. */ |
760 | #include "gregset.h" | |
761 | ||
c906108c | 762 | /* The /proc interface divides the target machine's register set up into |
c5aa993b JM |
763 | two different sets, the general register set (gregset) and the floating |
764 | point register set (fpregset). For each set, there is an ioctl to get | |
765 | the current register set and another ioctl to set the current values. | |
c906108c | 766 | |
c5aa993b JM |
767 | The actual structure passed through the ioctl interface is, of course, |
768 | naturally machine dependent, and is different for each set of registers. | |
769 | For the m68k for example, the general register set is typically defined | |
770 | by: | |
c906108c | 771 | |
c5aa993b | 772 | typedef int gregset_t[18]; |
c906108c | 773 | |
c5aa993b JM |
774 | #define R_D0 0 |
775 | ... | |
776 | #define R_PS 17 | |
c906108c | 777 | |
c5aa993b | 778 | and the floating point set by: |
c906108c | 779 | |
c5aa993b JM |
780 | typedef struct fpregset { |
781 | int f_pcr; | |
782 | int f_psr; | |
783 | int f_fpiaddr; | |
784 | int f_fpregs[8][3]; (8 regs, 96 bits each) | |
785 | } fpregset_t; | |
c906108c | 786 | |
c5aa993b JM |
787 | These routines provide the packing and unpacking of gregset_t and |
788 | fpregset_t formatted data. | |
c906108c SS |
789 | |
790 | */ | |
791 | ||
792 | /* Atari SVR4 has R_SR but not R_PS */ | |
793 | ||
794 | #if !defined (R_PS) && defined (R_SR) | |
795 | #define R_PS R_SR | |
796 | #endif | |
797 | ||
798 | /* Given a pointer to a general register set in /proc format (gregset_t *), | |
c5aa993b JM |
799 | unpack the register contents and supply them as gdb's idea of the current |
800 | register values. */ | |
c906108c SS |
801 | |
802 | void | |
fba45db2 | 803 | supply_gregset (gregset_t *gregsetp) |
c906108c SS |
804 | { |
805 | register int regi; | |
806 | register greg_t *regp = (greg_t *) gregsetp; | |
807 | ||
c5aa993b | 808 | for (regi = 0; regi < R_PC; regi++) |
c906108c SS |
809 | { |
810 | supply_register (regi, (char *) (regp + regi)); | |
811 | } | |
812 | supply_register (PS_REGNUM, (char *) (regp + R_PS)); | |
813 | supply_register (PC_REGNUM, (char *) (regp + R_PC)); | |
814 | } | |
815 | ||
816 | void | |
fba45db2 | 817 | fill_gregset (gregset_t *gregsetp, int regno) |
c906108c SS |
818 | { |
819 | register int regi; | |
820 | register greg_t *regp = (greg_t *) gregsetp; | |
c906108c | 821 | |
c5aa993b | 822 | for (regi = 0; regi < R_PC; regi++) |
c906108c SS |
823 | { |
824 | if ((regno == -1) || (regno == regi)) | |
825 | { | |
524d7c18 | 826 | *(regp + regi) = *(int *) &deprecated_registers[REGISTER_BYTE (regi)]; |
c906108c SS |
827 | } |
828 | } | |
829 | if ((regno == -1) || (regno == PS_REGNUM)) | |
830 | { | |
524d7c18 | 831 | *(regp + R_PS) = *(int *) &deprecated_registers[REGISTER_BYTE (PS_REGNUM)]; |
c906108c SS |
832 | } |
833 | if ((regno == -1) || (regno == PC_REGNUM)) | |
834 | { | |
524d7c18 | 835 | *(regp + R_PC) = *(int *) &deprecated_registers[REGISTER_BYTE (PC_REGNUM)]; |
c906108c SS |
836 | } |
837 | } | |
838 | ||
839 | #if defined (FP0_REGNUM) | |
840 | ||
841 | /* Given a pointer to a floating point register set in /proc format | |
c5aa993b JM |
842 | (fpregset_t *), unpack the register contents and supply them as gdb's |
843 | idea of the current floating point register values. */ | |
c906108c | 844 | |
c5aa993b | 845 | void |
fba45db2 | 846 | supply_fpregset (fpregset_t *fpregsetp) |
c906108c SS |
847 | { |
848 | register int regi; | |
849 | char *from; | |
c5aa993b | 850 | |
32eeb91a | 851 | for (regi = FP0_REGNUM; regi < M68K_FPC_REGNUM; regi++) |
c906108c | 852 | { |
c5aa993b | 853 | from = (char *) &(fpregsetp->f_fpregs[regi - FP0_REGNUM][0]); |
c906108c SS |
854 | supply_register (regi, from); |
855 | } | |
32eeb91a AS |
856 | supply_register (M68K_FPC_REGNUM, (char *) &(fpregsetp->f_pcr)); |
857 | supply_register (M68K_FPS_REGNUM, (char *) &(fpregsetp->f_psr)); | |
858 | supply_register (M68K_FPI_REGNUM, (char *) &(fpregsetp->f_fpiaddr)); | |
c906108c SS |
859 | } |
860 | ||
861 | /* Given a pointer to a floating point register set in /proc format | |
c5aa993b JM |
862 | (fpregset_t *), update the register specified by REGNO from gdb's idea |
863 | of the current floating point register set. If REGNO is -1, update | |
864 | them all. */ | |
c906108c SS |
865 | |
866 | void | |
fba45db2 | 867 | fill_fpregset (fpregset_t *fpregsetp, int regno) |
c906108c SS |
868 | { |
869 | int regi; | |
870 | char *to; | |
871 | char *from; | |
c906108c | 872 | |
32eeb91a | 873 | for (regi = FP0_REGNUM; regi < M68K_FPC_REGNUM; regi++) |
c906108c SS |
874 | { |
875 | if ((regno == -1) || (regno == regi)) | |
876 | { | |
524d7c18 | 877 | from = (char *) &deprecated_registers[REGISTER_BYTE (regi)]; |
c5aa993b | 878 | to = (char *) &(fpregsetp->f_fpregs[regi - FP0_REGNUM][0]); |
c906108c SS |
879 | memcpy (to, from, REGISTER_RAW_SIZE (regi)); |
880 | } | |
881 | } | |
32eeb91a | 882 | if ((regno == -1) || (regno == M68K_FPC_REGNUM)) |
c906108c | 883 | { |
32eeb91a | 884 | fpregsetp->f_pcr = *(int *) &deprecated_registers[REGISTER_BYTE (M68K_FPC_REGNUM)]; |
c906108c | 885 | } |
32eeb91a | 886 | if ((regno == -1) || (regno == M68K_FPS_REGNUM)) |
c906108c | 887 | { |
32eeb91a | 888 | fpregsetp->f_psr = *(int *) &deprecated_registers[REGISTER_BYTE (M68K_FPS_REGNUM)]; |
c906108c | 889 | } |
32eeb91a | 890 | if ((regno == -1) || (regno == M68K_FPI_REGNUM)) |
c906108c | 891 | { |
32eeb91a | 892 | fpregsetp->f_fpiaddr = *(int *) &deprecated_registers[REGISTER_BYTE (M68K_FPI_REGNUM)]; |
c906108c SS |
893 | } |
894 | } | |
895 | ||
c5aa993b | 896 | #endif /* defined (FP0_REGNUM) */ |
c906108c | 897 | |
c5aa993b | 898 | #endif /* USE_PROC_FS */ |
c906108c | 899 | |
c906108c SS |
900 | /* Figure out where the longjmp will land. Slurp the args out of the stack. |
901 | We expect the first arg to be a pointer to the jmp_buf structure from which | |
902 | we extract the pc (JB_PC) that we will land at. The pc is copied into PC. | |
903 | This routine returns true on success. */ | |
904 | ||
2765b798 AC |
905 | /* NOTE: cagney/2000-11-08: For this function to be fully multi-arched |
906 | the macro's JB_PC and JB_ELEMENT_SIZE would need to be moved into | |
907 | the ``struct gdbarch_tdep'' object and then set on a target ISA/ABI | |
908 | dependant basis. */ | |
909 | ||
c906108c | 910 | int |
f4281f55 | 911 | m68k_get_longjmp_target (CORE_ADDR *pc) |
c906108c | 912 | { |
2765b798 | 913 | #if defined (JB_PC) && defined (JB_ELEMENT_SIZE) |
35fc8285 | 914 | char *buf; |
c906108c SS |
915 | CORE_ADDR sp, jb_addr; |
916 | ||
35fc8285 | 917 | buf = alloca (TARGET_PTR_BIT / TARGET_CHAR_BIT); |
c5aa993b | 918 | sp = read_register (SP_REGNUM); |
c906108c | 919 | |
b5d78d39 GS |
920 | if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack */ |
921 | buf, TARGET_PTR_BIT / TARGET_CHAR_BIT)) | |
c906108c SS |
922 | return 0; |
923 | ||
924 | jb_addr = extract_address (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT); | |
925 | ||
926 | if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, buf, | |
927 | TARGET_PTR_BIT / TARGET_CHAR_BIT)) | |
928 | return 0; | |
929 | ||
930 | *pc = extract_address (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT); | |
931 | ||
932 | return 1; | |
2765b798 | 933 | #else |
8e65ff28 AC |
934 | internal_error (__FILE__, __LINE__, |
935 | "m68k_get_longjmp_target: not implemented"); | |
2765b798 AC |
936 | return 0; |
937 | #endif | |
c906108c | 938 | } |
c906108c SS |
939 | |
940 | /* Immediately after a function call, return the saved pc before the frame | |
941 | is setup. For sun3's, we check for the common case of being inside of a | |
942 | system call, and if so, we know that Sun pushes the call # on the stack | |
943 | prior to doing the trap. */ | |
944 | ||
945 | CORE_ADDR | |
fba45db2 | 946 | m68k_saved_pc_after_call (struct frame_info *frame) |
c906108c SS |
947 | { |
948 | #ifdef SYSCALL_TRAP | |
949 | int op; | |
950 | ||
951 | op = read_memory_integer (frame->pc - SYSCALL_TRAP_OFFSET, 2); | |
952 | ||
953 | if (op == SYSCALL_TRAP) | |
954 | return read_memory_integer (read_register (SP_REGNUM) + 4, 4); | |
955 | else | |
956 | #endif /* SYSCALL_TRAP */ | |
957 | return read_memory_integer (read_register (SP_REGNUM), 4); | |
958 | } | |
959 | ||
152d9db6 GS |
960 | /* Function: m68k_gdbarch_init |
961 | Initializer function for the m68k gdbarch vector. | |
962 | Called by gdbarch. Sets up the gdbarch vector(s) for this target. */ | |
963 | ||
964 | static struct gdbarch * | |
965 | m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | |
966 | { | |
a2c6a6d5 GS |
967 | static LONGEST call_dummy_words[7] = { 0xf227e0ff, 0x48e7fffc, 0x426742e7, |
968 | 0x4eb93232, 0x3232dffc, 0x69696969, | |
969 | (0x4e404e71 | (BPT_VECTOR << 16)) | |
970 | }; | |
152d9db6 GS |
971 | struct gdbarch_tdep *tdep = NULL; |
972 | struct gdbarch *gdbarch; | |
973 | ||
974 | /* find a candidate among the list of pre-declared architectures. */ | |
975 | arches = gdbarch_list_lookup_by_info (arches, &info); | |
976 | if (arches != NULL) | |
977 | return (arches->gdbarch); | |
978 | ||
979 | #if 0 | |
980 | tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep)); | |
981 | #endif | |
6300c360 | 982 | |
152d9db6 GS |
983 | gdbarch = gdbarch_alloc (&info, 0); |
984 | ||
5d3ed2e3 GS |
985 | set_gdbarch_long_double_format (gdbarch, &floatformat_m68881_ext); |
986 | set_gdbarch_long_double_bit (gdbarch, 96); | |
987 | ||
988 | set_gdbarch_function_start_offset (gdbarch, 0); | |
989 | ||
990 | set_gdbarch_skip_prologue (gdbarch, m68k_skip_prologue); | |
991 | set_gdbarch_saved_pc_after_call (gdbarch, m68k_saved_pc_after_call); | |
103a1597 | 992 | set_gdbarch_breakpoint_from_pc (gdbarch, m68k_local_breakpoint_from_pc); |
5d3ed2e3 GS |
993 | |
994 | /* Stack grows down. */ | |
995 | set_gdbarch_inner_than (gdbarch, core_addr_lessthan); | |
996 | set_gdbarch_stack_align (gdbarch, m68k_stack_align); | |
997 | ||
6300c360 GS |
998 | |
999 | set_gdbarch_believe_pcc_promotion (gdbarch, 1); | |
942dc0e9 GS |
1000 | set_gdbarch_decr_pc_after_break (gdbarch, 2); |
1001 | ||
1002 | set_gdbarch_store_struct_return (gdbarch, m68k_store_struct_return); | |
1003 | set_gdbarch_deprecated_extract_return_value (gdbarch, | |
1004 | m68k_deprecated_extract_return_value); | |
ebba8386 | 1005 | set_gdbarch_deprecated_store_return_value (gdbarch, m68k_store_return_value); |
942dc0e9 GS |
1006 | |
1007 | set_gdbarch_frame_chain (gdbarch, m68k_frame_chain); | |
6300c360 | 1008 | set_gdbarch_frame_chain_valid (gdbarch, generic_func_frame_chain_valid); |
942dc0e9 GS |
1009 | set_gdbarch_frame_saved_pc (gdbarch, m68k_frame_saved_pc); |
1010 | set_gdbarch_frame_init_saved_regs (gdbarch, m68k_frame_init_saved_regs); | |
1011 | set_gdbarch_frameless_function_invocation (gdbarch, | |
1012 | m68k_frameless_function_invocation); | |
6300c360 GS |
1013 | /* OK to default this value to 'unknown'. */ |
1014 | set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown); | |
1015 | set_gdbarch_frame_args_skip (gdbarch, 8); | |
942dc0e9 | 1016 | |
5d3ed2e3 GS |
1017 | set_gdbarch_register_raw_size (gdbarch, m68k_register_raw_size); |
1018 | set_gdbarch_register_virtual_size (gdbarch, m68k_register_virtual_size); | |
1019 | set_gdbarch_max_register_raw_size (gdbarch, 12); | |
1020 | set_gdbarch_max_register_virtual_size (gdbarch, 12); | |
1021 | set_gdbarch_register_virtual_type (gdbarch, m68k_register_virtual_type); | |
1022 | set_gdbarch_register_name (gdbarch, m68k_register_name); | |
1023 | set_gdbarch_register_size (gdbarch, 4); | |
1024 | set_gdbarch_register_byte (gdbarch, m68k_register_byte); | |
942dc0e9 GS |
1025 | set_gdbarch_num_regs (gdbarch, 29); |
1026 | set_gdbarch_register_bytes_ok (gdbarch, m68k_register_bytes_ok); | |
1027 | set_gdbarch_register_bytes (gdbarch, (16 * 4 + 8 + 8 * 12 + 3 * 4)); | |
32eeb91a AS |
1028 | set_gdbarch_sp_regnum (gdbarch, M68K_SP_REGNUM); |
1029 | set_gdbarch_fp_regnum (gdbarch, M68K_FP_REGNUM); | |
1030 | set_gdbarch_pc_regnum (gdbarch, M68K_PC_REGNUM); | |
1031 | set_gdbarch_ps_regnum (gdbarch, M68K_PS_REGNUM); | |
1032 | set_gdbarch_fp0_regnum (gdbarch, M68K_FP0_REGNUM); | |
a2c6a6d5 | 1033 | |
07555a72 | 1034 | set_gdbarch_deprecated_use_generic_dummy_frames (gdbarch, 0); |
7f8e7424 GS |
1035 | set_gdbarch_call_dummy_location (gdbarch, ON_STACK); |
1036 | set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1); | |
a2c6a6d5 | 1037 | set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 24); |
b4b88177 | 1038 | set_gdbarch_pc_in_call_dummy (gdbarch, deprecated_pc_in_call_dummy_on_stack); |
7f8e7424 GS |
1039 | set_gdbarch_call_dummy_p (gdbarch, 1); |
1040 | set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0); | |
1041 | set_gdbarch_call_dummy_length (gdbarch, 28); | |
1042 | set_gdbarch_call_dummy_start_offset (gdbarch, 12); | |
a2c6a6d5 | 1043 | |
7f8e7424 GS |
1044 | set_gdbarch_call_dummy_words (gdbarch, call_dummy_words); |
1045 | set_gdbarch_sizeof_call_dummy_words (gdbarch, sizeof (call_dummy_words)); | |
1046 | set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0); | |
1047 | set_gdbarch_fix_call_dummy (gdbarch, m68k_fix_call_dummy); | |
1048 | set_gdbarch_push_dummy_frame (gdbarch, m68k_push_dummy_frame); | |
1049 | set_gdbarch_pop_frame (gdbarch, m68k_pop_frame); | |
a2c6a6d5 | 1050 | |
152d9db6 GS |
1051 | return gdbarch; |
1052 | } | |
1053 | ||
1054 | ||
1055 | static void | |
1056 | m68k_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file) | |
1057 | { | |
1058 | ||
1059 | } | |
2acceee2 | 1060 | |
c906108c | 1061 | void |
fba45db2 | 1062 | _initialize_m68k_tdep (void) |
c906108c | 1063 | { |
152d9db6 | 1064 | gdbarch_register (bfd_arch_m68k, m68k_gdbarch_init, m68k_dump_tdep); |
c906108c SS |
1065 | tm_print_insn = print_insn_m68k; |
1066 | } |