Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] find_saved_register(): Terminate loop when saved reg found
@ 2002-08-05 14:52 Kevin Buettner
  2002-08-05 21:04 ` Andrew Cagney
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2002-08-05 14:52 UTC (permalink / raw)
  To: gdb-patches

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;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] find_saved_register(): Terminate loop when saved reg found
  2002-08-05 14:52 [RFA] find_saved_register(): Terminate loop when saved reg found Kevin Buettner
@ 2002-08-05 21:04 ` Andrew Cagney
  2002-08-06 15:44   ` Kevin Buettner
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2002-08-05 21:04 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches

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

Ok.

I should point out though, that the function is about to be deprecated 
(if not simply deleted).  As best I can tell, Alpha, ns32k and VAX don't 
need it (their custom get_saved_register() functions appear to be 
verbatum copies of the original get_saved_register()).  That just leaves 
the MIPS, which should call frame_register_unwind() directly.

enjoy,
Andrew



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] find_saved_register(): Terminate loop when saved reg found
  2002-08-05 21:04 ` Andrew Cagney
@ 2002-08-06 15:44   ` Kevin Buettner
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Buettner @ 2002-08-06 15:44 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

On Aug 6, 12:04am, Andrew Cagney wrote:

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

Committed.

> I should point out though, that the function is about to be deprecated 
> (if not simply deleted).  As best I can tell, Alpha, ns32k and VAX don't 
> need it (their custom get_saved_register() functions appear to be 
> verbatum copies of the original get_saved_register()).  That just leaves 
> the MIPS, which should call frame_register_unwind() directly.

I'll take a look...

Kevin


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-08-06 22:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-05 14:52 [RFA] find_saved_register(): Terminate loop when saved reg found Kevin Buettner
2002-08-05 21:04 ` Andrew Cagney
2002-08-06 15:44   ` Kevin Buettner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox