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:d10v] Tweak prolog analyzer


Hello,

This patch tweaks the d10v prologue analyzer so that it can spot the sequence:

	sp--
	move sp to fp
	store rN at [fp]

and hence identify the address at which rN was saved. It has no effect on the quality of the d10v's test results.

Andrew
2003-03-05  Andrew Cagney  <cagney at redhat dot com>

	* d10v-tdep.c (struct frame_extra_info): Delete unused structure.
	(struct d10v_unwind_cache): Delete field "frameless".  Replace
	"next_addr" with "sp_offset".  Add "r11_offset".
	(d10v_frame_unwind_cache): Update.
	(prologue_find_regs): Update.  When "mv r11, sp", save the
	"sp_offset" in "r11_offset".  Recognize "st rn, @r11", note that
	RN was saved in r11_offset.

Index: d10v-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/d10v-tdep.c,v
retrieving revision 1.80
diff -u -r1.80 d10v-tdep.c
--- d10v-tdep.c	3 Mar 2003 20:50:17 -0000	1.80
+++ d10v-tdep.c	5 Mar 2003 20:56:19 -0000
@@ -45,13 +45,6 @@
 
 #include "gdb_assert.h"
 
-struct frame_extra_info
-  {
-    CORE_ADDR return_pc;
-    int frameless;
-    int size;
-  };
-
 struct gdbarch_tdep
   {
     int a0_regnum;
@@ -617,10 +610,13 @@
 struct d10v_unwind_cache
 {
   CORE_ADDR return_pc;
-  int frameless;
   int size;
   CORE_ADDR *saved_regs;
-  CORE_ADDR next_addr;
+  /* How far the SP and r11 (FP) have been offset from the start of
+     the stack frame (as defined by the previous frame's stack
+     pointer).  */
+  LONGEST sp_offset;
+  LONGEST r11_offset;
   int uses_frame;
   void **regs;
 };
@@ -635,8 +631,8 @@
   if ((op & 0x7E1F) == 0x6C1F)
     {
       n = (op & 0x1E0) >> 5;
-      info->next_addr -= 2;
-      info->saved_regs[n] = info->next_addr;
+      info->sp_offset -= 2;
+      info->saved_regs[n] = info->sp_offset;
       return 1;
     }
 
@@ -644,9 +640,9 @@
   else if ((op & 0x7E3F) == 0x6E1F)
     {
       n = (op & 0x1E0) >> 5;
-      info->next_addr -= 4;
-      info->saved_regs[n] = info->next_addr;
-      info->saved_regs[n + 1] = info->next_addr + 2;
+      info->sp_offset -= 4;
+      info->saved_regs[n] = info->sp_offset;
+      info->saved_regs[n + 1] = info->sp_offset + 2;
       return 1;
     }
 
@@ -656,7 +652,7 @@
       n = (op & 0x1E) >> 1;
       if (n == 0)
 	n = 16;
-      info->next_addr -= n;
+      info->sp_offset -= n;
       return 1;
     }
 
@@ -664,6 +660,15 @@
   if (op == 0x417E)
     {
       info->uses_frame = 1;
+      info->r11_offset = info->sp_offset;
+      return 1;
+    }
+
+  /* st  rn, @r11 */
+  if ((op & 0x7E1F) == 0x6816)
+    {
+      n = (op & 0x1E0) >> 5;
+      info->saved_regs[n] = info->r11_offset;
       return 1;
     }
 
@@ -675,7 +680,7 @@
   if ((op & 0x7E1F) == 0x681E)
     {
       n = (op & 0x1E0) >> 5;
-      info->saved_regs[n] = info->next_addr;
+      info->saved_regs[n] = info->sp_offset;
       return 1;
     }
 
@@ -683,8 +688,8 @@
   if ((op & 0x7E3F) == 0x3A1E)
     {
       n = (op & 0x1E0) >> 5;
-      info->saved_regs[n] = info->next_addr;
-      info->saved_regs[n + 1] = info->next_addr + 2;
+      info->saved_regs[n] = info->sp_offset;
+      info->saved_regs[n + 1] = info->sp_offset + 2;
       return 1;
     }
 
@@ -714,12 +719,11 @@
   (*cache) = info;
   info->saved_regs = frame_obstack_zalloc (SIZEOF_FRAME_SAVED_REGS);
 
-  info->frameless = 0;
   info->size = 0;
   info->return_pc = 0;
 
   fp = get_frame_base (fi);
-  info->next_addr = 0;
+  info->sp_offset = 0;
 
   pc = get_pc_function_start (get_frame_pc (fi));
 
@@ -734,22 +738,22 @@
 	    {
 	      /* add3 sp,sp,n */
 	      short n = op & 0xFFFF;
-	      info->next_addr += n;
+	      info->sp_offset += n;
 	    }
 	  else if ((op & 0x3F0F0000) == 0x340F0000)
 	    {
 	      /* st  rn, @(offset,sp) */
 	      short offset = op & 0xFFFF;
 	      short n = (op >> 20) & 0xF;
-	      info->saved_regs[n] = info->next_addr + offset;
+	      info->saved_regs[n] = info->sp_offset + offset;
 	    }
 	  else if ((op & 0x3F1F0000) == 0x350F0000)
 	    {
 	      /* st2w  rn, @(offset,sp) */
 	      short offset = op & 0xFFFF;
 	      short n = (op >> 20) & 0xF;
-	      info->saved_regs[n] = info->next_addr + offset;
-	      info->saved_regs[n + 1] = info->next_addr + offset + 2;
+	      info->saved_regs[n] = info->sp_offset + offset;
+	      info->saved_regs[n + 1] = info->sp_offset + offset + 2;
 	    }
 	  else
 	    break;
@@ -774,7 +778,7 @@
       pc += 4;
     }
 
-  info->size = -info->next_addr;
+  info->size = -info->sp_offset;
 
   if (!(fp & 0xffff))
     fp = d10v_read_sp ();
@@ -782,7 +786,7 @@
   for (i = 0; i < NUM_REGS - 1; i++)
     if (info->saved_regs[i])
       {
-	info->saved_regs[i] = fp - (info->next_addr - info->saved_regs[i]);
+	info->saved_regs[i] = fp - (info->sp_offset - info->saved_regs[i]);
       }
 
   if (info->saved_regs[LR_REGNUM])
@@ -810,7 +814,6 @@
       else
 	{
 	  info->saved_regs[SP_REGNUM] = fp + info->size;
-	  info->frameless = 1;
 	  info->saved_regs[FP_REGNUM] = 0;
 	}
     }

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