This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch] Only frame chain once ...
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 09 Nov 2002 13:05:56 -0500
- Subject: [patch] Only frame chain once ...
Hello,
This patch adds a slightly more sane `have we been here before' test to
get_prev_frame(). Given the outer-most / oldest / top frame, the old
code would always try to chain it (doh!).
I'll commit it once all my tests have come in,
Andrew
2002-11-09 Andrew Cagney <ac131313@redhat.com>
* frame.c (get_prev_frame): Test prev_p to identify a previously
unwound frame. Initialize prev_p.
* frame.h (struct frame_info): Add field prev_p. Expand prev/next
comment.
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.24
diff -u -r1.24 frame.c
--- frame.c 9 Nov 2002 17:45:17 -0000 1.24
+++ frame.c 9 Nov 2002 18:00:00 -0000
@@ -742,13 +742,10 @@
return current_frame;
}
- /* If we have the prev one, return it. */
- if (next_frame->prev)
- /* FIXME: cagney/2002-11-09: Rather than relying on ->PREV being
- non-NULL, there should be a predicate (->prev_p?). That would
- stop this function constantly trying to chain beyond the
- outermost frame. */
+ /* Only try to do the unwind once. */
+ if (next_frame->prev_p)
return next_frame->prev;
+ next_frame->prev_p = 1;
/* On some machines it is possible to call a function without
setting up a stack frame for it. On these machines, we
Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.29
diff -u -r1.29 frame.h
--- frame.h 5 Nov 2002 21:44:05 -0000 1.29
+++ frame.h 9 Nov 2002 18:00:00 -0000
@@ -140,10 +140,11 @@
frame_register_unwind_ftype *register_unwind;
void *register_unwind_cache;
- /* Pointers to the next (down, inner) and previous (up, outer)
- frame_info's in the frame cache. */
- struct frame_info *next; /* down, inner */
- struct frame_info *prev; /* up, outer */
+ /* Pointers to the next (down, inner, younger) and previous (up,
+ outer, older) frame_info's in the frame cache. */
+ struct frame_info *next; /* down, inner, younger */
+ int prev_p;
+ struct frame_info *prev; /* up, outer, older */
};
/* Values for the source flag to be used in print_frame_info_base(). */