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]

Re: [patch] Fix unwind handling for hppa


> Beats me.  I guess that might work.  At that point you're more or less
> running the prologue analyzer despite having unwind data; I'm not sure
> how I feel about that.  But it does seem pragmatically useful.

yeah, actually it can be optimized a bit. hppa_frame_cache already is
doing some prologue parsing, so there's no point in doing it again....

something like this seems to work just as well.

randolph


2004-04-17  Randolph Chung  <tausq@debian.org>

	* hppa-tdep.c (hppa_frame_cache): Handle the case when frame unwind
	starts at a pc before the frame is created.

Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.147
diff -u -p -r1.147 hppa-tdep.c
--- hppa-tdep.c	17 Apr 2004 17:41:10 -0000	1.147
+++ hppa-tdep.c	17 Apr 2004 18:08:34 -0000
@@ -2039,5 +2039,6 @@ hppa_frame_cache (struct frame_info *nex
   CORE_ADDR this_sp;
   long frame_size;
   struct unwind_table_entry *u;
+  CORE_ADDR end_pc;
   int i;
 
@@ -2085,7 +2086,6 @@ hppa_frame_cache (struct frame_info *nex
   {
     int final_iteration = 0;
     CORE_ADDR pc;
-    CORE_ADDR end_pc;
     int looking_for_sp = u->Save_SP;
     int looking_for_rp = u->Save_RP;
     int fp_loc = -1;
@@ -2207,6 +2207,7 @@ hppa_frame_cache (struct frame_info *nex
 	if (is_branch (inst))
 	  final_iteration = 1;
       }
+    end_pc = pc;
   }
 
   {
@@ -2214,17 +2215,28 @@ hppa_frame_cache (struct frame_info *nex
        the current function (and is thus equivalent to the "saved"
        stack pointer.  */
     CORE_ADDR this_sp = frame_unwind_register_unsigned (next_frame, HPPA_SP_REGNUM);
-    /* FIXME: cagney/2004-02-22: This assumes that the frame has been
-       created.  If it hasn't everything will be out-of-wack.  */
-    if (u->Save_SP && trad_frame_addr_p (cache->saved_regs, HPPA_SP_REGNUM))
-      /* Both we're expecting the SP to be saved and the SP has been
-	 saved.  The entry SP value is saved at this frame's SP
-	 address.  */
-      cache->base = read_memory_integer (this_sp, TARGET_PTR_BIT / 8);
+    if (frame_pc_unwind (next_frame) >= end_pc)
+      {
+        if (u->Save_SP && trad_frame_addr_p (cache->saved_regs, HPPA_SP_REGNUM))
+          {
+          /* Both we're expecting the SP to be saved and the SP has been
+	     saved.  The entry SP value is saved at this frame's SP
+	     address.  */
+          cache->base = read_memory_integer (this_sp, TARGET_PTR_BIT / 8);
+          }
+        else
+          {
+            /* The prologue has been slowly allocating stack space.  Adjust
+	     the SP back.  */
+            cache->base = this_sp - frame_size;
+          }
+      }
     else
-      /* The prologue has been slowly allocating stack space.  Adjust
-	 the SP back.  */
-      cache->base = this_sp - frame_size;
+      {
+	/* This frame has not yet been created. */
+        cache->base = this_sp;
+      }
+
     trad_frame_set_value (cache->saved_regs, HPPA_SP_REGNUM, cache->base);
   }
 


-- 
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/


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