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]

[PATCH] Improve i386 prologue analyzer


Picking some low-hanging fruit :-).  This probably fixes PR
backtrace/1338.  I'll be checking this in on the branch if Michael
confirms that this fixes the bug.  I'll add a testcase shortly.

Mark

Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* i386-tdep.c (i386_analyze_register_saves): Handle register saves
	at the start of a frameless function.  This probably fixes PR
	backtrace/1338.

Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.165
diff -u -p -r1.165 i386-tdep.c
--- i386-tdep.c 12 Aug 2003 16:12:33 -0000 1.165
+++ i386-tdep.c 17 Aug 2003 23:11:19 -0000
@@ -571,23 +571,22 @@ static CORE_ADDR
 i386_analyze_register_saves (CORE_ADDR pc, CORE_ADDR current_pc,
 			     struct i386_frame_cache *cache)
 {
-  if (cache->locals >= 0)
-    {
-      CORE_ADDR offset;
-      unsigned char op;
-      int i;
+  CORE_ADDR offset = 0;
+  unsigned char op;
+  int i;
 
-      offset = - 4 - cache->locals;
-      for (i = 0; i < 8 && pc < current_pc; i++)
-	{
-	  op = read_memory_unsigned_integer (pc, 1);
-	  if (op < 0x50 || op > 0x57)
-	    break;
+  if (cache->locals > 0)
+    offset -= cache->locals;
+  for (i = 0; i < 8 && pc < current_pc; i++)
+    {
+      op = read_memory_unsigned_integer (pc, 1);
+      if (op < 0x50 || op > 0x57)
+	break;
 
-	  cache->saved_regs[op - 0x50] = offset;
-	  offset -= 4;
-	  pc++;
-	}
+      offset -= 4;
+      cache->saved_regs[op - 0x50] = offset;
+      cache->sp_offset += 4;
+      pc++;
     }
 
   return pc;


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