[RFA] Fix problems with unwinder on mips-irix (take 2)

Joel Brobecker brobecker@gnat.com
Wed Sep 1 20:40:00 GMT 2004


This patch fixes the problem reported in:

        http://sources.redhat.com/ml/gdb-patches/2004-07/msg00319.html

Namely:

        % gdb store
        (gdb) b wack_doublest
        (gdb) run
        (gdb) bt
        #0  wack_doublest (u=Unhandled dwarf expression opcode 0x93
        ) at ./gdb.base/store.c:125
        #1  0x100108d8 in ?? ()
        warning: GDB can't find the start of the function at 0x100108d8.

            GDB is unable to find the start of the function at 0x100108d8
        and thus can't determine the size of that function's stack frame.
        This means that GDB may be unable to access that stack frame, or
        the frames below it.
            This problem is most likely caused by an invalid program counter or
        stack pointer.
            However, if you think GDB should simply search farther back
        from 0x100108d8 for code which looks like the beginning of a
        function, you can increase the range of the search using the `set
        heuristic-fence-post' command.
        Previous frame inner to this frame (corrupt stack?)

2004-09-01  Joel Brobecker  <brobecker@gnat.com>

        * mips-tdep.c (set_saved_reg_info): New function.
        (mips32_heuristic_proc_desc): Use set_saved_reg_info to compute
        PROG_REG_MASK and PROC_REG_OFFSET.

Tested on mips-irix. Fixes about 250 fails.
OK to apply?

-- 
Joel
-------------- next part --------------
--- mips-tdep.c.new_ref	2004-09-01 14:59:04.400090072 -0400
+++ mips-tdep.c	2004-09-01 15:07:12.769297632 -0400
@@ -2804,6 +2804,24 @@ mips16_heuristic_proc_desc (CORE_ADDR st
     }
 }
 
+/* Record in the procedure descriptor INFO the fact that register REGNO
+   was saved at OFFSET bytes from the procedure descriptor frame register.
+   Also updates the offset between the frame base and the area in the stack
+   where the registers are stored.  */
+
+static void
+set_saved_reg_info (struct mips_extra_func_info *info,
+                    int regno, int offset)
+{
+  /* If this is the first register saved, then OFFSET points to
+     the begining of the stack where the registers are saved.
+     We can use this to compute the PROC_REG_OFFSET of this frame.  */
+  if (PROC_REG_MASK (info) == 0)
+    PROC_REG_OFFSET (info) = offset - PROC_FRAME_OFFSET (info);
+
+  PROC_REG_MASK (info) |= 1 << regno;
+}
+
 static void
 mips32_heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
 			    struct frame_info *next_frame, CORE_ADDR sp)
@@ -2842,14 +2860,14 @@ restart:
 	}
       else if ((high_word & 0xFFE0) == 0xafa0)	/* sw reg,offset($sp) */
 	{
-	  PROC_REG_MASK (&temp_proc_desc) |= 1 << reg;
+          set_saved_reg_info (&temp_proc_desc, reg, low_word);
 	  set_reg_offset (temp_saved_regs, 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_saved_reg_info (&temp_proc_desc, reg, low_word);
 	  set_reg_offset (temp_saved_regs, reg, sp + low_word);
 	}
       else if (high_word == 0x27be)	/* addiu $30,$sp,size */
@@ -2899,7 +2917,7 @@ restart:
 	}
       else if ((high_word & 0xFFE0) == 0xafc0)	/* sw reg,offset($30) */
 	{
-	  PROC_REG_MASK (&temp_proc_desc) |= 1 << reg;
+	  set_saved_reg_info (&temp_proc_desc, reg, low_word);
 	  set_reg_offset (temp_saved_regs, reg, frame_addr + low_word);
 	}
     }


More information about the Gdb-patches mailing list