OSDN Git Service

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