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]

[RFA] find_saved_register(): Terminate loop when saved reg found


As currently written, find_saved_register() scans from the callee (if
any) of FRAME through to the innermost frame looking for the location
at which a particular register was saved.  The problem with the loop
as currently written is that it doesn't terminate until the the very
last (innermost) frame is reached.  This is wrong.  It should
terminate as soon as the address of the saved register is found.

Prior to April of this year, the loop in question worked quite
differently.  It would start at the innermost frame (which is the most
recently pushed frame as viewed execution-wise from the inferior) and
consider each caller in succession until the frame under consideration
was reached.

In April, 2002, the termination condition mentioned above was removed
and the direction of frame traversal was reversed.  I.e, instead of
following the "caller" link, the loop now instead follows the "callee"
link.  I suspect that the addition of the appropriate termination
condition for this new arrangement was merely an oversight.

(This change fixes quite a few testsuite failures for the mips target
that I'm working on.)

Okay to commit?

	* frame.c (find_saved_register): Break out of loop once saved
	register address is found.  Don't mention sparc in loop comment
	anymore.

Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.13
diff -u -p -r1.13 frame.c
--- frame.c	10 Jun 2002 23:25:50 -0000	1.13
+++ frame.c	5 Aug 2002 20:54:46 -0000
@@ -94,10 +94,9 @@ find_saved_register (struct frame_info *
   if (frame == NULL)		/* No regs saved if want current frame */
     return 0;
 
-  /* Note that this next routine assumes that registers used in
-     frame x will be saved only in the frame that x calls and
-     frames interior to it.  This is not true on the sparc, but the
-     above macro takes care of it, so we should be all right. */
+  /* Note that the following loop assumes that registers used in
+     frame x will be saved only in the frame that x calls and frames
+     interior to it.  */
   while (1)
     {
       QUIT;
@@ -107,7 +106,10 @@ find_saved_register (struct frame_info *
       frame = frame1;
       FRAME_INIT_SAVED_REGS (frame1);
       if (frame1->saved_regs[regnum])
-	addr = frame1->saved_regs[regnum];
+	{
+	  addr = frame1->saved_regs[regnum];
+	  break;
+	}
     }
 
   return addr;


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