GDB (API)
/home/stan/gdb/src/gdb/mt-tdep.c
Go to the documentation of this file.
00001 /* Target-dependent code for Morpho mt processor, for GDB.
00002 
00003    Copyright (C) 2005-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 /* Contributed by Michael Snyder, msnyder@redhat.com.  */
00021 
00022 #include "defs.h"
00023 #include "frame.h"
00024 #include "frame-unwind.h"
00025 #include "frame-base.h"
00026 #include "symtab.h"
00027 #include "dis-asm.h"
00028 #include "arch-utils.h"
00029 #include "gdbtypes.h"
00030 #include "gdb_string.h"
00031 #include "regcache.h"
00032 #include "reggroups.h"
00033 #include "gdbcore.h"
00034 #include "trad-frame.h"
00035 #include "inferior.h"
00036 #include "dwarf2-frame.h"
00037 #include "infcall.h"
00038 #include "gdb_assert.h"
00039 #include "language.h"
00040 #include "valprint.h"
00041 
00042 enum mt_arch_constants
00043 {
00044   MT_MAX_STRUCT_SIZE = 16
00045 };
00046 
00047 enum mt_gdb_regnums
00048 {
00049   MT_R0_REGNUM,                 /* 32 bit regs.  */
00050   MT_R1_REGNUM,
00051   MT_1ST_ARGREG = MT_R1_REGNUM,
00052   MT_R2_REGNUM,
00053   MT_R3_REGNUM,
00054   MT_R4_REGNUM,
00055   MT_LAST_ARGREG = MT_R4_REGNUM,
00056   MT_R5_REGNUM,
00057   MT_R6_REGNUM,
00058   MT_R7_REGNUM,
00059   MT_R8_REGNUM,
00060   MT_R9_REGNUM,
00061   MT_R10_REGNUM,
00062   MT_R11_REGNUM,
00063   MT_R12_REGNUM,
00064   MT_FP_REGNUM = MT_R12_REGNUM,
00065   MT_R13_REGNUM,
00066   MT_SP_REGNUM = MT_R13_REGNUM,
00067   MT_R14_REGNUM,
00068   MT_RA_REGNUM = MT_R14_REGNUM,
00069   MT_R15_REGNUM,
00070   MT_IRA_REGNUM = MT_R15_REGNUM,
00071   MT_PC_REGNUM,
00072 
00073   /* Interrupt Enable pseudo-register, exported by SID.  */
00074   MT_INT_ENABLE_REGNUM,
00075   /* End of CPU regs.  */
00076 
00077   MT_NUM_CPU_REGS,
00078 
00079   /* Co-processor registers.  */
00080   MT_COPRO_REGNUM = MT_NUM_CPU_REGS,    /* 16 bit regs.  */
00081   MT_CPR0_REGNUM,
00082   MT_CPR1_REGNUM,
00083   MT_CPR2_REGNUM,
00084   MT_CPR3_REGNUM,
00085   MT_CPR4_REGNUM,
00086   MT_CPR5_REGNUM,
00087   MT_CPR6_REGNUM,
00088   MT_CPR7_REGNUM,
00089   MT_CPR8_REGNUM,
00090   MT_CPR9_REGNUM,
00091   MT_CPR10_REGNUM,
00092   MT_CPR11_REGNUM,
00093   MT_CPR12_REGNUM,
00094   MT_CPR13_REGNUM,
00095   MT_CPR14_REGNUM,
00096   MT_CPR15_REGNUM,
00097   MT_BYPA_REGNUM,               /* 32 bit regs.  */
00098   MT_BYPB_REGNUM,
00099   MT_BYPC_REGNUM,
00100   MT_FLAG_REGNUM,
00101   MT_CONTEXT_REGNUM,            /* 38 bits (treat as array of
00102                                    six bytes).  */
00103   MT_MAC_REGNUM,                        /* 32 bits.  */
00104   MT_Z1_REGNUM,                 /* 16 bits.  */
00105   MT_Z2_REGNUM,                 /* 16 bits.  */
00106   MT_ICHANNEL_REGNUM,           /* 32 bits.  */
00107   MT_ISCRAMB_REGNUM,            /* 32 bits.  */
00108   MT_QSCRAMB_REGNUM,            /* 32 bits.  */
00109   MT_OUT_REGNUM,                        /* 16 bits.  */
00110   MT_EXMAC_REGNUM,              /* 32 bits (8 used).  */
00111   MT_QCHANNEL_REGNUM,           /* 32 bits.  */
00112   MT_ZI2_REGNUM,                /* 16 bits.  */
00113   MT_ZQ2_REGNUM,                /* 16 bits.  */
00114   MT_CHANNEL2_REGNUM,           /* 32 bits.  */
00115   MT_ISCRAMB2_REGNUM,           /* 32 bits.  */
00116   MT_QSCRAMB2_REGNUM,           /* 32 bits.  */
00117   MT_QCHANNEL2_REGNUM,          /* 32 bits.  */
00118 
00119   /* Number of real registers.  */
00120   MT_NUM_REGS,
00121 
00122   /* Pseudo-registers.  */
00123   MT_COPRO_PSEUDOREG_REGNUM = MT_NUM_REGS,
00124   MT_MAC_PSEUDOREG_REGNUM,
00125   MT_COPRO_PSEUDOREG_ARRAY,
00126 
00127   MT_COPRO_PSEUDOREG_DIM_1 = 2,
00128   MT_COPRO_PSEUDOREG_DIM_2 = 8,
00129   /* The number of pseudo-registers for each coprocessor.  These
00130      include the real coprocessor registers, the pseudo-registe for
00131      the coprocessor number, and the pseudo-register for the MAC.  */
00132   MT_COPRO_PSEUDOREG_REGS = MT_NUM_REGS - MT_NUM_CPU_REGS + 2,
00133   /* The register number of the MAC, relative to a given coprocessor.  */
00134   MT_COPRO_PSEUDOREG_MAC_REGNUM = MT_COPRO_PSEUDOREG_REGS - 1,
00135 
00136   /* Two pseudo-regs ('coprocessor' and 'mac').  */
00137   MT_NUM_PSEUDO_REGS = 2 + (MT_COPRO_PSEUDOREG_REGS
00138                             * MT_COPRO_PSEUDOREG_DIM_1
00139                             * MT_COPRO_PSEUDOREG_DIM_2)
00140 };
00141 
00142 /* The tdep structure.  */
00143 struct gdbarch_tdep
00144 {
00145   /* ISA-specific types.  */
00146   struct type *copro_type;
00147 };
00148 
00149 
00150 /* Return name of register number specified by REGNUM.  */
00151 
00152 static const char *
00153 mt_register_name (struct gdbarch *gdbarch, int regnum)
00154 {
00155   static const char *const register_names[] = {
00156     /* CPU regs.  */
00157     "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
00158     "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
00159     "pc", "IE",
00160     /* Co-processor regs.  */
00161     "",                         /* copro register.  */
00162     "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",
00163     "cr8", "cr9", "cr10", "cr11", "cr12", "cr13", "cr14", "cr15",
00164     "bypa", "bypb", "bypc", "flag", "context", "" /* mac.  */ , "z1", "z2",
00165     "Ichannel", "Iscramb", "Qscramb", "out", "" /* ex-mac.  */ , "Qchannel",
00166     "zi2", "zq2", "Ichannel2", "Iscramb2", "Qscramb2", "Qchannel2",
00167     /* Pseudo-registers.  */
00168     "coprocessor", "MAC"
00169   };
00170   static const char *array_names[MT_COPRO_PSEUDOREG_REGS
00171                                  * MT_COPRO_PSEUDOREG_DIM_1
00172                                  * MT_COPRO_PSEUDOREG_DIM_2];
00173 
00174   if (regnum < 0)
00175     return "";
00176   if (regnum < ARRAY_SIZE (register_names))
00177     return register_names[regnum];
00178   if (array_names[regnum - MT_COPRO_PSEUDOREG_ARRAY])
00179     return array_names[regnum - MT_COPRO_PSEUDOREG_ARRAY];
00180   
00181   {
00182     char *name;
00183     const char *stub;
00184     unsigned dim_1;
00185     unsigned dim_2;
00186     unsigned index;
00187     
00188     regnum -= MT_COPRO_PSEUDOREG_ARRAY;
00189     index = regnum % MT_COPRO_PSEUDOREG_REGS;
00190     dim_2 = (regnum / MT_COPRO_PSEUDOREG_REGS) % MT_COPRO_PSEUDOREG_DIM_2;
00191     dim_1 = ((regnum / MT_COPRO_PSEUDOREG_REGS / MT_COPRO_PSEUDOREG_DIM_2)
00192              %  MT_COPRO_PSEUDOREG_DIM_1);
00193     
00194     if (index == MT_COPRO_PSEUDOREG_MAC_REGNUM)
00195       stub = register_names[MT_MAC_PSEUDOREG_REGNUM];
00196     else if (index >= MT_NUM_REGS - MT_CPR0_REGNUM)
00197       stub = "";
00198     else
00199       stub = register_names[index + MT_CPR0_REGNUM];
00200     if (!*stub)
00201       {
00202         array_names[regnum] = stub;
00203         return stub;
00204       }
00205     name = xmalloc (30);
00206     sprintf (name, "copro_%d_%d_%s", dim_1, dim_2, stub);
00207     array_names[regnum] = name;
00208     return name;
00209   }
00210 }
00211 
00212 /* Return the type of a coprocessor register.  */
00213 
00214 static struct type *
00215 mt_copro_register_type (struct gdbarch *arch, int regnum)
00216 {
00217   switch (regnum)
00218     {
00219     case MT_INT_ENABLE_REGNUM:
00220     case MT_ICHANNEL_REGNUM:
00221     case MT_QCHANNEL_REGNUM:
00222     case MT_ISCRAMB_REGNUM:
00223     case MT_QSCRAMB_REGNUM:
00224       return builtin_type (arch)->builtin_int32;
00225     case MT_BYPA_REGNUM:
00226     case MT_BYPB_REGNUM:
00227     case MT_BYPC_REGNUM:
00228     case MT_Z1_REGNUM:
00229     case MT_Z2_REGNUM:
00230     case MT_OUT_REGNUM:
00231     case MT_ZI2_REGNUM:
00232     case MT_ZQ2_REGNUM:
00233       return builtin_type (arch)->builtin_int16;
00234     case MT_EXMAC_REGNUM:
00235     case MT_MAC_REGNUM:
00236       return builtin_type (arch)->builtin_uint32;
00237     case MT_CONTEXT_REGNUM:
00238       return builtin_type (arch)->builtin_long_long;
00239     case MT_FLAG_REGNUM:
00240       return builtin_type (arch)->builtin_unsigned_char;
00241     default:
00242       if (regnum >= MT_CPR0_REGNUM && regnum <= MT_CPR15_REGNUM)
00243         return builtin_type (arch)->builtin_int16;
00244       else if (regnum == MT_CPR0_REGNUM + MT_COPRO_PSEUDOREG_MAC_REGNUM)
00245         {
00246           if (gdbarch_bfd_arch_info (arch)->mach == bfd_mach_mrisc2
00247               || gdbarch_bfd_arch_info (arch)->mach == bfd_mach_ms2)
00248             return builtin_type (arch)->builtin_uint64;
00249           else
00250             return builtin_type (arch)->builtin_uint32;
00251         }
00252       else
00253         return builtin_type (arch)->builtin_uint32;
00254     }
00255 }
00256 
00257 /* Given ARCH and a register number specified by REGNUM, return the
00258    type of that register.  */
00259 
00260 static struct type *
00261 mt_register_type (struct gdbarch *arch, int regnum)
00262 {
00263   struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
00264 
00265   if (regnum >= 0 && regnum < MT_NUM_REGS + MT_NUM_PSEUDO_REGS)
00266     {
00267       switch (regnum)
00268         {
00269         case MT_PC_REGNUM:
00270         case MT_RA_REGNUM:
00271         case MT_IRA_REGNUM:
00272           return builtin_type (arch)->builtin_func_ptr;
00273         case MT_SP_REGNUM:
00274         case MT_FP_REGNUM:
00275           return builtin_type (arch)->builtin_data_ptr;
00276         case MT_COPRO_REGNUM:
00277         case MT_COPRO_PSEUDOREG_REGNUM:
00278           if (tdep->copro_type == NULL)
00279             {
00280               struct type *elt = builtin_type (arch)->builtin_int16;
00281               tdep->copro_type = lookup_array_range_type (elt, 0, 1);
00282             }
00283           return tdep->copro_type;
00284         case MT_MAC_PSEUDOREG_REGNUM:
00285           return mt_copro_register_type (arch,
00286                                          MT_CPR0_REGNUM
00287                                          + MT_COPRO_PSEUDOREG_MAC_REGNUM);
00288         default:
00289           if (regnum >= MT_R0_REGNUM && regnum <= MT_R15_REGNUM)
00290             return builtin_type (arch)->builtin_int32;
00291           else if (regnum < MT_COPRO_PSEUDOREG_ARRAY)
00292             return mt_copro_register_type (arch, regnum);
00293           else
00294             {
00295               regnum -= MT_COPRO_PSEUDOREG_ARRAY;
00296               regnum %= MT_COPRO_PSEUDOREG_REGS;
00297               regnum += MT_CPR0_REGNUM;
00298               return mt_copro_register_type (arch, regnum);
00299             }
00300         }
00301     }
00302   internal_error (__FILE__, __LINE__,
00303                   _("mt_register_type: illegal register number %d"), regnum);
00304 }
00305 
00306 /* Return true if register REGNUM is a member of the register group
00307    specified by GROUP.  */
00308 
00309 static int
00310 mt_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
00311                          struct reggroup *group)
00312 {
00313   /* Groups of registers that can be displayed via "info reg".  */
00314   if (group == all_reggroup)
00315     return (regnum >= 0
00316             && regnum < MT_NUM_REGS + MT_NUM_PSEUDO_REGS
00317             && mt_register_name (gdbarch, regnum)[0] != '\0');
00318 
00319   if (group == general_reggroup)
00320     return (regnum >= MT_R0_REGNUM && regnum <= MT_R15_REGNUM);
00321 
00322   if (group == float_reggroup)
00323     return 0;                   /* No float regs.  */
00324 
00325   if (group == vector_reggroup)
00326     return 0;                   /* No vector regs.  */
00327 
00328   /* For any that are not handled above.  */
00329   return default_register_reggroup_p (gdbarch, regnum, group);
00330 }
00331 
00332 /* Return the return value convention used for a given type TYPE.
00333    Optionally, fetch or set the return value via READBUF or
00334    WRITEBUF respectively using REGCACHE for the register
00335    values.  */
00336 
00337 static enum return_value_convention
00338 mt_return_value (struct gdbarch *gdbarch, struct value *function,
00339                  struct type *type, struct regcache *regcache,
00340                  gdb_byte *readbuf, const gdb_byte *writebuf)
00341 {
00342   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
00343 
00344   if (TYPE_LENGTH (type) > 4)
00345     {
00346       /* Return values > 4 bytes are returned in memory, 
00347          pointed to by R11.  */
00348       if (readbuf)
00349         {
00350           ULONGEST addr;
00351 
00352           regcache_cooked_read_unsigned (regcache, MT_R11_REGNUM, &addr);
00353           read_memory (addr, readbuf, TYPE_LENGTH (type));
00354         }
00355 
00356       if (writebuf)
00357         {
00358           ULONGEST addr;
00359 
00360           regcache_cooked_read_unsigned (regcache, MT_R11_REGNUM, &addr);
00361           write_memory (addr, writebuf, TYPE_LENGTH (type));
00362         }
00363 
00364       return RETURN_VALUE_ABI_RETURNS_ADDRESS;
00365     }
00366   else
00367     {
00368       if (readbuf)
00369         {
00370           ULONGEST temp;
00371 
00372           /* Return values of <= 4 bytes are returned in R11.  */
00373           regcache_cooked_read_unsigned (regcache, MT_R11_REGNUM, &temp);
00374           store_unsigned_integer (readbuf, TYPE_LENGTH (type),
00375                                   byte_order, temp);
00376         }
00377 
00378       if (writebuf)
00379         {
00380           if (TYPE_LENGTH (type) < 4)
00381             {
00382               gdb_byte buf[4];
00383               /* Add leading zeros to the value.  */
00384               memset (buf, 0, sizeof (buf));
00385               memcpy (buf + sizeof (buf) - TYPE_LENGTH (type),
00386                       writebuf, TYPE_LENGTH (type));
00387               regcache_cooked_write (regcache, MT_R11_REGNUM, buf);
00388             }
00389           else                  /* (TYPE_LENGTH (type) == 4 */
00390             regcache_cooked_write (regcache, MT_R11_REGNUM, writebuf);
00391         }
00392 
00393       return RETURN_VALUE_REGISTER_CONVENTION;
00394     }
00395 }
00396 
00397 /* If the input address, PC, is in a function prologue, return the
00398    address of the end of the prologue, otherwise return the input
00399    address.
00400 
00401    Note:  PC is likely to be the function start, since this function
00402    is mainly used for advancing a breakpoint to the first line, or
00403    stepping to the first line when we have stepped into a function
00404    call.  */
00405 
00406 static CORE_ADDR
00407 mt_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
00408 {
00409   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
00410   CORE_ADDR func_addr = 0, func_end = 0;
00411   const char *func_name;
00412   unsigned long instr;
00413 
00414   if (find_pc_partial_function (pc, &func_name, &func_addr, &func_end))
00415     {
00416       struct symtab_and_line sal;
00417       struct symbol *sym;
00418 
00419       /* Found a function.  */
00420       sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL);
00421       if (sym && SYMBOL_LANGUAGE (sym) != language_asm)
00422         {
00423           /* Don't use this trick for assembly source files.  */
00424           sal = find_pc_line (func_addr, 0);
00425 
00426           if (sal.end && sal.end < func_end)
00427             {
00428               /* Found a line number, use it as end of prologue.  */
00429               return sal.end;
00430             }
00431         }
00432     }
00433 
00434   /* No function symbol, or no line symbol.  Use prologue scanning method.  */
00435   for (;; pc += 4)
00436     {
00437       instr = read_memory_unsigned_integer (pc, 4, byte_order);
00438       if (instr == 0x12000000)  /* nop */
00439         continue;
00440       if (instr == 0x12ddc000)  /* copy sp into fp */
00441         continue;
00442       instr >>= 16;
00443       if (instr == 0x05dd)      /* subi sp, sp, imm */
00444         continue;
00445       if (instr >= 0x43c0 && instr <= 0x43df)   /* push */
00446         continue;
00447       /* Not an obvious prologue instruction.  */
00448       break;
00449     }
00450 
00451   return pc;
00452 }
00453 
00454 /* The breakpoint instruction must be the same size as the smallest
00455    instruction in the instruction set.
00456 
00457    The BP for ms1 is defined as 0x68000000 (BREAK).
00458    The BP for ms2 is defined as 0x69000000 (illegal).  */
00459 
00460 static const gdb_byte *
00461 mt_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *bp_addr,
00462                        int *bp_size)
00463 {
00464   static gdb_byte ms1_breakpoint[] = { 0x68, 0, 0, 0 };
00465   static gdb_byte ms2_breakpoint[] = { 0x69, 0, 0, 0 };
00466 
00467   *bp_size = 4;
00468   if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_ms2)
00469     return ms2_breakpoint;
00470   
00471   return ms1_breakpoint;
00472 }
00473 
00474 /* Select the correct coprocessor register bank.  Return the pseudo
00475    regnum we really want to read.  */
00476 
00477 static int
00478 mt_select_coprocessor (struct gdbarch *gdbarch,
00479                         struct regcache *regcache, int regno)
00480 {
00481   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
00482   unsigned index, base;
00483   gdb_byte copro[4];
00484 
00485   /* Get the copro pseudo regnum.  */
00486   regcache_raw_read (regcache, MT_COPRO_REGNUM, copro);
00487   base = ((extract_signed_integer (&copro[0], 2, byte_order)
00488            * MT_COPRO_PSEUDOREG_DIM_2)
00489           + extract_signed_integer (&copro[2], 2, byte_order));
00490 
00491   regno -= MT_COPRO_PSEUDOREG_ARRAY;
00492   index = regno % MT_COPRO_PSEUDOREG_REGS;
00493   regno /= MT_COPRO_PSEUDOREG_REGS;
00494   if (base != regno)
00495     {
00496       /* Select the correct coprocessor register bank.  Invalidate the
00497          coprocessor register cache.  */
00498       unsigned ix;
00499 
00500       store_signed_integer (&copro[0], 2, byte_order,
00501                             regno / MT_COPRO_PSEUDOREG_DIM_2);
00502       store_signed_integer (&copro[2], 2, byte_order,
00503                             regno % MT_COPRO_PSEUDOREG_DIM_2);
00504       regcache_raw_write (regcache, MT_COPRO_REGNUM, copro);
00505       
00506       /* We must flush the cache, as it is now invalid.  */
00507       for (ix = MT_NUM_CPU_REGS; ix != MT_NUM_REGS; ix++)
00508         regcache_invalidate (regcache, ix);
00509     }
00510   
00511   return index;
00512 }
00513 
00514 /* Fetch the pseudo registers:
00515 
00516    There are two regular pseudo-registers:
00517    1) The 'coprocessor' pseudo-register (which mirrors the 
00518    "real" coprocessor register sent by the target), and
00519    2) The 'MAC' pseudo-register (which represents the union
00520    of the original 32 bit target MAC register and the new
00521    8-bit extended-MAC register).
00522 
00523    Additionally there is an array of coprocessor registers which track
00524    the coprocessor registers for each coprocessor.  */
00525 
00526 static enum register_status
00527 mt_pseudo_register_read (struct gdbarch *gdbarch,
00528                          struct regcache *regcache, int regno, gdb_byte *buf)
00529 {
00530   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
00531 
00532   switch (regno)
00533     {
00534     case MT_COPRO_REGNUM:
00535     case MT_COPRO_PSEUDOREG_REGNUM:
00536       return regcache_raw_read (regcache, MT_COPRO_REGNUM, buf);
00537     case MT_MAC_REGNUM:
00538     case MT_MAC_PSEUDOREG_REGNUM:
00539       if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_mrisc2
00540           || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_ms2)
00541         {
00542           enum register_status status;
00543           ULONGEST oldmac = 0, ext_mac = 0;
00544           ULONGEST newmac;
00545 
00546           status = regcache_cooked_read_unsigned (regcache, MT_MAC_REGNUM, &oldmac);
00547           if (status != REG_VALID)
00548             return status;
00549 
00550           regcache_cooked_read_unsigned (regcache, MT_EXMAC_REGNUM, &ext_mac);
00551           if (status != REG_VALID)
00552             return status;
00553 
00554           newmac =
00555             (oldmac & 0xffffffff) | ((long long) (ext_mac & 0xff) << 32);
00556           store_signed_integer (buf, 8, byte_order, newmac);
00557 
00558           return REG_VALID;
00559         }
00560       else
00561         return regcache_raw_read (regcache, MT_MAC_REGNUM, buf);
00562       break;
00563     default:
00564       {
00565         unsigned index = mt_select_coprocessor (gdbarch, regcache, regno);
00566         
00567         if (index == MT_COPRO_PSEUDOREG_MAC_REGNUM)
00568           return mt_pseudo_register_read (gdbarch, regcache,
00569                                           MT_MAC_PSEUDOREG_REGNUM, buf);
00570         else if (index < MT_NUM_REGS - MT_CPR0_REGNUM)
00571           return regcache_raw_read (regcache, index + MT_CPR0_REGNUM, buf);
00572         else
00573           /* ??? */
00574           return REG_VALID;
00575       }
00576       break;
00577     }
00578 }
00579 
00580 /* Write the pseudo registers:
00581 
00582    Mt pseudo-registers are stored directly to the target.  The
00583    'coprocessor' register is special, because when it is modified, all
00584    the other coprocessor regs must be flushed from the reg cache.  */
00585 
00586 static void
00587 mt_pseudo_register_write (struct gdbarch *gdbarch,
00588                            struct regcache *regcache,
00589                            int regno, const gdb_byte *buf)
00590 {
00591   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
00592   int i;
00593 
00594   switch (regno)
00595     {
00596     case MT_COPRO_REGNUM:
00597     case MT_COPRO_PSEUDOREG_REGNUM:
00598       regcache_raw_write (regcache, MT_COPRO_REGNUM, buf);
00599       for (i = MT_NUM_CPU_REGS; i < MT_NUM_REGS; i++)
00600         regcache_invalidate (regcache, i);
00601       break;
00602     case MT_MAC_REGNUM:
00603     case MT_MAC_PSEUDOREG_REGNUM:
00604       if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_mrisc2
00605           || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_ms2)
00606         {
00607           /* The 8-byte MAC pseudo-register must be broken down into two
00608              32-byte registers.  */
00609           unsigned int oldmac, ext_mac;
00610           ULONGEST newmac;
00611 
00612           newmac = extract_unsigned_integer (buf, 8, byte_order);
00613           oldmac = newmac & 0xffffffff;
00614           ext_mac = (newmac >> 32) & 0xff;
00615           regcache_cooked_write_unsigned (regcache, MT_MAC_REGNUM, oldmac);
00616           regcache_cooked_write_unsigned (regcache, MT_EXMAC_REGNUM, ext_mac);
00617         }
00618       else
00619         regcache_raw_write (regcache, MT_MAC_REGNUM, buf);
00620       break;
00621     default:
00622       {
00623         unsigned index = mt_select_coprocessor (gdbarch, regcache, regno);
00624         
00625         if (index == MT_COPRO_PSEUDOREG_MAC_REGNUM)
00626           mt_pseudo_register_write (gdbarch, regcache,
00627                                     MT_MAC_PSEUDOREG_REGNUM, buf);
00628         else if (index < MT_NUM_REGS - MT_CPR0_REGNUM)
00629           regcache_raw_write (regcache, index + MT_CPR0_REGNUM, buf);
00630       }
00631       break;
00632     }
00633 }
00634 
00635 static CORE_ADDR
00636 mt_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
00637 {
00638   /* Register size is 4 bytes.  */
00639   return align_down (sp, 4);
00640 }
00641 
00642 /* Implements the "info registers" command.   When ``all'' is non-zero,
00643    the coprocessor registers will be printed in addition to the rest
00644    of the registers.  */
00645 
00646 static void
00647 mt_registers_info (struct gdbarch *gdbarch,
00648                    struct ui_file *file,
00649                    struct frame_info *frame, int regnum, int all)
00650 {
00651   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
00652 
00653   if (regnum == -1)
00654     {
00655       int lim;
00656 
00657       lim = all ? MT_NUM_REGS : MT_NUM_CPU_REGS;
00658 
00659       for (regnum = 0; regnum < lim; regnum++)
00660         {
00661           /* Don't display the Qchannel register since it will be displayed
00662              along with Ichannel.  (See below.)  */
00663           if (regnum == MT_QCHANNEL_REGNUM)
00664             continue;
00665 
00666           mt_registers_info (gdbarch, file, frame, regnum, all);
00667 
00668           /* Display the Qchannel register immediately after Ichannel.  */
00669           if (regnum == MT_ICHANNEL_REGNUM)
00670             mt_registers_info (gdbarch, file, frame, MT_QCHANNEL_REGNUM, all);
00671         }
00672     }
00673   else
00674     {
00675       if (regnum == MT_EXMAC_REGNUM)
00676         return;
00677       else if (regnum == MT_CONTEXT_REGNUM)
00678         {
00679           /* Special output handling for 38-bit context register.  */
00680           unsigned char *buff;
00681           unsigned int *bytes, i, regsize;
00682 
00683           regsize = register_size (gdbarch, regnum);
00684 
00685           buff = alloca (regsize);
00686           bytes = alloca (regsize * sizeof (*bytes));
00687 
00688           deprecated_frame_register_read (frame, regnum, buff);
00689 
00690           fputs_filtered (gdbarch_register_name
00691                           (gdbarch, regnum), file);
00692           print_spaces_filtered (15 - strlen (gdbarch_register_name
00693                                                 (gdbarch, regnum)),
00694                                  file);
00695           fputs_filtered ("0x", file);
00696 
00697           for (i = 0; i < regsize; i++)
00698             fprintf_filtered (file, "%02x", (unsigned int)
00699                               extract_unsigned_integer (buff + i, 1, byte_order));
00700           fputs_filtered ("\t", file);
00701           print_longest (file, 'd', 0,
00702                          extract_unsigned_integer (buff, regsize, byte_order));
00703           fputs_filtered ("\n", file);
00704         }
00705       else if (regnum == MT_COPRO_REGNUM
00706                || regnum == MT_COPRO_PSEUDOREG_REGNUM)
00707         {
00708           /* Special output handling for the 'coprocessor' register.  */
00709           gdb_byte *buf;
00710           struct value_print_options opts;
00711 
00712           buf = alloca (register_size (gdbarch, MT_COPRO_REGNUM));
00713           deprecated_frame_register_read (frame, MT_COPRO_REGNUM, buf);
00714           /* And print.  */
00715           regnum = MT_COPRO_PSEUDOREG_REGNUM;
00716           fputs_filtered (gdbarch_register_name (gdbarch, regnum),
00717                           file);
00718           print_spaces_filtered (15 - strlen (gdbarch_register_name
00719                                                 (gdbarch, regnum)),
00720                                  file);
00721           get_no_prettyformat_print_options (&opts);
00722           opts.deref_ref = 1;
00723           val_print (register_type (gdbarch, regnum), buf,
00724                      0, 0, file, 0, NULL,
00725                      &opts, current_language);
00726           fputs_filtered ("\n", file);
00727         }
00728       else if (regnum == MT_MAC_REGNUM || regnum == MT_MAC_PSEUDOREG_REGNUM)
00729         {
00730           ULONGEST oldmac, ext_mac, newmac;
00731           gdb_byte buf[3 * sizeof (LONGEST)];
00732 
00733           /* Get the two "real" mac registers.  */
00734           deprecated_frame_register_read (frame, MT_MAC_REGNUM, buf);
00735           oldmac = extract_unsigned_integer
00736             (buf, register_size (gdbarch, MT_MAC_REGNUM), byte_order);
00737           if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_mrisc2
00738               || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_ms2)
00739             {
00740               deprecated_frame_register_read (frame, MT_EXMAC_REGNUM, buf);
00741               ext_mac = extract_unsigned_integer
00742                 (buf, register_size (gdbarch, MT_EXMAC_REGNUM), byte_order);
00743             }
00744           else
00745             ext_mac = 0;
00746 
00747           /* Add them together.  */
00748           newmac = (oldmac & 0xffffffff) + ((ext_mac & 0xff) << 32);
00749 
00750           /* And print.  */
00751           regnum = MT_MAC_PSEUDOREG_REGNUM;
00752           fputs_filtered (gdbarch_register_name (gdbarch, regnum),
00753                           file);
00754           print_spaces_filtered (15 - strlen (gdbarch_register_name
00755                                               (gdbarch, regnum)),
00756                                  file);
00757           fputs_filtered ("0x", file);
00758           print_longest (file, 'x', 0, newmac);
00759           fputs_filtered ("\t", file);
00760           print_longest (file, 'u', 0, newmac);
00761           fputs_filtered ("\n", file);
00762         }
00763       else
00764         default_print_registers_info (gdbarch, file, frame, regnum, all);
00765     }
00766 }
00767 
00768 /* Set up the callee's arguments for an inferior function call.  The
00769    arguments are pushed on the stack or are placed in registers as
00770    appropriate.  It also sets up the return address (which points to
00771    the call dummy breakpoint).
00772 
00773    Returns the updated (and aligned) stack pointer.  */
00774 
00775 static CORE_ADDR
00776 mt_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
00777                      struct regcache *regcache, CORE_ADDR bp_addr,
00778                      int nargs, struct value **args, CORE_ADDR sp,
00779                      int struct_return, CORE_ADDR struct_addr)
00780 {
00781 #define wordsize 4
00782   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
00783   gdb_byte buf[MT_MAX_STRUCT_SIZE];
00784   int argreg = MT_1ST_ARGREG;
00785   int split_param_len = 0;
00786   int stack_dest = sp;
00787   int slacklen;
00788   int typelen;
00789   int i, j;
00790 
00791   /* First handle however many args we can fit into MT_1ST_ARGREG thru
00792      MT_LAST_ARGREG.  */
00793   for (i = 0; i < nargs && argreg <= MT_LAST_ARGREG; i++)
00794     {
00795       const gdb_byte *val;
00796       typelen = TYPE_LENGTH (value_type (args[i]));
00797       switch (typelen)
00798         {
00799         case 1:
00800         case 2:
00801         case 3:
00802         case 4:
00803           regcache_cooked_write_unsigned (regcache, argreg++,
00804                                           extract_unsigned_integer
00805                                           (value_contents (args[i]),
00806                                            wordsize, byte_order));
00807           break;
00808         case 8:
00809         case 12:
00810         case 16:
00811           val = value_contents (args[i]);
00812           while (typelen > 0)
00813             {
00814               if (argreg <= MT_LAST_ARGREG)
00815                 {
00816                   /* This word of the argument is passed in a register.  */
00817                   regcache_cooked_write_unsigned (regcache, argreg++,
00818                                                   extract_unsigned_integer
00819                                                   (val, wordsize, byte_order));
00820                   typelen -= wordsize;
00821                   val += wordsize;
00822                 }
00823               else
00824                 {
00825                   /* Remainder of this arg must be passed on the stack
00826                      (deferred to do later).  */
00827                   split_param_len = typelen;
00828                   memcpy (buf, val, typelen);
00829                   break;        /* No more args can be handled in regs.  */
00830                 }
00831             }
00832           break;
00833         default:
00834           /* By reverse engineering of gcc output, args bigger than
00835              16 bytes go on the stack, and their address is passed
00836              in the argreg.  */
00837           stack_dest -= typelen;
00838           write_memory (stack_dest, value_contents (args[i]), typelen);
00839           regcache_cooked_write_unsigned (regcache, argreg++, stack_dest);
00840           break;
00841         }
00842     }
00843 
00844   /* Next, the rest of the arguments go onto the stack, in reverse order.  */
00845   for (j = nargs - 1; j >= i; j--)
00846     {
00847       gdb_byte *val;
00848       struct cleanup *back_to;
00849       const gdb_byte *contents = value_contents (args[j]);
00850       
00851       /* Right-justify the value in an aligned-length buffer.  */
00852       typelen = TYPE_LENGTH (value_type (args[j]));
00853       slacklen = (wordsize - (typelen % wordsize)) % wordsize;
00854       val = xmalloc (typelen + slacklen);
00855       back_to = make_cleanup (xfree, val);
00856       memcpy (val, contents, typelen);
00857       memset (val + typelen, 0, slacklen);
00858       /* Now write this data to the stack.  */
00859       stack_dest -= typelen + slacklen;
00860       write_memory (stack_dest, val, typelen + slacklen);
00861       do_cleanups (back_to);
00862     }
00863 
00864   /* Finally, if a param needs to be split between registers and stack, 
00865      write the second half to the stack now.  */
00866   if (split_param_len != 0)
00867     {
00868       stack_dest -= split_param_len;
00869       write_memory (stack_dest, buf, split_param_len);
00870     }
00871 
00872   /* Set up return address (provided to us as bp_addr).  */
00873   regcache_cooked_write_unsigned (regcache, MT_RA_REGNUM, bp_addr);
00874 
00875   /* Store struct return address, if given.  */
00876   if (struct_return && struct_addr != 0)
00877     regcache_cooked_write_unsigned (regcache, MT_R11_REGNUM, struct_addr);
00878 
00879   /* Set aside 16 bytes for the callee to save regs 1-4.  */
00880   stack_dest -= 16;
00881 
00882   /* Update the stack pointer.  */
00883   regcache_cooked_write_unsigned (regcache, MT_SP_REGNUM, stack_dest);
00884 
00885   /* And that should do it.  Return the new stack pointer.  */
00886   return stack_dest;
00887 }
00888 
00889 
00890 /* The 'unwind_cache' data structure.  */
00891 
00892 struct mt_unwind_cache
00893 {
00894   /* The previous frame's inner most stack address.
00895      Used as this frame ID's stack_addr.  */
00896   CORE_ADDR prev_sp;
00897   CORE_ADDR frame_base;
00898   int framesize;
00899   int frameless_p;
00900 
00901   /* Table indicating the location of each and every register.  */
00902   struct trad_frame_saved_reg *saved_regs;
00903 };
00904 
00905 /* Initialize an unwind_cache.  Build up the saved_regs table etc. for
00906    the frame.  */
00907 
00908 static struct mt_unwind_cache *
00909 mt_frame_unwind_cache (struct frame_info *this_frame,
00910                         void **this_prologue_cache)
00911 {
00912   struct gdbarch *gdbarch;
00913   struct mt_unwind_cache *info;
00914   CORE_ADDR next_addr, start_addr, end_addr, prologue_end_addr;
00915   unsigned long instr, upper_half, delayed_store = 0;
00916   int regnum, offset;
00917   ULONGEST sp, fp;
00918 
00919   if ((*this_prologue_cache))
00920     return (*this_prologue_cache);
00921 
00922   gdbarch = get_frame_arch (this_frame);
00923   info = FRAME_OBSTACK_ZALLOC (struct mt_unwind_cache);
00924   (*this_prologue_cache) = info;
00925 
00926   info->prev_sp = 0;
00927   info->framesize = 0;
00928   info->frame_base = 0;
00929   info->frameless_p = 1;
00930   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
00931 
00932   /* Grab the frame-relative values of SP and FP, needed below.
00933      The frame_saved_register function will find them on the
00934      stack or in the registers as appropriate.  */
00935   sp = get_frame_register_unsigned (this_frame, MT_SP_REGNUM);
00936   fp = get_frame_register_unsigned (this_frame, MT_FP_REGNUM);
00937 
00938   start_addr = get_frame_func (this_frame);
00939 
00940   /* Return early if GDB couldn't find the function.  */
00941   if (start_addr == 0)
00942     return info;
00943 
00944   end_addr = get_frame_pc (this_frame);
00945   prologue_end_addr = skip_prologue_using_sal (gdbarch, start_addr);
00946   if (end_addr == 0)
00947   for (next_addr = start_addr; next_addr < end_addr; next_addr += 4)
00948     {
00949       instr = get_frame_memory_unsigned (this_frame, next_addr, 4);
00950       if (delayed_store)        /* Previous instr was a push.  */
00951         {
00952           upper_half = delayed_store >> 16;
00953           regnum = upper_half & 0xf;
00954           offset = delayed_store & 0xffff;
00955           switch (upper_half & 0xfff0)
00956             {
00957             case 0x43c0:        /* push using frame pointer.  */
00958               info->saved_regs[regnum].addr = offset;
00959               break;
00960             case 0x43d0:        /* push using stack pointer.  */
00961               info->saved_regs[regnum].addr = offset;
00962               break;
00963             default:            /* lint */
00964               break;
00965             }
00966           delayed_store = 0;
00967         }
00968 
00969       switch (instr)
00970         {
00971         case 0x12000000:        /* NO-OP */
00972           continue;
00973         case 0x12ddc000:        /* copy sp into fp */
00974           info->frameless_p = 0;        /* Record that the frame
00975                                            pointer is in use.  */
00976           continue;
00977         default:
00978           upper_half = instr >> 16;
00979           if (upper_half == 0x05dd ||   /* subi  sp, sp, imm */
00980               upper_half == 0x07dd)     /* subui sp, sp, imm */
00981             {
00982               /* Record the frame size.  */
00983               info->framesize = instr & 0xffff;
00984               continue;
00985             }
00986           if ((upper_half & 0xfff0) == 0x43c0 ||        /* frame push */
00987               (upper_half & 0xfff0) == 0x43d0)  /* stack push */
00988             {
00989               /* Save this instruction, but don't record the 
00990                  pushed register as 'saved' until we see the
00991                  next instruction.  That's because of deferred stores
00992                  on this target -- GDB won't be able to read the register
00993                  from the stack until one instruction later.  */
00994               delayed_store = instr;
00995               continue;
00996             }
00997           /* Not a prologue instruction.  Is this the end of the prologue?
00998              This is the most difficult decision; when to stop scanning. 
00999 
01000              If we have no line symbol, then the best thing we can do
01001              is to stop scanning when we encounter an instruction that
01002              is not likely to be a part of the prologue. 
01003 
01004              But if we do have a line symbol, then we should 
01005              keep scanning until we reach it (or we reach end_addr).  */
01006 
01007           if (prologue_end_addr && (prologue_end_addr > (next_addr + 4)))
01008             continue;   /* Keep scanning, recording saved_regs etc.  */
01009           else
01010             break;      /* Quit scanning: breakpoint can be set here.  */
01011         }
01012     }
01013 
01014   /* Special handling for the "saved" address of the SP:
01015      The SP is of course never saved on the stack at all, so
01016      by convention what we put here is simply the previous 
01017      _value_ of the SP (as opposed to an address where the
01018      previous value would have been pushed).  This will also
01019      give us the frame base address.  */
01020 
01021   if (info->frameless_p)
01022     {
01023       info->frame_base = sp + info->framesize;
01024       info->prev_sp = sp + info->framesize;
01025     }
01026   else
01027     {
01028       info->frame_base = fp + info->framesize;
01029       info->prev_sp = fp + info->framesize;
01030     }
01031   /* Save prev_sp in saved_regs as a value, not as an address.  */
01032   trad_frame_set_value (info->saved_regs, MT_SP_REGNUM, info->prev_sp);
01033 
01034   /* Now convert frame offsets to actual addresses (not offsets).  */
01035   for (regnum = 0; regnum < MT_NUM_REGS; regnum++)
01036     if (trad_frame_addr_p (info->saved_regs, regnum))
01037       info->saved_regs[regnum].addr += info->frame_base - info->framesize;
01038 
01039   /* The call instruction moves the caller's PC in the callee's RA reg.
01040      Since this is an unwind, do the reverse.  Copy the location of RA
01041      into PC (the address / regnum) so that a request for PC will be
01042      converted into a request for the RA.  */
01043   info->saved_regs[MT_PC_REGNUM] = info->saved_regs[MT_RA_REGNUM];
01044 
01045   return info;
01046 }
01047 
01048 static CORE_ADDR
01049 mt_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
01050 {
01051   ULONGEST pc;
01052 
01053   pc = frame_unwind_register_unsigned (next_frame, MT_PC_REGNUM);
01054   return pc;
01055 }
01056 
01057 static CORE_ADDR
01058 mt_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
01059 {
01060   ULONGEST sp;
01061 
01062   sp = frame_unwind_register_unsigned (next_frame, MT_SP_REGNUM);
01063   return sp;
01064 }
01065 
01066 /* Assuming THIS_FRAME is a dummy, return the frame ID of that dummy
01067    frame.  The frame ID's base needs to match the TOS value saved by
01068    save_dummy_frame_tos(), and the PC match the dummy frame's breakpoint.  */
01069 
01070 static struct frame_id
01071 mt_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
01072 {
01073   CORE_ADDR sp = get_frame_register_unsigned (this_frame, MT_SP_REGNUM);
01074   return frame_id_build (sp, get_frame_pc (this_frame));
01075 }
01076 
01077 /* Given a GDB frame, determine the address of the calling function's
01078    frame.  This will be used to create a new GDB frame struct.  */
01079 
01080 static void
01081 mt_frame_this_id (struct frame_info *this_frame,
01082                    void **this_prologue_cache, struct frame_id *this_id)
01083 {
01084   struct mt_unwind_cache *info =
01085     mt_frame_unwind_cache (this_frame, this_prologue_cache);
01086 
01087   if (!(info == NULL || info->prev_sp == 0))
01088     (*this_id) = frame_id_build (info->prev_sp, get_frame_func (this_frame));
01089 
01090   return;
01091 }
01092 
01093 static struct value *
01094 mt_frame_prev_register (struct frame_info *this_frame,
01095                          void **this_prologue_cache, int regnum)
01096 {
01097   struct mt_unwind_cache *info =
01098     mt_frame_unwind_cache (this_frame, this_prologue_cache);
01099 
01100   return trad_frame_get_prev_register (this_frame, info->saved_regs, regnum);
01101 }
01102 
01103 static CORE_ADDR
01104 mt_frame_base_address (struct frame_info *this_frame,
01105                         void **this_prologue_cache)
01106 {
01107   struct mt_unwind_cache *info =
01108     mt_frame_unwind_cache (this_frame, this_prologue_cache);
01109 
01110   return info->frame_base;
01111 }
01112 
01113 /* This is a shared interface:  the 'frame_unwind' object is what's
01114    returned by the 'sniffer' function, and in turn specifies how to
01115    get a frame's ID and prev_regs.
01116 
01117    This exports the 'prev_register' and 'this_id' methods.  */
01118 
01119 static const struct frame_unwind mt_frame_unwind = {
01120   NORMAL_FRAME,
01121   default_frame_unwind_stop_reason,
01122   mt_frame_this_id,
01123   mt_frame_prev_register,
01124   NULL,
01125   default_frame_sniffer
01126 };
01127 
01128 /* Another shared interface:  the 'frame_base' object specifies how to
01129    unwind a frame and secure the base addresses for frame objects
01130    (locals, args).  */
01131 
01132 static struct frame_base mt_frame_base = {
01133   &mt_frame_unwind,
01134   mt_frame_base_address,
01135   mt_frame_base_address,
01136   mt_frame_base_address
01137 };
01138 
01139 static struct gdbarch *
01140 mt_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
01141 {
01142   struct gdbarch *gdbarch;
01143   struct gdbarch_tdep *tdep;
01144 
01145   /* Find a candidate among the list of pre-declared architectures.  */
01146   arches = gdbarch_list_lookup_by_info (arches, &info);
01147   if (arches != NULL)
01148     return arches->gdbarch;
01149 
01150   /* None found, create a new architecture from the information
01151      provided.  */
01152   tdep = XCALLOC (1, struct gdbarch_tdep);
01153   gdbarch = gdbarch_alloc (&info, tdep);
01154 
01155   set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
01156   set_gdbarch_double_format (gdbarch, floatformats_ieee_double);
01157   set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
01158 
01159   set_gdbarch_register_name (gdbarch, mt_register_name);
01160   set_gdbarch_num_regs (gdbarch, MT_NUM_REGS);
01161   set_gdbarch_num_pseudo_regs (gdbarch, MT_NUM_PSEUDO_REGS);
01162   set_gdbarch_pc_regnum (gdbarch, MT_PC_REGNUM);
01163   set_gdbarch_sp_regnum (gdbarch, MT_SP_REGNUM);
01164   set_gdbarch_pseudo_register_read (gdbarch, mt_pseudo_register_read);
01165   set_gdbarch_pseudo_register_write (gdbarch, mt_pseudo_register_write);
01166   set_gdbarch_skip_prologue (gdbarch, mt_skip_prologue);
01167   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
01168   set_gdbarch_breakpoint_from_pc (gdbarch, mt_breakpoint_from_pc);
01169   set_gdbarch_decr_pc_after_break (gdbarch, 0);
01170   set_gdbarch_frame_args_skip (gdbarch, 0);
01171   set_gdbarch_print_insn (gdbarch, print_insn_mt);
01172   set_gdbarch_register_type (gdbarch, mt_register_type);
01173   set_gdbarch_register_reggroup_p (gdbarch, mt_register_reggroup_p);
01174 
01175   set_gdbarch_return_value (gdbarch, mt_return_value);
01176   set_gdbarch_sp_regnum (gdbarch, MT_SP_REGNUM);
01177 
01178   set_gdbarch_frame_align (gdbarch, mt_frame_align);
01179 
01180   set_gdbarch_print_registers_info (gdbarch, mt_registers_info);
01181 
01182   set_gdbarch_push_dummy_call (gdbarch, mt_push_dummy_call);
01183 
01184   /* Target builtin data types.  */
01185   set_gdbarch_short_bit (gdbarch, 16);
01186   set_gdbarch_int_bit (gdbarch, 32);
01187   set_gdbarch_long_bit (gdbarch, 32);
01188   set_gdbarch_long_long_bit (gdbarch, 64);
01189   set_gdbarch_float_bit (gdbarch, 32);
01190   set_gdbarch_double_bit (gdbarch, 64);
01191   set_gdbarch_long_double_bit (gdbarch, 64);
01192   set_gdbarch_ptr_bit (gdbarch, 32);
01193 
01194   /* Register the DWARF 2 sniffer first, and then the traditional prologue
01195      based sniffer.  */
01196   dwarf2_append_unwinders (gdbarch);
01197   frame_unwind_append_unwinder (gdbarch, &mt_frame_unwind);
01198   frame_base_set_default (gdbarch, &mt_frame_base);
01199 
01200   /* Register the 'unwind_pc' method.  */
01201   set_gdbarch_unwind_pc (gdbarch, mt_unwind_pc);
01202   set_gdbarch_unwind_sp (gdbarch, mt_unwind_sp);
01203 
01204   /* Methods for saving / extracting a dummy frame's ID.
01205      The ID's stack address must match the SP value returned by
01206      PUSH_DUMMY_CALL, and saved by generic_save_dummy_frame_tos.  */
01207   set_gdbarch_dummy_id (gdbarch, mt_dummy_id);
01208 
01209   return gdbarch;
01210 }
01211 
01212 /* Provide a prototype to silence -Wmissing-prototypes.  */
01213 extern initialize_file_ftype _initialize_mt_tdep;
01214 
01215 void
01216 _initialize_mt_tdep (void)
01217 {
01218   register_gdbarch_init (bfd_arch_mt, mt_gdbarch_init);
01219 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines