2004-01-02 Michael Chastain <mec.gnu@mindspring.com>
[deliverable/binutils-gdb.git] / gdb / frame-base.c
index f7ba4be19033b78bdc17d03c7ca372a4a94faecd..66a0106aa0b83b1cbf149cccb868429a4c1be122 100644 (file)
@@ -24,9 +24,9 @@
 #include "frame.h"
 
 /* A default frame base implementations.  If it wasn't for the old
-   FRAME_LOCALS_ADDRESS and FRAME_ARGS_ADDRESS, these could be
-   combined into a single function.  All architectures really need to
-   override this.  */
+   DEPRECATED_FRAME_LOCALS_ADDRESS and DEPRECATED_FRAME_ARGS_ADDRESS,
+   these could be combined into a single function.  All architectures
+   really need to override this.  */
 
 static CORE_ADDR
 default_frame_base_address (struct frame_info *next_frame, void **this_cache)
@@ -38,25 +38,25 @@ default_frame_base_address (struct frame_info *next_frame, void **this_cache)
 static CORE_ADDR
 default_frame_locals_address (struct frame_info *next_frame, void **this_cache)
 {
-  struct frame_info *this_frame = get_prev_frame (next_frame);
-  return FRAME_LOCALS_ADDRESS (this_frame);
+  if (DEPRECATED_FRAME_LOCALS_ADDRESS_P ())
+    {
+      /* This is bad.  The computation of per-frame locals address
+        should use a per-frame frame-base.  */
+      struct frame_info *this_frame = get_prev_frame (next_frame);
+      return DEPRECATED_FRAME_LOCALS_ADDRESS (this_frame);
+    }
+  return default_frame_base_address (next_frame, this_cache);
 }
 
 static CORE_ADDR
 default_frame_args_address (struct frame_info *next_frame, void **this_cache)
 {
-  struct frame_info *this_frame = get_prev_frame (next_frame);
-  /* FRAME_ARGS_ADDRESS_CORRECT is just like FRAME_ARGS_ADDRESS except
-     that if it is unsure about the answer, it returns 0 instead of
-     guessing (this happens on the VAX and i960, for example).
-
-     On most machines, we never have to guess about the args address,
-     so FRAME_ARGS_ADDRESS{,_CORRECT} are the same.  */
-#ifdef FRAME_ARGS_ADDRESS_CORRECT
-  return FRAME_ARGS_ADDRESS_CORRECT (this_frame);
-#else
-  return FRAME_ARGS_ADDRESS (this_frame);
-#endif
+  if (DEPRECATED_FRAME_ARGS_ADDRESS_P ())
+    {
+      struct frame_info *this_frame = get_prev_frame (next_frame);
+      return DEPRECATED_FRAME_ARGS_ADDRESS (this_frame);
+    }
+  return default_frame_base_address (next_frame, this_cache);
 }
 
 const struct frame_base default_frame_base = {
@@ -70,7 +70,7 @@ static struct gdbarch_data *frame_base_data;
 
 struct frame_base_table
 {
-  frame_base_p_ftype **p;
+  frame_base_sniffer_ftype **sniffer;
   const struct frame_base *default_base;
   int nr;
 };
@@ -83,15 +83,6 @@ frame_base_init (struct gdbarch *gdbarch)
   return table;
 }
 
-static void
-frame_base_free (struct gdbarch *gdbarch, void *data)
-{
-  struct frame_base_table *table =
-    gdbarch_data (gdbarch, frame_base_data);
-  xfree (table->p);
-  xfree (table);
-}
-
 static struct frame_base_table *
 frame_base_table (struct gdbarch *gdbarch)
 {
@@ -108,20 +99,22 @@ frame_base_table (struct gdbarch *gdbarch)
 
 /* Append a predicate to the end of the table.  */
 static void
-append_predicate (struct frame_base_table *table, frame_base_p_ftype *p)
+append_predicate (struct frame_base_table *table,
+                 frame_base_sniffer_ftype *sniffer)
 {
-  table->p = xrealloc (table->p, ((table->nr + 1)
-                                 * sizeof (frame_base_p_ftype *)));
-  table->p[table->nr] = p;
+  table->sniffer = xrealloc (table->sniffer,
+                            ((table->nr + 1)
+                             * sizeof (frame_base_sniffer_ftype *)));
+  table->sniffer[table->nr] = sniffer;
   table->nr++;
 }
 
 void
-frame_base_append_predicate (struct gdbarch *gdbarch,
-                            frame_base_p_ftype *p)
+frame_base_append_sniffer (struct gdbarch *gdbarch,
+                          frame_base_sniffer_ftype *sniffer)
 {
   struct frame_base_table *table = frame_base_table (gdbarch);
-  append_predicate (table, p);
+  append_predicate (table, sniffer);
 }
 
 void
@@ -133,22 +126,25 @@ frame_base_set_default (struct gdbarch *gdbarch,
 }
 
 const struct frame_base *
-frame_base_find_by_pc (struct gdbarch *gdbarch, CORE_ADDR pc)
+frame_base_find_by_frame (struct frame_info *next_frame)
 {
-  int i;
+  struct gdbarch *gdbarch = get_frame_arch (next_frame);
   struct frame_base_table *table = frame_base_table (gdbarch);
+  int i;
   for (i = 0; i < table->nr; i++)
     {
-      const struct frame_base *desc = table->p[i] (pc);
+      const struct frame_base *desc = NULL;
+      desc = table->sniffer[i] (next_frame);
       if (desc != NULL)
        return desc;
     }
   return table->default_base;
 }
 
+extern initialize_file_ftype _initialize_frame_base; /* -Wmissing-prototypes */
+
 void
 _initialize_frame_base (void)
 {
-  frame_base_data = register_gdbarch_data (frame_base_init,
-                                          frame_base_free);
+  frame_base_data = register_gdbarch_data (frame_base_init);
 }
This page took 0.02467 seconds and 4 git commands to generate.