2004-09-14 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / mips-tdep.c
index f6c568a5d3e4d75af58ce8e2a01d3c625423fee8..2b40fddf8f93641a1c4df26c4106dd50c5701589 100644 (file)
 #include "frame-base.h"
 #include "trad-frame.h"
 #include "infcall.h"
+#include "floatformat.h"
 
 static const struct objfile_data *mips_pdr_data;
 
-static void set_reg_offset (CORE_ADDR *saved_regs, int regnum, CORE_ADDR off);
 static struct type *mips_register_type (struct gdbarch *gdbarch, int regnum);
 
 /* A useful bit in the CP0 status register (PS_REGNUM).  */
@@ -149,6 +149,32 @@ struct gdbarch_tdep
   const char **mips_processor_reg_names;
 };
 
+static int
+n32n64_floatformat_always_valid (const struct floatformat *fmt,
+                                 const char *from)
+{
+  return 1;
+}
+
+/* FIXME: brobecker/2004-08-08: Long Double values are 128 bit long.
+   They are implemented as a pair of 64bit doubles where the high
+   part holds the result of the operation rounded to double, and
+   the low double holds the difference between the exact result and
+   the rounded result.  So "high" + "low" contains the result with
+   added precision.  Unfortunately, the floatformat structure used
+   by GDB is not powerful enough to describe this format.  As a temporary
+   measure, we define a 128bit floatformat that only uses the high part.
+   We lose a bit of precision but that's probably the best we can do
+   for now with the current infrastructure.  */
+
+static const struct floatformat floatformat_n32n64_long_double_big =
+{
+  floatformat_big, 128, 0, 1, 11, 1023, 2047, 12, 52,
+  floatformat_intbit_no,
+  "floatformat_ieee_double_big",
+  n32n64_floatformat_always_valid
+};
+
 const struct mips_regnum *
 mips_regnum (struct gdbarch *gdbarch)
 {
@@ -393,8 +419,10 @@ mips_stack_argsize (struct gdbarch *gdbarch)
 
 #define VM_MIN_ADDRESS (CORE_ADDR)0x400000
 
+struct mips_frame_cache;
 static mips_extra_func_info_t heuristic_proc_desc (CORE_ADDR, CORE_ADDR,
-                                                  struct frame_info *, int);
+                                                  struct frame_info *,
+                                                  struct mips_frame_cache *);
 static mips_extra_func_info_t non_heuristic_proc_desc (CORE_ADDR pc,
                                                       CORE_ADDR *addrptr);
 
@@ -404,12 +432,7 @@ static CORE_ADDR read_next_frame_reg (struct frame_info *, int);
 
 static void reinit_frame_cache_sfunc (char *, int, struct cmd_list_element *);
 
-static mips_extra_func_info_t find_proc_desc (CORE_ADDR pc,
-                                             struct frame_info *next_frame,
-                                             int cur_frame);
-
-static CORE_ADDR after_prologue (CORE_ADDR pc,
-                                mips_extra_func_info_t proc_desc);
+static CORE_ADDR after_prologue (CORE_ADDR pc);
 
 static struct type *mips_float_register_type (void);
 static struct type *mips_double_register_type (void);
@@ -631,15 +654,6 @@ static unsigned int heuristic_fence_post = 0;
    this will corrupt pdr.iline.  Fortunately we don't use it.  */
 #define PROC_SYMBOL(proc) (*(struct symbol**)&(proc)->pdr.isym)
 #define _PROC_MAGIC_ 0x0F0F0F0F
-#define PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym == _PROC_MAGIC_)
-#define SET_PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym = _PROC_MAGIC_)
-
-struct linked_proc_info
-{
-  struct mips_extra_func_info info;
-  struct linked_proc_info *next;
-}
- *linked_proc_desc_table = NULL;
 
 /* Number of bytes of storage in the actual machine representation for
    register N.  NOTE: This defines the pseudo register type so need to
@@ -865,18 +879,48 @@ mips_write_pc (CORE_ADDR pc, ptid_t ptid)
    find the prologue, then return 0.  */
 
 static CORE_ADDR
-after_prologue (CORE_ADDR pc, mips_extra_func_info_t proc_desc)
+after_prologue (CORE_ADDR pc)
 {
+  mips_extra_func_info_t proc_desc;
   struct symtab_and_line sal;
   CORE_ADDR func_addr, func_end;
+  CORE_ADDR startaddr = 0;
+
+  /* Pass a NULL next_frame to heuristic_proc_desc.  We should not
+     attempt to read the stack pointer from the current machine state,
+     because the current machine state has nothing to do with the
+     information we need from the proc_desc; and the process may or
+     may not exist right now.  */
+  proc_desc = non_heuristic_proc_desc (pc, &startaddr);
+  if (proc_desc)
+    {
+      /* IF this is the topmost frame AND (this proc does not have
+        debugging information OR the PC is in the procedure prologue)
+        THEN create a "heuristic" proc_desc (by analyzing the actual
+        code) to replace the "official" proc_desc.  */
+      struct symtab_and_line val;
+      if (PROC_SYMBOL (proc_desc))
+       {
+         val = find_pc_line (BLOCK_START
+                             (SYMBOL_BLOCK_VALUE (PROC_SYMBOL (proc_desc))),
+                             0);
+         val.pc = val.end ? val.end : pc;
+       }
+      if (!PROC_SYMBOL (proc_desc) || pc < val.pc)
+       {
+         mips_extra_func_info_t found_heuristic =
+           heuristic_proc_desc (PROC_LOW_ADDR (proc_desc), pc, NULL, NULL);
+         if (found_heuristic)
+           proc_desc = found_heuristic;
+       }
+    }
+  else
+    {
+      if (startaddr == 0)
+       startaddr = heuristic_proc_start (pc);
 
-  /* Pass cur_frame == 0 to find_proc_desc.  We should not attempt
-     to read the stack pointer from the current machine state, because
-     the current machine state has nothing to do with the information
-     we need from the proc_desc; and the process may or may not exist
-     right now.  */
-  if (!proc_desc)
-    proc_desc = find_proc_desc (pc, NULL, 0);
+      proc_desc = heuristic_proc_desc (startaddr, pc, NULL, NULL);
+    }
 
   if (proc_desc)
     {
@@ -1509,6 +1553,7 @@ struct mips_frame_cache
 static struct mips_frame_cache *
 mips_mdebug_frame_cache (struct frame_info *next_frame, void **this_cache)
 {
+  CORE_ADDR startaddr = 0;
   mips_extra_func_info_t proc_desc;
   struct mips_frame_cache *cache;
   struct gdbarch *gdbarch = get_frame_arch (next_frame);
@@ -1525,12 +1570,11 @@ mips_mdebug_frame_cache (struct frame_info *next_frame, void **this_cache)
   cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
 
   /* Get the mdebug proc descriptor.  */
-  proc_desc = find_proc_desc (frame_pc_unwind (next_frame), next_frame, 1);
-  if (proc_desc == NULL)
-    /* I'm not sure how/whether this can happen.  Normally when we
-       can't find a proc_desc, we "synthesize" one using
-       heuristic_proc_desc and set the saved_regs right away.  */
-    return cache;
+  proc_desc = non_heuristic_proc_desc (frame_pc_unwind (next_frame),
+                                      &startaddr);
+  /* Must be true.  This is only called when the sniffer detected a
+     proc descriptor.  */
+  gdb_assert (proc_desc != NULL);
 
   /* Extract the frame's base.  */
   cache->base = (frame_unwind_register_signed (next_frame, NUM_REGS + PROC_FRAME_REG (proc_desc))
@@ -1540,58 +1584,17 @@ mips_mdebug_frame_cache (struct frame_info *next_frame, void **this_cache)
   gen_mask = kernel_trap ? 0xFFFFFFFF : PROC_REG_MASK (proc_desc);
   float_mask = kernel_trap ? 0xFFFFFFFF : PROC_FREG_MASK (proc_desc);
   
-  /* In any frame other than the innermost or a frame interrupted by a
-     signal, we assume that all registers have been saved.  This
-     assumes that all register saves in a function happen before the
-     first function call.  */
-  if (in_prologue (frame_pc_unwind (next_frame), PROC_LOW_ADDR (proc_desc))
-      /* Not sure exactly what kernel_trap means, but if it means the
-        kernel saves the registers without a prologue doing it, we
-        better not examine the prologue to see whether registers
-        have been saved yet.  */
-      && !kernel_trap)
-    {
-      /* We need to figure out whether the registers that the
-         proc_desc claims are saved have been saved yet.  */
-
-      CORE_ADDR addr;
-
-      /* Bitmasks; set if we have found a save for the register.  */
-      unsigned long gen_save_found = 0;
-      unsigned long float_save_found = 0;
-      int mips16;
-
-      /* If the address is odd, assume this is MIPS16 code.  */
-      addr = PROC_LOW_ADDR (proc_desc);
-      mips16 = pc_is_mips16 (addr);
-
-      /* Scan through this function's instructions preceding the
-         current PC, and look for those that save registers.  */
-      while (addr < frame_pc_unwind (next_frame))
-       {
-         if (mips16)
-           {
-             mips16_decode_reg_save (mips16_fetch_instruction (addr),
-                                     &gen_save_found);
-             addr += MIPS16_INSTLEN;
-           }
-         else
-           {
-             mips32_decode_reg_save (mips32_fetch_instruction (addr),
-                                     &gen_save_found, &float_save_found);
-             addr += MIPS_INSTLEN;
-           }
-       }
-      gen_mask = gen_save_found;
-      float_mask = float_save_found;
-    }
+  /* Must be true.  The in_prologue case is left for the heuristic
+     unwinder.  This is always used on kernel traps.  */
+  gdb_assert (!in_prologue (frame_pc_unwind (next_frame), PROC_LOW_ADDR (proc_desc))
+             || kernel_trap);
 
   /* Fill in the offsets for the registers which gen_mask says were
      saved.  */
   {
-    CORE_ADDR reg_position = (cache->base
-                             + PROC_REG_OFFSET (proc_desc));
+    CORE_ADDR reg_position = (cache->base + PROC_REG_OFFSET (proc_desc));
     int ireg;
+
     for (ireg = MIPS_NUMREGS - 1; gen_mask; --ireg, gen_mask <<= 1)
       if (gen_mask & 0x80000000)
        {
@@ -1800,14 +1803,22 @@ mips_insn16_frame_cache (struct frame_info *next_frame, void **this_cache)
   (*this_cache) = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
 
-  /* Get the mdebug proc descriptor.  */
-  proc_desc = find_proc_desc (frame_pc_unwind (next_frame), next_frame, 1);
-  if (proc_desc == NULL)
-    /* I'm not sure how/whether this can happen.  Normally when we
-       can't find a proc_desc, we "synthesize" one using
-       heuristic_proc_desc and set the saved_regs right away.  */
-    return cache;
+  /* Synthesize a proc descriptor.  */
+  {
+    const CORE_ADDR pc = frame_pc_unwind (next_frame);
+    CORE_ADDR start_addr;
+
+    find_pc_partial_function (pc, NULL, &start_addr, NULL);
+    if (start_addr == 0)
+      start_addr = heuristic_proc_start (pc);
 
+#ifdef NOT_YET
+    proc_desc = heuristic_proc_desc (start_addr, pc, next_frame, *this_cache);
+#else
+    proc_desc = heuristic_proc_desc (start_addr, pc, next_frame, NULL);
+#endif
+  }
+  
   /* Extract the frame's base.  */
   cache->base = (frame_unwind_register_signed (next_frame, NUM_REGS + PROC_FRAME_REG (proc_desc))
                 + PROC_FRAME_OFFSET (proc_desc) - PROC_FRAME_ADJUST (proc_desc));
@@ -2053,8 +2064,22 @@ mips_insn32_frame_cache (struct frame_info *next_frame, void **this_cache)
   (*this_cache) = cache;
   cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
 
-  /* Get the mdebug proc descriptor.  */
-  proc_desc = find_proc_desc (frame_pc_unwind (next_frame), next_frame, 1);
+  /* Synthesize a proc descriptor.  */
+  {
+    const CORE_ADDR pc = frame_pc_unwind (next_frame);
+    CORE_ADDR start_addr;
+
+    find_pc_partial_function (pc, NULL, &start_addr, NULL);
+    if (start_addr == 0)
+      start_addr = heuristic_proc_start (pc);
+
+#ifdef NOT_YET
+    proc_desc = heuristic_proc_desc (start_addr, pc, next_frame, *this_cache);
+#else
+    proc_desc = heuristic_proc_desc (start_addr, pc, next_frame, NULL);
+#endif
+  }
+  
   if (proc_desc == NULL)
     /* I'm not sure how/whether this can happen.  Normally when we
        can't find a proc_desc, we "synthesize" one using
@@ -2088,28 +2113,16 @@ mips_insn32_frame_cache (struct frame_info *next_frame, void **this_cache)
       /* Bitmasks; set if we have found a save for the register.  */
       unsigned long gen_save_found = 0;
       unsigned long float_save_found = 0;
-      int mips16;
 
-      /* If the address is odd, assume this is MIPS16 code.  */
       addr = PROC_LOW_ADDR (proc_desc);
-      mips16 = pc_is_mips16 (addr);
 
       /* Scan through this function's instructions preceding the
          current PC, and look for those that save registers.  */
       while (addr < frame_pc_unwind (next_frame))
        {
-         if (mips16)
-           {
-             mips16_decode_reg_save (mips16_fetch_instruction (addr),
-                                     &gen_save_found);
-             addr += MIPS16_INSTLEN;
-           }
-         else
-           {
-             mips32_decode_reg_save (mips32_fetch_instruction (addr),
-                                     &gen_save_found, &float_save_found);
-             addr += MIPS_INSTLEN;
-           }
+          mips32_decode_reg_save (mips32_fetch_instruction (addr),
+                                  &gen_save_found, &float_save_found);
+          addr += MIPS_INSTLEN;
        }
       gen_mask = gen_save_found;
       float_mask = float_save_found;
@@ -2129,48 +2142,20 @@ mips_insn32_frame_cache (struct frame_info *next_frame, void **this_cache)
        }
   }
 
-  /* The MIPS16 entry instruction saves $s0 and $s1 in the reverse
-     order of that normally used by gcc.  Therefore, we have to fetch
-     the first instruction of the function, and if it's an entry
-     instruction that saves $s0 or $s1, correct their saved addresses.  */
-  if (pc_is_mips16 (PROC_LOW_ADDR (proc_desc)))
-    {
-      ULONGEST inst = mips16_fetch_instruction (PROC_LOW_ADDR (proc_desc));
-      if ((inst & 0xf81f) == 0xe809 && (inst & 0x700) != 0x700)
-       /* entry */
-       {
-         int reg;
-         int sreg_count = (inst >> 6) & 3;
-
-         /* Check if the ra register was pushed on the stack.  */
-         CORE_ADDR reg_position = (cache->base
-                                   + PROC_REG_OFFSET (proc_desc));
-         if (inst & 0x20)
-           reg_position -= mips_abi_regsize (gdbarch);
-
-         /* Check if the s0 and s1 registers were pushed on the
-            stack.  */
-         /* NOTE: cagney/2004-02-08: Huh?  This is doing no such
-             check.  */
-         for (reg = 16; reg < sreg_count + 16; reg++)
-           {
-             cache->saved_regs[NUM_REGS + reg].addr = reg_position;
-             reg_position -= mips_abi_regsize (gdbarch);
-           }
-       }
-    }
-
   /* Fill in the offsets for the registers which float_mask says were
      saved.  */
   {
-    CORE_ADDR reg_position = (cache->base
-                             + PROC_FREG_OFFSET (proc_desc));
+    CORE_ADDR reg_position = (cache->base + PROC_FREG_OFFSET (proc_desc));
     int ireg;
+
     /* Fill in the offsets for the float registers which float_mask
        says were saved.  */
     for (ireg = MIPS_NUMREGS - 1; float_mask; --ireg, float_mask <<= 1)
       if (float_mask & 0x80000000)
        {
+          const int regno =
+            NUM_REGS + mips_regnum (current_gdbarch)->fp0 + ireg;
+
          if (mips_abi_regsize (gdbarch) == 4
              && TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
            {
@@ -2197,15 +2182,14 @@ mips_insn32_frame_cache (struct frame_info *next_frame, void **this_cache)
                 reg_position is decremented each time through the
                 loop).  */
              if ((ireg & 1))
-               cache->saved_regs[NUM_REGS + mips_regnum (current_gdbarch)->fp0 + ireg]
-                 .addr = reg_position - mips_abi_regsize (gdbarch);
+               cache->saved_regs[regno].addr =
+                  reg_position - mips_abi_regsize (gdbarch);
              else
-               cache->saved_regs[NUM_REGS + mips_regnum (current_gdbarch)->fp0 + ireg]
-                 .addr = reg_position + mips_abi_regsize (gdbarch);
+               cache->saved_regs[regno].addr =
+                 reg_position + mips_abi_regsize (gdbarch);
            }
          else
-           cache->saved_regs[NUM_REGS + mips_regnum (current_gdbarch)->fp0 + ireg]
-             .addr = reg_position;
+           cache->saved_regs[regno].addr = reg_position;
          reg_position -= mips_abi_regsize (gdbarch);
        }
 
@@ -2456,13 +2440,6 @@ mips_software_single_step (enum target_signal sig, int insert_breakpoints_p)
 
 static struct mips_extra_func_info temp_proc_desc;
 
-/* This hack will go away once the get_prev_frame() code has been
-   modified to set the frame's type first.  That is BEFORE init extra
-   frame info et.al.  is called.  This is because it will become
-   possible to skip the init extra info call for sigtramp and dummy
-   frames.  */
-static CORE_ADDR *temp_saved_regs;
-
 /* Set a register's saved stack address in temp_saved_regs.  If an
    address has already been set for this register, do nothing; this
    way we will only recognize the first save of a given register in a
@@ -2475,12 +2452,14 @@ static CORE_ADDR *temp_saved_regs;
    frame.  */
 
 static void
-set_reg_offset (CORE_ADDR *saved_regs, int regno, CORE_ADDR offset)
+set_reg_offset (struct mips_frame_cache *this_cache, int regnum,
+               CORE_ADDR offset)
 {
-  if (saved_regs[regno] == 0)
+  if (this_cache != NULL
+      && this_cache->saved_regs[regnum].addr == 0)
     {
-      saved_regs[regno + 0 * NUM_REGS] = offset;
-      saved_regs[regno + 1 * NUM_REGS] = offset;
+      this_cache->saved_regs[regnum + 0 * NUM_REGS].addr = offset;
+      this_cache->saved_regs[regnum + 1 * NUM_REGS].addr = offset;
     }
 }
 
@@ -2638,7 +2617,9 @@ mips16_get_imm (unsigned short prev_inst, /* previous instruction */
 
 static void
 mips16_heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
-                           struct frame_info *next_frame, CORE_ADDR sp)
+                           CORE_ADDR sp,
+                           struct frame_info *next_frame,
+                           struct mips_frame_cache *this_cache)
 {
   CORE_ADDR cur_pc;
   CORE_ADDR frame_addr = 0;    /* Value of $r17, used as frame pointer */
@@ -2676,26 +2657,26 @@ mips16_heuristic_proc_desc (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];
          PROC_REG_MASK (&temp_proc_desc) |= (1 << reg);
-         set_reg_offset (temp_saved_regs, reg, sp + offset);
+         set_reg_offset (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];
          PROC_REG_MASK (&temp_proc_desc) |= (1 << reg);
-         set_reg_offset (temp_saved_regs, reg, sp + offset);
+         set_reg_offset (this_cache, reg, sp + offset);
        }
       else if ((inst & 0xff00) == 0x6200)      /* sw $ra,n($sp) */
        {
          offset = mips16_get_imm (prev_inst, inst, 8, 4, 0);
          PROC_REG_MASK (&temp_proc_desc) |= (1 << RA_REGNUM);
-         set_reg_offset (temp_saved_regs, RA_REGNUM, sp + offset);
+         set_reg_offset (this_cache, RA_REGNUM, sp + offset);
        }
       else if ((inst & 0xff00) == 0xfa00)      /* sd $ra,n($sp) */
        {
          offset = mips16_get_imm (prev_inst, inst, 8, 8, 0);
          PROC_REG_MASK (&temp_proc_desc) |= (1 << RA_REGNUM);
-         set_reg_offset (temp_saved_regs, RA_REGNUM, sp + offset);
+         set_reg_offset (this_cache, RA_REGNUM, sp + offset);
        }
       else if (inst == 0x673d) /* move $s1, $sp */
        {
@@ -2714,14 +2695,14 @@ mips16_heuristic_proc_desc (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];
          PROC_REG_MASK (&temp_proc_desc) |= 1 << reg;
-         set_reg_offset (temp_saved_regs, reg, frame_addr + offset);
+         set_reg_offset (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];
          PROC_REG_MASK (&temp_proc_desc) |= 1 << reg;
-         set_reg_offset (temp_saved_regs, reg, frame_addr + offset);
+         set_reg_offset (this_cache, reg, frame_addr + offset);
        }
       else if ((inst & 0xf81f) == 0xe809 && (inst & 0x700) != 0x700)   /* entry */
        entry_inst = inst;      /* save for later processing */
@@ -2751,7 +2732,7 @@ mips16_heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
       for (reg = 4, offset = 0; reg < areg_count + 4; reg++)
        {
          PROC_REG_MASK (&temp_proc_desc) |= 1 << reg;
-         set_reg_offset (temp_saved_regs, reg, sp + offset);
+         set_reg_offset (this_cache, reg, sp + offset);
          offset += mips_abi_regsize (current_gdbarch);
        }
 
@@ -2760,7 +2741,7 @@ mips16_heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
       if (entry_inst & 0x20)
        {
          PROC_REG_MASK (&temp_proc_desc) |= 1 << RA_REGNUM;
-         set_reg_offset (temp_saved_regs, RA_REGNUM, sp + offset);
+         set_reg_offset (this_cache, RA_REGNUM, sp + offset);
          offset -= mips_abi_regsize (current_gdbarch);
        }
 
@@ -2768,7 +2749,7 @@ mips16_heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
       for (reg = 16; reg < sreg_count + 16; reg++)
        {
          PROC_REG_MASK (&temp_proc_desc) |= 1 << reg;
-         set_reg_offset (temp_saved_regs, reg, sp + offset);
+         set_reg_offset (this_cache, reg, sp + offset);
          offset -= mips_abi_regsize (current_gdbarch);
        }
     }
@@ -2776,13 +2757,12 @@ mips16_heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
 
 static void
 mips32_heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
-                           struct frame_info *next_frame, CORE_ADDR sp)
+                           CORE_ADDR sp, struct frame_info *next_frame,
+                           struct mips_frame_cache *this_cache)
 {
   CORE_ADDR cur_pc;
   CORE_ADDR frame_addr = 0;    /* Value of $r30. Used by gcc for frame-pointer */
 restart:
-  temp_saved_regs = xrealloc (temp_saved_regs, SIZEOF_FRAME_SAVED_REGS);
-  memset (temp_saved_regs, '\0', SIZEOF_FRAME_SAVED_REGS);
   PROC_FRAME_OFFSET (&temp_proc_desc) = 0;
   PROC_FRAME_ADJUST (&temp_proc_desc) = 0;     /* offset of FP from SP */
   for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += MIPS_INSTLEN)
@@ -2813,14 +2793,14 @@ restart:
       else if ((high_word & 0xFFE0) == 0xafa0) /* sw reg,offset($sp) */
        {
          PROC_REG_MASK (&temp_proc_desc) |= 1 << reg;
-         set_reg_offset (temp_saved_regs, reg, sp + low_word);
+         set_reg_offset (this_cache, reg, sp + low_word);
        }
       else if ((high_word & 0xFFE0) == 0xffa0) /* sd reg,offset($sp) */
        {
          /* Irix 6.2 N32 ABI uses sd instructions for saving $gp and
             $ra.  */
          PROC_REG_MASK (&temp_proc_desc) |= 1 << reg;
-         set_reg_offset (temp_saved_regs, reg, sp + low_word);
+         set_reg_offset (this_cache, reg, sp + low_word);
        }
       else if (high_word == 0x27be)    /* addiu $30,$sp,size */
        {
@@ -2870,18 +2850,21 @@ restart:
       else if ((high_word & 0xFFE0) == 0xafc0) /* sw reg,offset($30) */
        {
          PROC_REG_MASK (&temp_proc_desc) |= 1 << reg;
-         set_reg_offset (temp_saved_regs, reg, frame_addr + low_word);
+         set_reg_offset (this_cache, reg, frame_addr + low_word);
        }
     }
 }
 
 static mips_extra_func_info_t
 heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
-                    struct frame_info *next_frame, int cur_frame)
+                    struct frame_info *next_frame,
+                    struct mips_frame_cache *this_cache)
 {
   CORE_ADDR sp;
 
-  if (cur_frame)
+  /* Can be called when there's no process, and hence when there's no
+     NEXT_FRAME.  */
+  if (next_frame != NULL)
     sp = read_next_frame_reg (next_frame, NUM_REGS + MIPS_SP_REGNUM);
   else
     sp = 0;
@@ -2889,8 +2872,6 @@ heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
   if (start_pc == 0)
     return NULL;
   memset (&temp_proc_desc, '\0', sizeof (temp_proc_desc));
-  temp_saved_regs = xrealloc (temp_saved_regs, SIZEOF_FRAME_SAVED_REGS);
-  memset (temp_saved_regs, '\0', SIZEOF_FRAME_SAVED_REGS);
   PROC_LOW_ADDR (&temp_proc_desc) = start_pc;
   PROC_FRAME_REG (&temp_proc_desc) = MIPS_SP_REGNUM;
   PROC_PC_REG (&temp_proc_desc) = RA_REGNUM;
@@ -2898,9 +2879,11 @@ heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
   if (start_pc + 200 < limit_pc)
     limit_pc = start_pc + 200;
   if (pc_is_mips16 (start_pc))
-    mips16_heuristic_proc_desc (start_pc, limit_pc, next_frame, sp);
+    mips16_heuristic_proc_desc (start_pc, limit_pc, sp,
+                               next_frame, this_cache);
   else
-    mips32_heuristic_proc_desc (start_pc, limit_pc, next_frame, sp);
+    mips32_heuristic_proc_desc (start_pc, limit_pc, sp,
+                               next_frame, this_cache);
   return &temp_proc_desc;
 }
 
@@ -3118,67 +3101,6 @@ non_heuristic_proc_desc (CORE_ADDR pc, CORE_ADDR *addrptr)
     return NULL;
 }
 
-
-static mips_extra_func_info_t
-find_proc_desc (CORE_ADDR pc, struct frame_info *next_frame, int cur_frame)
-{
-  mips_extra_func_info_t proc_desc;
-  CORE_ADDR startaddr = 0;
-
-  proc_desc = non_heuristic_proc_desc (pc, &startaddr);
-
-  if (proc_desc)
-    {
-      /* IF this is the topmost frame AND
-       * (this proc does not have debugging information OR
-       * the PC is in the procedure prologue)
-       * THEN create a "heuristic" proc_desc (by analyzing
-       * the actual code) to replace the "official" proc_desc.
-       */
-      if (next_frame == NULL)
-       {
-         struct symtab_and_line val;
-         struct symbol *proc_symbol =
-           PROC_DESC_IS_DUMMY (proc_desc) ? 0 : PROC_SYMBOL (proc_desc);
-
-         if (proc_symbol)
-           {
-             val = find_pc_line (BLOCK_START
-                                 (SYMBOL_BLOCK_VALUE (proc_symbol)), 0);
-             val.pc = val.end ? val.end : pc;
-           }
-         if (!proc_symbol || pc < val.pc)
-           {
-             mips_extra_func_info_t found_heuristic =
-               heuristic_proc_desc (PROC_LOW_ADDR (proc_desc),
-                                    pc, next_frame, cur_frame);
-             if (found_heuristic)
-               proc_desc = found_heuristic;
-           }
-       }
-    }
-  else
-    {
-      /* Is linked_proc_desc_table really necessary?  It only seems to be used
-         by procedure call dummys.  However, the procedures being called ought
-         to have their own proc_descs, and even if they don't,
-         heuristic_proc_desc knows how to create them! */
-
-      struct linked_proc_info *link;
-
-      for (link = linked_proc_desc_table; link; link = link->next)
-       if (PROC_LOW_ADDR (&link->info) <= pc
-           && PROC_HIGH_ADDR (&link->info) > pc)
-         return &link->info;
-
-      if (startaddr == 0)
-       startaddr = heuristic_proc_start (pc);
-
-      proc_desc = heuristic_proc_desc (startaddr, pc, next_frame, cur_frame);
-    }
-  return proc_desc;
-}
-
 /* MIPS stack frames are almost impenetrable.  When execution stops,
    we basically have to look at symbol information for the function
    that we stopped in, which tells us *which* register (if any) is
@@ -5461,7 +5383,7 @@ mips_skip_prologue (CORE_ADDR pc)
      If so, then return either PC, or the PC after the prologue, whichever
      is greater.  */
 
-  CORE_ADDR post_prologue_pc = after_prologue (pc, NULL);
+  CORE_ADDR post_prologue_pc = after_prologue (pc);
 
   if (post_prologue_pc != 0)
     return max (pc, post_prologue_pc);
@@ -6323,6 +6245,9 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       set_gdbarch_long_bit (gdbarch, 32);
       set_gdbarch_ptr_bit (gdbarch, 32);
       set_gdbarch_long_long_bit (gdbarch, 64);
+      set_gdbarch_long_double_bit (gdbarch, 128);
+      set_gdbarch_long_double_format (gdbarch,
+                                      &floatformat_n32n64_long_double_big);
       break;
     case MIPS_ABI_N64:
       set_gdbarch_push_dummy_call (gdbarch, mips_n32n64_push_dummy_call);
@@ -6333,6 +6258,9 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       set_gdbarch_long_bit (gdbarch, 64);
       set_gdbarch_ptr_bit (gdbarch, 64);
       set_gdbarch_long_long_bit (gdbarch, 64);
+      set_gdbarch_long_double_bit (gdbarch, 128);
+      set_gdbarch_long_double_format (gdbarch,
+                                      &floatformat_n32n64_long_double_big);
       break;
     default:
       internal_error (__FILE__, __LINE__, "unknown ABI in switch");
@@ -6615,8 +6543,6 @@ mips_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
                      mips_abi_regsize (current_gdbarch));
   fprintf_unfiltered (file,
                      "mips_dump_tdep: PRID_REGNUM = %d\n", PRID_REGNUM);
-  fprintf_unfiltered (file,
-                     "mips_dump_tdep: PROC_DESC_IS_DUMMY = function?\n");
   fprintf_unfiltered (file,
                      "mips_dump_tdep: PROC_FRAME_ADJUST = function?\n");
   fprintf_unfiltered (file,
@@ -6645,8 +6571,6 @@ mips_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                      "mips_dump_tdep: SETUP_ARBITRARY_FRAME # %s\n",
                      XSTRING (SETUP_ARBITRARY_FRAME (NUMARGS, ARGS)));
-  fprintf_unfiltered (file,
-                     "mips_dump_tdep: SET_PROC_DESC_IS_DUMMY = function?\n");
   fprintf_unfiltered (file,
                      "mips_dump_tdep: SKIP_TRAMPOLINE_CODE # %s\n",
                      XSTRING (SKIP_TRAMPOLINE_CODE (PC)));
@@ -6680,9 +6604,6 @@ mips_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
                      "mips_dump_tdep: TARGET_CAN_USE_HARDWARE_WATCHPOINT # %s\n",
                      XSTRING (TARGET_CAN_USE_HARDWARE_WATCHPOINT
                               (TYPE, CNT, OTHERTYPE)));
-  fprintf_unfiltered (file,
-                     "mips_dump_tdep: TARGET_HAS_HARDWARE_WATCHPOINTS # %s\n",
-                     XSTRING (TARGET_HAS_HARDWARE_WATCHPOINTS));
 #ifdef TRACE_CLEAR
   fprintf_unfiltered (file,
                      "mips_dump_tdep: TRACE_CLEAR # %s\n",
@@ -6712,8 +6633,6 @@ mips_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
                      (long) VM_MIN_ADDRESS);
   fprintf_unfiltered (file,
                      "mips_dump_tdep: ZERO_REGNUM = %d\n", ZERO_REGNUM);
-  fprintf_unfiltered (file,
-                     "mips_dump_tdep: _PROC_MAGIC_ = %d\n", _PROC_MAGIC_);
 }
 
 extern initialize_file_ftype _initialize_mips_tdep;    /* -Wmissing-prototypes */
This page took 0.032325 seconds and 4 git commands to generate.