* mips-linux-tdep.c (mips_linux_in_dynsym_resolve_code): Update
[deliverable/binutils-gdb.git] / gdb / mips-tdep.c
index 6277407695ddd46cbf9cfc91806524fcf3fd8ffd..8304a02e27bc064b0488da09afcf8d44facc9ecc 100644 (file)
@@ -142,16 +142,6 @@ const struct register_alias mips_register_aliases[] = {
   { "fsr", MIPS_EMBED_FP0_REGNUM + 32 }
 };
 
-/* Some MIPS boards don't support floating point while others only
-   support single-precision floating-point operations.  */
-
-enum mips_fpu_type
-{
-  MIPS_FPU_DOUBLE,             /* Full double precision floating point.  */
-  MIPS_FPU_SINGLE,             /* Single precision floating point (R4650).  */
-  MIPS_FPU_NONE                        /* No floating point.  */
-};
-
 #ifndef MIPS_DEFAULT_FPU_TYPE
 #define MIPS_DEFAULT_FPU_TYPE MIPS_FPU_DOUBLE
 #endif
@@ -168,37 +158,6 @@ static int mips_debug = 0;
 struct target_desc *mips_tdesc_gp32;
 struct target_desc *mips_tdesc_gp64;
 
-/* MIPS specific per-architecture information */
-struct gdbarch_tdep
-{
-  /* from the elf header */
-  int elf_flags;
-
-  /* mips options */
-  enum mips_abi mips_abi;
-  enum mips_abi found_abi;
-  enum mips_fpu_type mips_fpu_type;
-  int mips_last_arg_regnum;
-  int mips_last_fp_arg_regnum;
-  int default_mask_address_p;
-  /* Is the target using 64-bit raw integer registers but only
-     storing a left-aligned 32-bit value in each?  */
-  int mips64_transfers_32bit_regs_p;
-  /* Indexes for various registers.  IRIX and embedded have
-     different values.  This contains the "public" fields.  Don't
-     add any that do not need to be public.  */
-  const struct mips_regnum *regnum;
-  /* Register names table for the current register set.  */
-  const char **mips_processor_reg_names;
-
-  /* The size of register data available from the target, if known.
-     This doesn't quite obsolete the manual
-     mips64_transfers_32bit_regs_p, since that is documented to force
-     left alignment even for big endian (very strange).  */
-  int register_size_valid_p;
-  int register_size;
-};
-
 const struct mips_regnum *
 mips_regnum (struct gdbarch *gdbarch)
 {
@@ -211,14 +170,15 @@ mips_fpa0_regnum (struct gdbarch *gdbarch)
   return mips_regnum (gdbarch)->fp0 + 12;
 }
 
-#define MIPS_EABI (gdbarch_tdep (current_gdbarch)->mips_abi == MIPS_ABI_EABI32 \
-                  || gdbarch_tdep (current_gdbarch)->mips_abi == MIPS_ABI_EABI64)
+#define MIPS_EABI(gdbarch) (gdbarch_tdep (gdbarch)->mips_abi \
+                    == MIPS_ABI_EABI32 \
+                  || gdbarch_tdep (gdbarch)->mips_abi == MIPS_ABI_EABI64)
 
-#define MIPS_LAST_FP_ARG_REGNUM (gdbarch_tdep (current_gdbarch)->mips_last_fp_arg_regnum)
+#define MIPS_LAST_FP_ARG_REGNUM(gdbarch) (gdbarch_tdep (gdbarch)->mips_last_fp_arg_regnum)
 
-#define MIPS_LAST_ARG_REGNUM (gdbarch_tdep (current_gdbarch)->mips_last_arg_regnum)
+#define MIPS_LAST_ARG_REGNUM(gdbarch) (gdbarch_tdep (gdbarch)->mips_last_arg_regnum)
 
-#define MIPS_FPU_TYPE (gdbarch_tdep (current_gdbarch)->mips_fpu_type)
+#define MIPS_FPU_TYPE(gdbarch) (gdbarch_tdep (gdbarch)->mips_fpu_type)
 
 /* MIPS16 function addresses are odd (bit 0 is set).  Here are some
    functions to test, set, or clear bit 0 of addresses.  */
@@ -293,8 +253,7 @@ mips_elf_make_msymbol_special (asymbol * sym, struct minimal_symbol *msym)
 {
   if (((elf_symbol_type *) (sym))->internal_elf_sym.st_other == STO_MIPS16)
     {
-      MSYMBOL_INFO (msym) = (char *)
-       (((long) MSYMBOL_INFO (msym)) | 0x80000000);
+      MSYMBOL_TARGET_FLAG_1 (msym) = 1;
       SYMBOL_VALUE_ADDRESS (msym) |= 1;
     }
 }
@@ -302,7 +261,7 @@ mips_elf_make_msymbol_special (asymbol * sym, struct minimal_symbol *msym)
 static int
 msymbol_is_special (struct minimal_symbol *msym)
 {
-  return (((long) MSYMBOL_INFO (msym) & 0x80000000) != 0);
+  return MSYMBOL_TARGET_FLAG_1 (msym);
 }
 
 /* XFER a value from the big/little/left end of the register.
@@ -391,7 +350,7 @@ mips2_fp_compat (struct frame_info *frame)
 
 #define VM_MIN_ADDRESS (CORE_ADDR)0x400000
 
-static CORE_ADDR heuristic_proc_start (CORE_ADDR);
+static CORE_ADDR heuristic_proc_start (struct gdbarch *, CORE_ADDR);
 
 static void reinit_frame_cache_sfunc (char *, int, struct cmd_list_element *);
 
@@ -777,12 +736,13 @@ mips_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
 
   /* Use pointer types for registers if we can.  For n32 we can not,
      since we do not have a 64-bit pointer type.  */
-  if (mips_abi_regsize (gdbarch) == TYPE_LENGTH (builtin_type_void_data_ptr))
+  if (mips_abi_regsize (gdbarch)
+      == TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr))
     {
       if (rawnum == MIPS_SP_REGNUM || rawnum == MIPS_EMBED_BADVADDR_REGNUM)
-       return builtin_type_void_data_ptr;
+       return builtin_type (gdbarch)->builtin_data_ptr;
       else if (rawnum == MIPS_EMBED_PC_REGNUM)
-       return builtin_type_void_func_ptr;
+       return builtin_type (gdbarch)->builtin_func_ptr;
     }
 
   if (mips_abi_regsize (gdbarch) == 4 && TYPE_LENGTH (rawtype) == 8
@@ -818,7 +778,7 @@ static void
 show_mask_address (struct ui_file *file, int from_tty,
                   struct cmd_list_element *c, const char *value)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (target_gdbarch);
 
   deprecated_show_value_hack (file, from_tty, c, value);
   switch (mask_address_var)
@@ -1017,6 +977,17 @@ mips32_next_pc (struct frame_info *frame, CORE_ADDR pc)
              /* Set PC to that address */
              pc = get_frame_register_signed (frame, rtype_rs (inst));
              break;
+           case 12:            /* SYSCALL */
+             {
+               struct gdbarch_tdep *tdep;
+
+               tdep = gdbarch_tdep (get_frame_arch (frame));
+               if (tdep->syscall_next_pc != NULL)
+                 pc = tdep->syscall_next_pc (frame);
+               else
+                 pc += 4;
+             }
+             break;
            default:
              pc += 4;
            }
@@ -1431,18 +1402,16 @@ struct mips_frame_cache
    saved registers in a frame.  */
 
 static void
-set_reg_offset (struct mips_frame_cache *this_cache, int regnum,
-               CORE_ADDR offset)
+set_reg_offset (struct gdbarch *gdbarch, struct mips_frame_cache *this_cache,
+               int regnum, CORE_ADDR offset)
 {
   if (this_cache != NULL
       && this_cache->saved_regs[regnum].addr == -1)
     {
-      this_cache->saved_regs[regnum
-                            + 0 * gdbarch_num_regs (current_gdbarch)].addr
-      = offset;
-      this_cache->saved_regs[regnum
-                            + 1 * gdbarch_num_regs (current_gdbarch)].addr
-      = offset;
+      this_cache->saved_regs[regnum + 0 * gdbarch_num_regs (gdbarch)].addr
+        = offset;
+      this_cache->saved_regs[regnum + 1 * gdbarch_num_regs (gdbarch)].addr
+        = offset;
     }
 }
 
@@ -1559,23 +1528,23 @@ mips16_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
        {
          offset = mips16_get_imm (prev_inst, inst, 8, 4, 0);
          reg = mips16_to_32_reg[(inst & 0x700) >> 8];
-         set_reg_offset (this_cache, reg, sp + offset);
+         set_reg_offset (gdbarch, this_cache, reg, sp + offset);
        }
       else if ((inst & 0xff00) == 0xf900)      /* sd reg,n($sp) */
        {
          offset = mips16_get_imm (prev_inst, inst, 5, 8, 0);
          reg = mips16_to_32_reg[(inst & 0xe0) >> 5];
-         set_reg_offset (this_cache, reg, sp + offset);
+         set_reg_offset (gdbarch, this_cache, reg, sp + offset);
        }
       else if ((inst & 0xff00) == 0x6200)      /* sw $ra,n($sp) */
        {
          offset = mips16_get_imm (prev_inst, inst, 8, 4, 0);
-         set_reg_offset (this_cache, MIPS_RA_REGNUM, sp + offset);
+         set_reg_offset (gdbarch, this_cache, MIPS_RA_REGNUM, sp + offset);
        }
       else if ((inst & 0xff00) == 0xfa00)      /* sd $ra,n($sp) */
        {
          offset = mips16_get_imm (prev_inst, inst, 8, 8, 0);
-         set_reg_offset (this_cache, MIPS_RA_REGNUM, sp + offset);
+         set_reg_offset (gdbarch, this_cache, MIPS_RA_REGNUM, sp + offset);
        }
       else if (inst == 0x673d) /* move $s1, $sp */
        {
@@ -1593,13 +1562,13 @@ mips16_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
        {
          offset = mips16_get_imm (prev_inst, inst, 5, 4, 0);
          reg = mips16_to_32_reg[(inst & 0xe0) >> 5];
-         set_reg_offset (this_cache, reg, frame_addr + offset);
+         set_reg_offset (gdbarch, this_cache, reg, frame_addr + offset);
        }
       else if ((inst & 0xFF00) == 0x7900)      /* sd reg,offset($s1) */
        {
          offset = mips16_get_imm (prev_inst, inst, 5, 8, 0);
          reg = mips16_to_32_reg[(inst & 0xe0) >> 5];
-         set_reg_offset (this_cache, reg, frame_addr + offset);
+         set_reg_offset (gdbarch, this_cache, reg, frame_addr + offset);
        }
       else if ((inst & 0xf81f) == 0xe809
                && (inst & 0x700) != 0x700)     /* entry */
@@ -1648,7 +1617,7 @@ mips16_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
       /* Check if a0-a3 were saved in the caller's argument save area.  */
       for (reg = 4, offset = 0; reg < areg_count + 4; reg++)
        {
-         set_reg_offset (this_cache, reg, sp + offset);
+         set_reg_offset (gdbarch, this_cache, reg, sp + offset);
          offset += mips_abi_regsize (gdbarch);
        }
 
@@ -1656,14 +1625,14 @@ mips16_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
       offset = -4;
       if (entry_inst & 0x20)
        {
-         set_reg_offset (this_cache, MIPS_RA_REGNUM, sp + offset);
+         set_reg_offset (gdbarch, this_cache, MIPS_RA_REGNUM, sp + offset);
          offset -= mips_abi_regsize (gdbarch);
        }
 
       /* Check if the s0 and s1 registers were pushed on the stack.  */
       for (reg = 16; reg < sreg_count + 16; reg++)
        {
-         set_reg_offset (this_cache, reg, sp + offset);
+         set_reg_offset (gdbarch, this_cache, reg, sp + offset);
          offset -= mips_abi_regsize (gdbarch);
        }
     }
@@ -1715,7 +1684,7 @@ mips16_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
       /* Check if A0-A3 were saved in the caller's argument save area.  */
       for (reg = MIPS_A0_REGNUM, offset = 0; reg < args + 4; reg++)
        {
-         set_reg_offset (this_cache, reg, sp + offset);
+         set_reg_offset (gdbarch, this_cache, reg, sp + offset);
          offset += mips_abi_regsize (gdbarch);
        }
 
@@ -1724,41 +1693,41 @@ mips16_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
       /* Check if the RA register was pushed on the stack.  */
       if (save_inst & 0x40)
        {
-         set_reg_offset (this_cache, MIPS_RA_REGNUM, sp + offset);
+         set_reg_offset (gdbarch, this_cache, MIPS_RA_REGNUM, sp + offset);
          offset -= mips_abi_regsize (gdbarch);
        }
 
       /* Check if the S8 register was pushed on the stack.  */
       if (xsregs > 6)
        {
-         set_reg_offset (this_cache, 30, sp + offset);
+         set_reg_offset (gdbarch, this_cache, 30, sp + offset);
          offset -= mips_abi_regsize (gdbarch);
          xsregs--;
        }
       /* Check if S2-S7 were pushed on the stack.  */
       for (reg = 18 + xsregs - 1; reg > 18 - 1; reg--)
        {
-         set_reg_offset (this_cache, reg, sp + offset);
+         set_reg_offset (gdbarch, this_cache, reg, sp + offset);
          offset -= mips_abi_regsize (gdbarch);
        }
 
       /* Check if the S1 register was pushed on the stack.  */
       if (save_inst & 0x10)
        {
-         set_reg_offset (this_cache, 17, sp + offset);
+         set_reg_offset (gdbarch, this_cache, 17, sp + offset);
          offset -= mips_abi_regsize (gdbarch);
        }
       /* Check if the S0 register was pushed on the stack.  */
       if (save_inst & 0x20)
        {
-         set_reg_offset (this_cache, 16, sp + offset);
+         set_reg_offset (gdbarch, this_cache, 16, sp + offset);
          offset -= mips_abi_regsize (gdbarch);
        }
 
       /* Check if A0-A3 were pushed on the stack.  */
       for (reg = MIPS_A0_REGNUM + 3; reg > MIPS_A0_REGNUM + 3 - astatic; reg--)
        {
-         set_reg_offset (this_cache, reg, sp + offset);
+         set_reg_offset (gdbarch, this_cache, reg, sp + offset);
          offset -= mips_abi_regsize (gdbarch);
        }
     }
@@ -1808,7 +1777,7 @@ mips_insn16_frame_cache (struct frame_info *this_frame, void **this_cache)
 
     find_pc_partial_function (pc, NULL, &start_addr, NULL);
     if (start_addr == 0)
-      start_addr = heuristic_proc_start (pc);
+      start_addr = heuristic_proc_start (get_frame_arch (this_frame), pc);
     /* We can't analyze the prologue if we couldn't find the begining
        of the function.  */
     if (start_addr == 0)
@@ -1893,14 +1862,14 @@ mips_insn16_frame_base_sniffer (struct frame_info *this_frame)
 /* Mark all the registers as unset in the saved_regs array
    of THIS_CACHE.  Do nothing if THIS_CACHE is null.  */
 
-void
-reset_saved_regs (struct mips_frame_cache *this_cache)
+static void
+reset_saved_regs (struct gdbarch *gdbarch, struct mips_frame_cache *this_cache)
 {
   if (this_cache == NULL || this_cache->saved_regs == NULL)
     return;
 
   {
-    const int num_regs = gdbarch_num_regs (current_gdbarch);
+    const int num_regs = gdbarch_num_regs (gdbarch);
     int i;
 
     for (i = 0; i < num_regs; i++)
@@ -1928,6 +1897,7 @@ mips32_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
   CORE_ADDR end_prologue_addr = 0;
   int seen_sp_adjust = 0;
   int load_immediate_bytes = 0;
+  int in_delay_slot = 0;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   int regsize_is_64_bits = (mips_abi_regsize (gdbarch) == 8);
 
@@ -1975,13 +1945,13 @@ restart:
       else if (((high_word & 0xFFE0) == 0xafa0) /* sw reg,offset($sp) */
                && !regsize_is_64_bits)
        {
-         set_reg_offset (this_cache, reg, sp + low_word);
+         set_reg_offset (gdbarch, this_cache, reg, sp + low_word);
        }
       else if (((high_word & 0xFFE0) == 0xffa0)        /* sd reg,offset($sp) */
                && regsize_is_64_bits)
        {
          /* Irix 6.2 N32 ABI uses sd instructions for saving $gp and $ra.  */
-         set_reg_offset (this_cache, reg, sp + low_word);
+         set_reg_offset (gdbarch, this_cache, reg, sp + low_word);
        }
       else if (high_word == 0x27be)    /* addiu $30,$sp,size */
        {
@@ -2007,7 +1977,7 @@ restart:
                      we will hit a guard that prevents the new address
                      for each register to be recomputed during the second
                      pass.  */
-                  reset_saved_regs (this_cache);
+                  reset_saved_regs (gdbarch, this_cache);
                  goto restart;
                }
            }
@@ -2037,7 +2007,7 @@ restart:
                      we will hit a guard that prevents the new address
                      for each register to be recomputed during the second
                      pass.  */
-                  reset_saved_regs (this_cache);
+                  reset_saved_regs (gdbarch, this_cache);
                  goto restart;
                }
            }
@@ -2045,7 +2015,7 @@ restart:
       else if ((high_word & 0xFFE0) == 0xafc0  /* sw reg,offset($30) */
                && !regsize_is_64_bits)
        {
-         set_reg_offset (this_cache, reg, frame_addr + low_word);
+         set_reg_offset (gdbarch, this_cache, reg, frame_addr + low_word);
        }
       else if ((high_word & 0xFFE0) == 0xE7A0 /* swc1 freg,n($sp) */
                || (high_word & 0xF3E0) == 0xA3C0 /* sx reg,n($s8) */
@@ -2085,7 +2055,18 @@ restart:
             instructions?  */
          if (end_prologue_addr == 0)
            end_prologue_addr = cur_pc;
+
+        /* Check for branches and jumps.  For now, only jump to
+           register are caught (i.e. returns).  */
+        if ((itype_op (inst) & 0x07) == 0 && rtype_funct (inst) == 8)
+          in_delay_slot = 1;
        }
+
+      /* If the previous instruction was a jump, we must have reached
+        the end of the prologue by now.  Stop scanning so that we do
+        not go past the function return.  */
+      if (in_delay_slot)
+       break;
     }
 
   if (this_cache != NULL)
@@ -2145,7 +2126,7 @@ mips_insn32_frame_cache (struct frame_info *this_frame, void **this_cache)
 
     find_pc_partial_function (pc, NULL, &start_addr, NULL);
     if (start_addr == 0)
-      start_addr = heuristic_proc_start (pc);
+      start_addr = heuristic_proc_start (get_frame_arch (this_frame), pc);
     /* We can't analyze the prologue if we couldn't find the begining
        of the function.  */
     if (start_addr == 0)
@@ -2287,6 +2268,7 @@ mips_stub_frame_sniffer (const struct frame_unwind *self,
   gdb_byte dummy[4];
   struct obj_section *s;
   CORE_ADDR pc = get_frame_address_in_block (this_frame);
+  struct minimal_symbol *msym;
 
   /* Use the stub unwinder for unreadable code.  */
   if (target_read_memory (get_frame_pc (this_frame), dummy, 4) != 0)
@@ -2303,6 +2285,14 @@ mips_stub_frame_sniffer (const struct frame_unwind *self,
                 ".MIPS.stubs") == 0)
     return 1;
 
+  /* Calling a PIC function from a non-PIC function passes through a
+     stub.  The stub for foo is named ".pic.foo".  */
+  msym = lookup_minimal_symbol_by_pc (pc);
+  if (msym != NULL
+      && SYMBOL_LINKAGE_NAME (msym) != NULL
+      && strncmp (SYMBOL_LINKAGE_NAME (msym), ".pic.", 5) == 0)
+    return 1;
+
   return 0;
 }
 
@@ -2344,9 +2334,9 @@ mips_stub_frame_base_sniffer (struct frame_info *this_frame)
 /* mips_addr_bits_remove - remove useless address bits  */
 
 static CORE_ADDR
-mips_addr_bits_remove (CORE_ADDR addr)
+mips_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   if (mips_mask_address_p (tdep) && (((ULONGEST) addr) >> 32 == 0xffffffffUL))
     /* This hack is a work-around for existing boards using PMON, the
        simulator, and any other 64-bit targets that doesn't have true
@@ -2517,14 +2507,15 @@ mips_about_to_return (CORE_ADDR pc)
    lines.  */
 
 static CORE_ADDR
-heuristic_proc_start (CORE_ADDR pc)
+heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   CORE_ADDR start_pc;
   CORE_ADDR fence;
   int instlen;
   int seen_adjsp = 0;
+  struct inferior *inf;
 
-  pc = gdbarch_addr_bits_remove (current_gdbarch, pc);
+  pc = gdbarch_addr_bits_remove (gdbarch, pc);
   start_pc = pc;
   fence = start_pc - heuristic_fence_post;
   if (start_pc == 0)
@@ -2535,6 +2526,8 @@ heuristic_proc_start (CORE_ADDR pc)
 
   instlen = mips_pc_is_mips16 (pc) ? MIPS_INSN16_SIZE : MIPS_INSN32_SIZE;
 
+  inf = current_inferior ();
+
   /* search back for previous return */
   for (start_pc -= instlen;; start_pc -= instlen)
     if (start_pc < fence)
@@ -2543,7 +2536,7 @@ heuristic_proc_start (CORE_ADDR pc)
           stop_soon, but with this test, at least we
           don't print out warnings for every child forked (eg, on
           decstation).  22apr93 rich@cygnus.com.  */
-       if (stop_soon == NO_STOP_QUIETLY)
+       if (inf->stop_soon == NO_STOP_QUIETLY)
          {
            static int blurb_printed = 0;
 
@@ -2633,16 +2626,17 @@ struct mips_objfile_private
    arguments into integer registers. */
 
 static int
-fp_register_arg_p (enum type_code typecode, struct type *arg_type)
+fp_register_arg_p (struct gdbarch *gdbarch, enum type_code typecode,
+                  struct type *arg_type)
 {
   return ((typecode == TYPE_CODE_FLT
-          || (MIPS_EABI
+          || (MIPS_EABI (gdbarch)
               && (typecode == TYPE_CODE_STRUCT
                   || typecode == TYPE_CODE_UNION)
               && TYPE_NFIELDS (arg_type) == 1
               && TYPE_CODE (check_typedef (TYPE_FIELD_TYPE (arg_type, 0))) 
               == TYPE_CODE_FLT))
-         && MIPS_FPU_TYPE != MIPS_FPU_NONE);
+         && MIPS_FPU_TYPE(gdbarch) != MIPS_FPU_NONE);
 }
 
 /* On o32, argument passing in GPRs depends on the alignment of the type being
@@ -2777,7 +2771,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          up before the check to see if there are any FP registers
          left.  Non MIPS_EABI targets also pass the FP in the integer
          registers so also round up normal registers.  */
-      if (regsize < 8 && fp_register_arg_p (typecode, arg_type))
+      if (regsize < 8 && fp_register_arg_p (gdbarch, typecode, arg_type))
        {
          if ((float_argreg & 1))
            float_argreg++;
@@ -2795,8 +2789,8 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       /* MIPS_EABI squeezes a struct that contains a single floating
          point value into an FP register instead of pushing it onto the
          stack.  */
-      if (fp_register_arg_p (typecode, arg_type)
-         && float_argreg <= MIPS_LAST_FP_ARG_REGNUM)
+      if (fp_register_arg_p (gdbarch, typecode, arg_type)
+         && float_argreg <= MIPS_LAST_FP_ARG_REGNUM (gdbarch))
        {
          /* EABI32 will pass doubles in consecutive registers, even on
             64-bit cores.  At one time, we used to check the size of
@@ -2861,9 +2855,9 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                                    partial_len);
 
              /* Write this portion of the argument to the stack.  */
-             if (argreg > MIPS_LAST_ARG_REGNUM
+             if (argreg > MIPS_LAST_ARG_REGNUM (gdbarch)
                  || odd_sized_struct
-                 || fp_register_arg_p (typecode, arg_type))
+                 || fp_register_arg_p (gdbarch, typecode, arg_type))
                {
                  /* Should shorter than int integer values be
                     promoted to int before being stored? */
@@ -2912,8 +2906,8 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                 arguments will not.  */
              /* Write this portion of the argument to a general
                 purpose register.  */
-             if (argreg <= MIPS_LAST_ARG_REGNUM
-                 && !fp_register_arg_p (typecode, arg_type))
+             if (argreg <= MIPS_LAST_ARG_REGNUM (gdbarch)
+                 && !fp_register_arg_p (gdbarch, typecode, arg_type))
                {
                  LONGEST regval =
                    extract_unsigned_integer (val, partial_len);
@@ -2956,10 +2950,59 @@ mips_eabi_return_value (struct gdbarch *gdbarch, struct type *func_type,
                        struct type *type, struct regcache *regcache,
                        gdb_byte *readbuf, const gdb_byte *writebuf)
 {
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int fp_return_type = 0;
+  int offset, regnum, xfer;
+
   if (TYPE_LENGTH (type) > 2 * mips_abi_regsize (gdbarch))
     return RETURN_VALUE_STRUCT_CONVENTION;
-  if (readbuf)
-    memset (readbuf, 0, TYPE_LENGTH (type));
+
+  /* Floating point type?  */
+  if (tdep->mips_fpu_type != MIPS_FPU_NONE)
+    {
+      if (TYPE_CODE (type) == TYPE_CODE_FLT)
+       fp_return_type = 1;
+      /* Structs with a single field of float type 
+        are returned in a floating point register.  */
+      if ((TYPE_CODE (type) == TYPE_CODE_STRUCT
+          || TYPE_CODE (type) == TYPE_CODE_UNION)
+         && TYPE_NFIELDS (type) == 1)
+       {
+         struct type *fieldtype = TYPE_FIELD_TYPE (type, 0);
+
+         if (TYPE_CODE (check_typedef (fieldtype)) == TYPE_CODE_FLT)
+           fp_return_type = 1;
+       }
+    }
+
+  if (fp_return_type)      
+    {
+      /* A floating-point value belongs in the least significant part
+        of FP0/FP1.  */
+      if (mips_debug)
+       fprintf_unfiltered (gdb_stderr, "Return float in $fp0\n");
+      regnum = mips_regnum (gdbarch)->fp0;
+    }
+  else 
+    {
+      /* An integer value goes in V0/V1.  */
+      if (mips_debug)
+       fprintf_unfiltered (gdb_stderr, "Return scalar in $v0\n");
+      regnum = MIPS_V0_REGNUM;
+    }
+  for (offset = 0;
+       offset < TYPE_LENGTH (type);
+       offset += mips_abi_regsize (gdbarch), regnum++)
+    {
+      xfer = mips_abi_regsize (gdbarch);
+      if (offset + xfer > TYPE_LENGTH (type))
+       xfer = TYPE_LENGTH (type) - offset;
+      mips_xfer_register (gdbarch, regcache,
+                         gdbarch_num_regs (gdbarch) + regnum, xfer,
+                         gdbarch_byte_order (gdbarch), readbuf, writebuf,
+                         offset);
+    }
+
   return RETURN_VALUE_REGISTER_CONVENTION;
 }
 
@@ -2971,14 +3014,15 @@ mips_eabi_return_value (struct gdbarch *gdbarch, struct type *func_type,
    registers.  */
 
 static int
-mips_n32n64_fp_arg_chunk_p (struct type *arg_type, int offset)
+mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type,
+                           int offset)
 {
   int i;
 
   if (TYPE_CODE (arg_type) != TYPE_CODE_STRUCT)
     return 0;
 
-  if (MIPS_FPU_TYPE != MIPS_FPU_DOUBLE)
+  if (MIPS_FPU_TYPE (gdbarch) != MIPS_FPU_DOUBLE)
     return 0;
 
   if (TYPE_LENGTH (arg_type) < offset + MIPS64_REGSIZE)
@@ -3013,7 +3057,7 @@ mips_n32n64_fp_arg_chunk_p (struct type *arg_type, int offset)
 
       /* This field starts at or before the requested offset, and
         overlaps it.  If it is a structure, recurse inwards.  */
-      return mips_n32n64_fp_arg_chunk_p (field_type, offset - pos);
+      return mips_n32n64_fp_arg_chunk_p (gdbarch, field_type, offset - pos);
     }
 
   return 0;
@@ -3092,23 +3136,49 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
       val = value_contents (arg);
 
-      if (fp_register_arg_p (typecode, arg_type)
-         && argreg <= MIPS_LAST_ARG_REGNUM)
+      /* A 128-bit long double value requires an even-odd pair of
+        floating-point registers.  */
+      if (len == 16
+         && fp_register_arg_p (gdbarch, typecode, arg_type)
+         && (float_argreg & 1))
+       {
+         float_argreg++;
+         argreg++;
+       }
+
+      if (fp_register_arg_p (gdbarch, typecode, arg_type)
+         && argreg <= MIPS_LAST_ARG_REGNUM (gdbarch))
        {
          /* This is a floating point value that fits entirely
-            in a single register.  */
-         LONGEST regval = extract_unsigned_integer (val, len);
+            in a single register or a pair of registers.  */
+         int reglen = (len <= MIPS64_REGSIZE ? len : MIPS64_REGSIZE);
+         LONGEST regval = extract_unsigned_integer (val, reglen);
          if (mips_debug)
            fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
-                               float_argreg, phex (regval, len));
+                               float_argreg, phex (regval, reglen));
          regcache_cooked_write_unsigned (regcache, float_argreg, regval);
 
          if (mips_debug)
            fprintf_unfiltered (gdb_stdlog, " - reg=%d val=%s",
-                               argreg, phex (regval, len));
+                               argreg, phex (regval, reglen));
          regcache_cooked_write_unsigned (regcache, argreg, regval);
          float_argreg++;
          argreg++;
+         if (len == 16)
+           {
+             regval = extract_unsigned_integer (val + reglen, reglen);
+             if (mips_debug)
+               fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
+                                   float_argreg, phex (regval, reglen));
+             regcache_cooked_write_unsigned (regcache, float_argreg, regval);
+
+             if (mips_debug)
+               fprintf_unfiltered (gdb_stdlog, " - reg=%d val=%s",
+                                   argreg, phex (regval, reglen));
+             regcache_cooked_write_unsigned (regcache, argreg, regval);
+             float_argreg++;
+             argreg++;
+           }
        }
       else
        {
@@ -3135,11 +3205,11 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                fprintf_unfiltered (gdb_stdlog, " -- partial=%d",
                                    partial_len);
 
-             if (fp_register_arg_p (typecode, arg_type))
-               gdb_assert (argreg > MIPS_LAST_ARG_REGNUM);
+             if (fp_register_arg_p (gdbarch, typecode, arg_type))
+               gdb_assert (argreg > MIPS_LAST_ARG_REGNUM (gdbarch));
 
              /* Write this portion of the argument to the stack.  */
-             if (argreg > MIPS_LAST_ARG_REGNUM)
+             if (argreg > MIPS_LAST_ARG_REGNUM (gdbarch))
                {
                  /* Should shorter than int integer values be
                     promoted to int before being stored? */
@@ -3149,8 +3219,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
                    {
                      if ((typecode == TYPE_CODE_INT
-                          || typecode == TYPE_CODE_PTR
-                          || typecode == TYPE_CODE_FLT)
+                          || typecode == TYPE_CODE_PTR)
                          && len <= 4)
                        longword_offset = MIPS64_REGSIZE - len;
                    }
@@ -3183,7 +3252,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                 structs may go thru BOTH paths.  */
              /* Write this portion of the argument to a general
                 purpose register.  */
-             if (argreg <= MIPS_LAST_ARG_REGNUM)
+             if (argreg <= MIPS_LAST_ARG_REGNUM (gdbarch))
                {
                  LONGEST regval;
 
@@ -3223,7 +3292,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                                      phex (regval, MIPS64_REGSIZE));
                  regcache_cooked_write_unsigned (regcache, argreg, regval);
 
-                 if (mips_n32n64_fp_arg_chunk_p (arg_type,
+                 if (mips_n32n64_fp_arg_chunk_p (gdbarch, arg_type,
                                                  TYPE_LENGTH (arg_type) - len))
                    {
                      if (mips_debug)
@@ -3339,15 +3408,16 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct type *func_type,
                   && (TYPE_CODE (check_typedef (TYPE_FIELD_TYPE (type, 0)))
                       == TYPE_CODE_FLT)
                   && (TYPE_CODE (check_typedef (TYPE_FIELD_TYPE (type, 1)))
-                      == TYPE_CODE_FLT)))
-          && tdep->mips_fpu_type != MIPS_FPU_NONE)
+                      == TYPE_CODE_FLT))))
     {
       /* A struct that contains one or two floats.  Each value is part
          in the least significant part of their floating point
-         register..  */
+         register (or GPR, for soft float).  */
       int regnum;
       int field;
-      for (field = 0, regnum = mips_regnum (gdbarch)->fp0;
+      for (field = 0, regnum = (tdep->mips_fpu_type != MIPS_FPU_NONE
+                               ? mips_regnum (gdbarch)->fp0
+                               : MIPS_V0_REGNUM);
           field < TYPE_NFIELDS (type); field++, regnum += 2)
        {
          int offset = (FIELD_BITPOS (TYPE_FIELDS (type)[field])
@@ -3355,11 +3425,27 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct type *func_type,
          if (mips_debug)
            fprintf_unfiltered (gdb_stderr, "Return float struct+%d\n",
                                offset);
-         mips_xfer_register (gdbarch, regcache,
-                             gdbarch_num_regs (gdbarch) + regnum,
-                             TYPE_LENGTH (TYPE_FIELD_TYPE (type, field)),
-                             gdbarch_byte_order (gdbarch),
-                             readbuf, writebuf, offset);
+         if (TYPE_LENGTH (TYPE_FIELD_TYPE (type, field)) == 16)
+           {
+             /* A 16-byte long double field goes in two consecutive
+                registers.  */
+             mips_xfer_register (gdbarch, regcache,
+                                 gdbarch_num_regs (gdbarch) + regnum,
+                                 8,
+                                 gdbarch_byte_order (gdbarch),
+                                 readbuf, writebuf, offset);
+             mips_xfer_register (gdbarch, regcache,
+                                 gdbarch_num_regs (gdbarch) + regnum + 1,
+                                 8,
+                                 gdbarch_byte_order (gdbarch),
+                                 readbuf, writebuf, offset + 8);
+           }
+         else
+           mips_xfer_register (gdbarch, regcache,
+                               gdbarch_num_regs (gdbarch) + regnum,
+                               TYPE_LENGTH (TYPE_FIELD_TYPE (type, field)),
+                               gdbarch_byte_order (gdbarch),
+                               readbuf, writebuf, offset);
        }
       return RETURN_VALUE_REGISTER_CONVENTION;
     }
@@ -3503,7 +3589,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          up before the check to see if there are any FP registers
          left.  O32/O64 targets also pass the FP in the integer
          registers so also round up normal registers.  */
-      if (fp_register_arg_p (typecode, arg_type))
+      if (fp_register_arg_p (gdbarch, typecode, arg_type))
        {
          if ((float_argreg & 1))
            float_argreg++;
@@ -3519,8 +3605,8 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          arguments in general registers can't hurt non-MIPS16 functions
          because those registers are normally skipped.  */
 
-      if (fp_register_arg_p (typecode, arg_type)
-         && float_argreg <= MIPS_LAST_FP_ARG_REGNUM)
+      if (fp_register_arg_p (gdbarch, typecode, arg_type)
+         && float_argreg <= MIPS_LAST_FP_ARG_REGNUM (gdbarch))
        {
          if (register_size (gdbarch, float_argreg) < 8 && len == 8)
            {
@@ -3562,15 +3648,13 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
                                    float_argreg, phex (regval, len));
              regcache_cooked_write_unsigned (regcache, float_argreg++, regval);
-             /* CAGNEY: 32 bit MIPS ABI's always reserve two FP
-                registers for each argument.  The below is (my
-                guess) to ensure that the corresponding integer
-                register has reserved the same space.  */
+             /* Although two FP registers are reserved for each
+                argument, only one corresponding integer register is
+                reserved.  */
              if (mips_debug)
                fprintf_unfiltered (gdb_stdlog, " - reg=%d val=%s",
                                    argreg, phex (regval, len));
-             regcache_cooked_write_unsigned (regcache, argreg, regval);
-             argreg += 2;
+             regcache_cooked_write_unsigned (regcache, argreg++, regval);
            }
          /* Reserve space for the FP register.  */
          stack_offset += align_up (len, MIPS32_REGSIZE);
@@ -3608,7 +3692,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                                    partial_len);
 
              /* Write this portion of the argument to the stack.  */
-             if (argreg > MIPS_LAST_ARG_REGNUM
+             if (argreg > MIPS_LAST_ARG_REGNUM (gdbarch)
                  || odd_sized_struct)
                {
                  /* Should shorter than int integer values be
@@ -3645,7 +3729,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                 structs may go thru BOTH paths.  */
              /* Write this portion of the argument to a general
                 purpose register.  */
-             if (argreg <= MIPS_LAST_ARG_REGNUM)
+             if (argreg <= MIPS_LAST_ARG_REGNUM (gdbarch))
                {
                  LONGEST regval = extract_signed_integer (val, partial_len);
                  /* Value may need to be sign extended, because
@@ -3692,7 +3776,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
                  /* Prevent subsequent floating point arguments from
                     being passed in floating point registers.  */
-                 float_argreg = MIPS_LAST_FP_ARG_REGNUM + 1;
+                 float_argreg = MIPS_LAST_FP_ARG_REGNUM (gdbarch) + 1;
                }
 
              len -= partial_len;
@@ -3967,8 +4051,8 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          arguments in general registers can't hurt non-MIPS16 functions
          because those registers are normally skipped.  */
 
-      if (fp_register_arg_p (typecode, arg_type)
-         && float_argreg <= MIPS_LAST_FP_ARG_REGNUM)
+      if (fp_register_arg_p (gdbarch, typecode, arg_type)
+         && float_argreg <= MIPS_LAST_FP_ARG_REGNUM (gdbarch))
        {
          LONGEST regval = extract_unsigned_integer (val, len);
          if (mips_debug)
@@ -4005,7 +4089,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                                    partial_len);
 
              /* Write this portion of the argument to the stack.  */
-             if (argreg > MIPS_LAST_ARG_REGNUM
+             if (argreg > MIPS_LAST_ARG_REGNUM (gdbarch)
                  || odd_sized_struct)
                {
                  /* Should shorter than int integer values be
@@ -4050,7 +4134,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                 structs may go thru BOTH paths.  */
              /* Write this portion of the argument to a general
                 purpose register.  */
-             if (argreg <= MIPS_LAST_ARG_REGNUM)
+             if (argreg <= MIPS_LAST_ARG_REGNUM (gdbarch))
                {
                  LONGEST regval = extract_signed_integer (val, partial_len);
                  /* Value may need to be sign extended, because
@@ -4081,7 +4165,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
                  /* Prevent subsequent floating point arguments from
                     being passed in floating point registers.  */
-                 float_argreg = MIPS_LAST_FP_ARG_REGNUM + 1;
+                 float_argreg = MIPS_LAST_FP_ARG_REGNUM (gdbarch) + 1;
                }
 
              len -= partial_len;
@@ -4119,7 +4203,7 @@ mips_o64_return_value (struct gdbarch *gdbarch, struct type *func_type,
       || TYPE_CODE (type) == TYPE_CODE_UNION
       || TYPE_CODE (type) == TYPE_CODE_ARRAY)
     return RETURN_VALUE_STRUCT_CONVENTION;
-  else if (fp_register_arg_p (TYPE_CODE (type), type))
+  else if (fp_register_arg_p (gdbarch, TYPE_CODE (type), type))
     {
       /* A floating-point value.  It fits in the least significant
          part of FP0.  */
@@ -4728,7 +4812,7 @@ show_mipsfpu_command (char *args, int from_tty)
 {
   char *fpu;
 
-  if (gdbarch_bfd_arch_info (current_gdbarch)->arch != bfd_arch_mips)
+  if (gdbarch_bfd_arch_info (target_gdbarch)->arch != bfd_arch_mips)
     {
       printf_unfiltered
        ("The MIPS floating-point coprocessor is unknown "
@@ -4736,7 +4820,7 @@ show_mipsfpu_command (char *args, int from_tty)
       return;
     }
 
-  switch (MIPS_FPU_TYPE)
+  switch (MIPS_FPU_TYPE (target_gdbarch))
     {
     case MIPS_FPU_SINGLE:
       fpu = "single-precision";
@@ -4825,11 +4909,12 @@ set_mipsfpu_auto_command (char *args, int from_tty)
 void
 deprecated_mips_set_processor_regs_hack (void)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  struct regcache *regcache = get_current_regcache ();
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   ULONGEST prid;
 
-  regcache_cooked_read_unsigned (get_current_regcache (),
-                                MIPS_PRID_REGNUM, &prid);
+  regcache_cooked_read_unsigned (regcache, MIPS_PRID_REGNUM, &prid);
   if ((prid & ~0xf) == 0x700)
     tdep->mips_processor_reg_names = mips_r3041_reg_names;
 }
@@ -4847,8 +4932,6 @@ reinit_frame_cache_sfunc (char *args, int from_tty,
 static int
 gdb_print_insn_mips (bfd_vma memaddr, struct disassemble_info *info)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
-
   /* FIXME: cagney/2003-06-26: Is this even necessary?  The
      disassembler needs to be able to locally determine the ISA, and
      not rely on GDB.  Otherwize the stand-alone 'objdump -d' will not
@@ -4860,17 +4943,7 @@ gdb_print_insn_mips (bfd_vma memaddr, struct disassemble_info *info)
   memaddr &= (info->mach == bfd_mach_mips16 ? ~1 : ~3);
 
   /* Set the disassembler options.  */
-  if (tdep->mips_abi == MIPS_ABI_N32 || tdep->mips_abi == MIPS_ABI_N64)
-    {
-      /* Set up the disassembler info, so that we get the right
-         register names from libopcodes.  */
-      if (tdep->mips_abi == MIPS_ABI_N32)
-       info->disassembler_options = "gpr-names=n32";
-      else
-       info->disassembler_options = "gpr-names=64";
-      info->flavour = bfd_target_elf_flavour;
-    }
-  else
+  if (!info->disassembler_options)
     /* This string is not recognized explicitly by the disassembler,
        but it tells the disassembler to not try to guess the ABI from
        the bfd elf headers, such that, if the user overrides the ABI
@@ -4885,6 +4958,28 @@ gdb_print_insn_mips (bfd_vma memaddr, struct disassemble_info *info)
     return print_insn_little_mips (memaddr, info);
 }
 
+static int
+gdb_print_insn_mips_n32 (bfd_vma memaddr, struct disassemble_info *info)
+{
+  /* Set up the disassembler info, so that we get the right
+     register names from libopcodes.  */
+  info->disassembler_options = "gpr-names=n32";
+  info->flavour = bfd_target_elf_flavour;
+
+  return gdb_print_insn_mips (memaddr, info);
+}
+
+static int
+gdb_print_insn_mips_n64 (bfd_vma memaddr, struct disassemble_info *info)
+{
+  /* Set up the disassembler info, so that we get the right
+     register names from libopcodes.  */
+  info->disassembler_options = "gpr-names=64";
+  info->flavour = bfd_target_elf_flavour;
+
+  return gdb_print_insn_mips (memaddr, info);
+}
+
 /* This function implements gdbarch_breakpoint_from_pc.  It uses the program
    counter value to determine whether a 16- or 32-bit breakpoint should be used.
    It returns a pointer to a string of bytes that encode a breakpoint
@@ -4971,7 +5066,7 @@ mips_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
    gory details.  */
 
 static CORE_ADDR
-mips_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
+mips_skip_mips16_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 {
   char *name;
   CORE_ADDR start_addr;
@@ -5050,6 +5145,80 @@ mips_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
   return 0;                    /* not a stub */
 }
 
+/* If the current PC is the start of a non-PIC-to-PIC stub, return the
+   PC of the stub target.  The stub just loads $t9 and jumps to it,
+   so that $t9 has the correct value at function entry.  */
+
+static CORE_ADDR
+mips_skip_pic_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
+{
+  struct minimal_symbol *msym;
+  int i;
+  gdb_byte stub_code[16];
+  int32_t stub_words[4];
+
+  /* The stub for foo is named ".pic.foo", and is either two
+     instructions inserted before foo or a three instruction sequence
+     which jumps to foo.  */
+  msym = lookup_minimal_symbol_by_pc (pc);
+  if (msym == NULL
+      || SYMBOL_VALUE_ADDRESS (msym) != pc
+      || SYMBOL_LINKAGE_NAME (msym) == NULL
+      || strncmp (SYMBOL_LINKAGE_NAME (msym), ".pic.", 5) != 0)
+    return 0;
+
+  /* A two-instruction header.  */
+  if (MSYMBOL_SIZE (msym) == 8)
+    return pc + 8;
+
+  /* A three-instruction (plus delay slot) trampoline.  */
+  if (MSYMBOL_SIZE (msym) == 16)
+    {
+      if (target_read_memory (pc, stub_code, 16) != 0)
+       return 0;
+      for (i = 0; i < 4; i++)
+       stub_words[i] = extract_unsigned_integer (stub_code + i * 4, 4);
+
+      /* A stub contains these instructions:
+        lui    t9, %hi(target)
+        j      target
+         addiu t9, t9, %lo(target)
+        nop
+
+        This works even for N64, since stubs are only generated with
+        -msym32.  */
+      if ((stub_words[0] & 0xffff0000U) == 0x3c190000
+         && (stub_words[1] & 0xfc000000U) == 0x08000000
+         && (stub_words[2] & 0xffff0000U) == 0x27390000
+         && stub_words[3] == 0x00000000)
+       return (((stub_words[0] & 0x0000ffff) << 16)
+               + (stub_words[2] & 0x0000ffff));
+    }
+
+  /* Not a recognized stub.  */
+  return 0;
+}
+
+static CORE_ADDR
+mips_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
+{
+  CORE_ADDR target_pc;
+
+  target_pc = mips_skip_mips16_trampoline_code (frame, pc);
+  if (target_pc)
+    return target_pc;
+
+  target_pc = find_solib_trampoline_target (frame, pc);
+  if (target_pc)
+    return target_pc;
+
+  target_pc = mips_skip_pic_trampoline_code (frame, pc);
+  if (target_pc)
+    return target_pc;
+
+  return 0;
+}
+
 /* Convert a dbx stab register number (from `r' declaration) to a GDB
    [1 * gdbarch_num_regs .. 2 * gdbarch_num_regs) REGNUM.  */
 
@@ -5812,7 +5981,12 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_print_registers_info (gdbarch, mips_print_registers_info);
 
-  set_gdbarch_print_insn (gdbarch, gdb_print_insn_mips);
+  if (mips_abi == MIPS_ABI_N32)
+    set_gdbarch_print_insn (gdbarch, gdb_print_insn_mips_n32);
+  else if (mips_abi == MIPS_ABI_N64)
+    set_gdbarch_print_insn (gdbarch, gdb_print_insn_mips_n64);
+  else
+    set_gdbarch_print_insn (gdbarch, gdb_print_insn_mips);
 
   /* FIXME: cagney/2003-08-29: The macros HAVE_STEPPABLE_WATCHPOINT,
      HAVE_NONSTEPPABLE_WATCHPOINT, and HAVE_CONTINUABLE_WATCHPOINT
@@ -5898,7 +6072,7 @@ show_mips_abi (struct ui_file *file,
               struct cmd_list_element *ignored_cmd,
               const char *ignored_value)
 {
-  if (gdbarch_bfd_arch_info (current_gdbarch)->arch != bfd_arch_mips)
+  if (gdbarch_bfd_arch_info (target_gdbarch)->arch != bfd_arch_mips)
     fprintf_filtered
       (file, 
        "The MIPS ABI is unknown because the current architecture "
@@ -5906,7 +6080,7 @@ show_mips_abi (struct ui_file *file,
   else
     {
       enum mips_abi global_abi = global_mips_abi ();
-      enum mips_abi actual_abi = mips_abi (current_gdbarch);
+      enum mips_abi actual_abi = mips_abi (target_gdbarch);
       const char *actual_abi_str = mips_abi_strings[actual_abi];
 
       if (global_abi == MIPS_ABI_UNKNOWN)
@@ -5983,13 +6157,14 @@ mips_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
                       : MIPS_DEFAULT_FPU_TYPE == MIPS_FPU_SINGLE ? "single"
                       : MIPS_DEFAULT_FPU_TYPE == MIPS_FPU_DOUBLE ? "double"
                       : "???"));
-  fprintf_unfiltered (file, "mips_dump_tdep: MIPS_EABI = %d\n", MIPS_EABI);
+  fprintf_unfiltered (file, "mips_dump_tdep: MIPS_EABI = %d\n",
+                     MIPS_EABI (gdbarch));
   fprintf_unfiltered (file,
                      "mips_dump_tdep: MIPS_FPU_TYPE = %d (%s)\n",
-                     MIPS_FPU_TYPE,
-                     (MIPS_FPU_TYPE == MIPS_FPU_NONE ? "none"
-                      : MIPS_FPU_TYPE == MIPS_FPU_SINGLE ? "single"
-                      : MIPS_FPU_TYPE == MIPS_FPU_DOUBLE ? "double"
+                     MIPS_FPU_TYPE (gdbarch),
+                     (MIPS_FPU_TYPE (gdbarch) == MIPS_FPU_NONE ? "none"
+                      : MIPS_FPU_TYPE (gdbarch) == MIPS_FPU_SINGLE ? "single"
+                      : MIPS_FPU_TYPE (gdbarch) == MIPS_FPU_DOUBLE ? "double"
                       : "???"));
 }
 
This page took 0.039147 seconds and 4 git commands to generate.