This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] Give the d10v a constant frame ID . base


Hello,

The attached modifies the d10v so that it returns a frame ID .base pointing at the outer-most address of each frame. Doing that ensures that it is constant through out the frame, including the prologue.

committed,
Andrew
2003-04-01  Andrew Cagney  <cagney at redhat dot com>

	* Makefile.in (d10v-tdep.o): Update dependencies.
	* d10v-tdep.c: Include "frame-base.h".
	(d10v_frame_unwind): Make constant.
	(d10v_frame_base_address): New function.
	(d10v_frame_base): New variable.
	(d10v_gdbarch_init): Set frame_base default.
	(struct d10v_unwind_cache): Add the field "prev_sp".  Update
	comment for base.
	(d10v_frame_unwind_cache): Set and use "prev_sp".
	(d10v_frame_this_id): Use the previous frame's inner most stack
	address and this frame's func address for the frame ID.  Use
	frame_id_build.  Don't analyze beyond the current instruction.
	
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.355
diff -u -r1.355 Makefile.in
--- Makefile.in	1 Apr 2003 19:11:00 -0000	1.355
+++ Makefile.in	1 Apr 2003 19:50:49 -0000
@@ -1622,10 +1622,12 @@
 	$(gdbtypes_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(value_h) \
 	$(opcode_cris_h) $(arch_utils_h) $(regcache_h) $(symfile_h) \
 	$(solib_h) $(solib_svr4_h) $(gdb_string_h)
-d10v-tdep.o: d10v-tdep.c $(defs_h) $(frame_h) $(frame_unwind_h) $(symtab_h) $(gdbtypes_h) \
-	$(gdbcmd_h) $(gdbcore_h) $(gdb_string_h) $(value_h) $(inferior_h) $(dis_asm_h) \
-	$(symfile_h) $(objfiles_h) $(language_h) $(arch_utils_h) $(regcache_h) \
-	$(remote_h) $(floatformat_h) $(gdb_sim_d10v_h) $(sim_regno_h) $(gdb_assert_h)
+d10v-tdep.o: d10v-tdep.c $(defs_h) $(frame_h) $(frame_unwind_h) \
+	$(frame_base_h) $(symtab_h) $(gdbtypes_h) $(gdbcmd_h) $(gdbcore_h) \
+	$(gdb_string_h) $(value_h) $(inferior_h) $(dis_asm_h) $(symfile_h) \
+	$(objfiles_h) $(language_h) $(arch_utils_h) $(regcache_h) \
+	$(remote_h) $(floatformat_h) $(gdb_sim_d10v_h) $(sim_regno_h) \
+	$(gdb_assert_h)
 dbug-rom.o: dbug-rom.c $(defs_h) $(gdbcore_h) $(target_h) $(monitor_h) \
 	$(serial_h) $(regcache_h) $(m68k_tdep_h)
 dbxread.o: dbxread.c $(defs_h) $(gdb_string_h) $(gdb_obstack_h) \
Index: d10v-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/d10v-tdep.c,v
retrieving revision 1.100
diff -u -r1.100 d10v-tdep.c
--- d10v-tdep.c	1 Apr 2003 17:17:27 -0000	1.100
+++ d10v-tdep.c	1 Apr 2003 19:50:51 -0000
@@ -25,6 +25,7 @@
 #include "defs.h"
 #include "frame.h"
 #include "frame-unwind.h"
+#include "frame-base.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "gdbcmd.h"
@@ -598,7 +599,10 @@
 struct d10v_unwind_cache
 {
   CORE_ADDR return_pc;
-  /* The frame's base.  Used when constructing a frame ID.  */
+  /* The previous frame's inner most stack address.  Used as this
+     frame ID's stack_addr.  */
+  CORE_ADDR prev_sp;
+  /* The frame's base, optionally used by the high-level debug info.  */
   CORE_ADDR base;
   int size;
   CORE_ADDR *saved_regs;
@@ -715,10 +719,10 @@
   info->return_pc = 0;
   info->sp_offset = 0;
 
-  pc = get_pc_function_start (frame_pc_unwind (next_frame));
-
   info->uses_frame = 0;
-  while (1)
+  for (pc = get_pc_function_start (frame_pc_unwind (next_frame));
+       pc < frame_pc_unwind (next_frame);
+       pc += 4)
     {
       op = (unsigned long) read_memory_integer (pc, 4);
       if ((op & 0xC0000000) == 0xC0000000)
@@ -765,7 +769,6 @@
 	      || !prologue_find_regs (info, op2, pc))
 	    break;
 	}
-      pc += 4;
     }
 
   info->size = -info->sp_offset;
@@ -799,14 +802,14 @@
     }
 
   info->base = d10v_make_daddr (this_base);
-  prev_sp = d10v_make_daddr (prev_sp);
+  info->prev_sp = d10v_make_daddr (prev_sp);
 
   /* Adjust all the saved registers so that they contain addresses and
      not offsets.  */
   for (i = 0; i < NUM_REGS - 1; i++)
     if (info->saved_regs[i])
       {
-	info->saved_regs[i] = (prev_sp + info->saved_regs[i]);
+	info->saved_regs[i] = (info->prev_sp + info->saved_regs[i]);
       }
 
   if (info->saved_regs[LR_REGNUM])
@@ -825,7 +828,7 @@
 
   /* The SP_REGNUM is special.  Instead of the address of the SP, the
      previous frame's SP value is saved.  */
-  info->saved_regs[SP_REGNUM] = prev_sp;
+  info->saved_regs[SP_REGNUM] = info->prev_sp;
 
   return info;
 }
@@ -1450,9 +1453,6 @@
   CORE_ADDR base;
   CORE_ADDR pc;
 
-  /* Start with a NULL frame ID.  */
-  (*this_id) = null_frame_id;
-
   /* The PC is easy.  */
   pc = frame_pc_unwind (next_frame);
 
@@ -1464,7 +1464,7 @@
   /* Hopefully the prologue analysis either correctly determined the
      frame's base (which is the SP from the previous frame), or set
      that base to "NULL".  */
-  base = info->base;
+  base = info->prev_sp;
   if (base == STACK_START || base == 0)
     return;
 
@@ -1478,8 +1478,7 @@
       && get_frame_id (next_frame).base == base)
     return;
 
-  this_id->base = base;
-  this_id->pc = pc;
+  (*this_id) = frame_id_build (base, pc);
 }
 
 static void
@@ -1553,8 +1552,7 @@
     }
 }
 
-
-static struct frame_unwind d10v_frame_unwind = {
+static const struct frame_unwind d10v_frame_unwind = {
   d10v_frame_this_id,
   d10v_frame_prev_register
 };
@@ -1565,6 +1563,21 @@
   return &d10v_frame_unwind;
 }
 
+static CORE_ADDR
+d10v_frame_base_address (struct frame_info *next_frame, void **this_cache)
+{
+  struct d10v_unwind_cache *info
+    = d10v_frame_unwind_cache (next_frame, this_cache);
+  return info->base;
+}
+
+static const struct frame_base d10v_frame_base = {
+  &d10v_frame_unwind,
+  d10v_frame_base_address,
+  d10v_frame_base_address,
+  d10v_frame_base_address
+};
+
 /* Assuming NEXT_FRAME->prev is a dummy, return the frame ID of that
    dummy frame.  The frame ID's base needs to match the TOS value
    saved by save_dummy_frame_tos(), and the PC match the dummy frame's
@@ -1698,6 +1711,7 @@
   set_gdbarch_print_registers_info (gdbarch, d10v_print_registers_info);
 
   frame_unwind_append_predicate (gdbarch, d10v_frame_p);
+  frame_base_set_default (gdbarch, &d10v_frame_base);
 
   /* Methods for saving / extracting a dummy frame's ID.  */
   set_gdbarch_unwind_dummy_id (gdbarch, d10v_unwind_dummy_id);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]