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