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