* frame-unwind.h: Update copyright.
(struct frame_data): Add opaque declaration.
(frame_sniffer_ftype): Declare.
(struct frame_unwind): Add "unwind_data" and "sniffer".
(frame_unwind_register_unwinder): Declare.
(frame_unwind_find_by_frame): Add parameter "this_cache".
* frame.c (get_frame_id, create_new_frame, legacy_get_prev_frame)
(legacy_get_prev_frame, legacy_get_prev_frame)
(get_frame_type): Pass the prologue_cache to
frame_unwind_find_by_frame.
* frame-unwind.c (struct frame_unwind_table_entry): Add field
"unwinder".
(frame_unwind_register_unwinder): New function.
(frame_unwind_find_by_frame): Handle an unwind sniffer.
+2004-03-21 Andrew Cagney <cagney@redhat.com>
+
+ * frame-unwind.h: Update copyright.
+ (struct frame_data): Add opaque declaration.
+ (frame_sniffer_ftype): Declare.
+ (struct frame_unwind): Add "unwind_data" and "sniffer".
+ (frame_unwind_register_unwinder): Declare.
+ (frame_unwind_find_by_frame): Add parameter "this_cache".
+ * frame.c (get_frame_id, create_new_frame, legacy_get_prev_frame)
+ (legacy_get_prev_frame, legacy_get_prev_frame)
+ (get_frame_type): Pass the prologue_cache to
+ frame_unwind_find_by_frame.
+ * frame-unwind.c (struct frame_unwind_table_entry): Add field
+ "unwinder".
+ (frame_unwind_register_unwinder): New function.
+ (frame_unwind_find_by_frame): Handle an unwind sniffer.
+
2004-03-20 Paul Hilfinger <hilfingr@nile.gnat.com>
* bcache.c (print_percentage): Use floating point to avoid
struct frame_unwind_table_entry
{
frame_unwind_sniffer_ftype *sniffer;
+ const struct frame_unwind *unwinder;
struct frame_unwind_table_entry *next;
};
table->tail = &((*table->tail)->next);
}
+void
+frame_unwind_register_unwinder (struct gdbarch *gdbarch,
+ const struct frame_unwind *unwinder)
+{
+ struct frame_unwind_table *table = gdbarch_data (gdbarch, frame_unwind_data);
+ (*table->tail) = GDBARCH_OBSTACK_ZALLOC (gdbarch,
+ struct frame_unwind_table_entry);
+ (*table->tail)->unwinder = unwinder;
+ table->tail = &((*table->tail)->next);
+}
+
const struct frame_unwind *
-frame_unwind_find_by_frame (struct frame_info *next_frame)
+frame_unwind_find_by_frame (struct frame_info *next_frame, void **this_cache)
{
int i;
struct gdbarch *gdbarch = get_frame_arch (next_frame);
return legacy_saved_regs_unwind;
for (entry = table->head; entry != NULL; entry = entry->next)
{
- const struct frame_unwind *desc;
- desc = entry->sniffer (next_frame);
- if (desc != NULL)
- return desc;
+ if (entry->sniffer != NULL)
+ {
+ const struct frame_unwind *desc = NULL;
+ desc = entry->sniffer (next_frame);
+ if (desc != NULL)
+ return desc;
+ }
+ if (entry->unwinder != NULL)
+ {
+ if (entry->unwinder->sniffer (entry->unwinder, next_frame,
+ this_cache))
+ return entry->unwinder;
+ }
}
return legacy_saved_regs_unwind;
}
/* Definitions for a frame unwinder, for GDB, the GNU debugger.
- Copyright 2003 Free Software Foundation, Inc.
+ Copyright 2003, 2004 Free Software Foundation, Inc.
This file is part of GDB.
#if !defined (FRAME_UNWIND_H)
#define FRAME_UNWIND_H 1
+struct frame_data;
struct frame_info;
struct frame_id;
struct frame_unwind;
as where this frame's prologue stores the previous frame's
registers. */
+/* Given the NEXT frame, take a wiff of THIS frame's registers (namely
+ the PC and attributes) and if SELF is the applicable unwinder,
+ return non-zero. Possibly also initialize THIS_PROLOGUE_CACHE. */
+
+typedef int (frame_sniffer_ftype) (const struct frame_unwind *self,
+ struct frame_info *next_frame,
+ void **this_prologue_cache);
+
/* Assuming the frame chain: (outer) prev <-> this <-> next (inner);
use the NEXT frame, and its register unwind method, to determine
the frame ID of THIS frame.
here? */
frame_this_id_ftype *this_id;
frame_prev_register_ftype *prev_register;
+ const struct frame_data *unwind_data;
+ frame_sniffer_ftype *sniffer;
};
+/* Register a frame unwinder, _appending_ it to the end of the search
+ list. */
+extern void frame_unwind_register_unwinder (struct gdbarch *gdbarch,
+ const struct frame_unwind *unwinder);
+
+
/* Given the NEXT frame, take a wiff of THIS frame's registers (namely
the PC and attributes) and if it is the applicable unwinder return
the unwind methods, or NULL if it is not. */
frame_unwind_sniffer_ftype *sniffer);
/* Iterate through the next frame's sniffers until one returns with an
- unwinder implementation. */
+ unwinder implementation. Possibly initialize THIS_CACHE. */
-extern const struct frame_unwind *frame_unwind_find_by_frame (struct frame_info *next_frame);
+extern const struct frame_unwind *frame_unwind_find_by_frame (struct frame_info *next_frame,
+ void **this_cache);
#endif
/* Find the unwinder. */
if (fi->unwind == NULL)
{
- fi->unwind = frame_unwind_find_by_frame (fi->next);
+ fi->unwind = frame_unwind_find_by_frame (fi->next,
+ &fi->prologue_cache);
/* FIXME: cagney/2003-04-02: Rather than storing the frame's
type in the frame, the unwinder's type should be returned
directly. Unfortunately, legacy code, called by
/* Find the unwinder. */
if (frame->unwind == NULL)
{
- frame->unwind = frame_unwind_find_by_frame (frame->next);
+ frame->unwind = frame_unwind_find_by_frame (frame->next,
+ &frame->prologue_cache);
/* FIXME: cagney/2003-04-02: Rather than storing the frame's
type in the frame, the unwinder's type should be returned
directly. Unfortunately, legacy code, called by
/* Select/initialize both the unwind function and the frame's type
based on the PC. */
- fi->unwind = frame_unwind_find_by_frame (fi->next);
+ fi->unwind = frame_unwind_find_by_frame (fi->next, &fi->prologue_cache);
if (fi->unwind->type != UNKNOWN_FRAME)
fi->type = fi->unwind->type;
else
/* Set the unwind functions based on that identified PC. Ditto
for the "type" but strongly prefer the unwinder's frame type. */
- prev->unwind = frame_unwind_find_by_frame (prev->next);
+ prev->unwind = frame_unwind_find_by_frame (prev->next,
+ &prev->prologue_cache);
if (prev->unwind->type == UNKNOWN_FRAME)
prev->type = frame_type_from_pc (get_frame_pc (prev));
else
to the new frame code. Implement FRAME_CHAIN the way the
new frame will. */
/* Find PREV frame's unwinder. */
- prev->unwind = frame_unwind_find_by_frame (this_frame);
+ prev->unwind = frame_unwind_find_by_frame (this_frame,
+ &prev->prologue_cache);
/* FIXME: cagney/2003-04-02: Rather than storing the frame's
type in the frame, the unwinder's type should be returned
directly. Unfortunately, legacy code, called by
If there isn't a FRAME_CHAIN, the code above will have already
done this. */
if (prev->unwind == NULL)
- prev->unwind = frame_unwind_find_by_frame (prev->next);
+ prev->unwind = frame_unwind_find_by_frame (prev->next,
+ &prev->prologue_cache);
/* If the unwinder provides a frame type, use it. Otherwize
continue on to that heuristic mess. */
{
/* Initialize the frame's unwinder because it is that which
provides the frame's type. */
- frame->unwind = frame_unwind_find_by_frame (frame->next);
+ frame->unwind = frame_unwind_find_by_frame (frame->next,
+ &frame->prologue_cache);
/* FIXME: cagney/2003-04-02: Rather than storing the frame's
type in the frame, the unwinder's type should be returned
directly. Unfortunately, legacy code, called by