1 /* Definitions for frame address handler, for GDB, the GNU debugger.
3 Copyright 2003 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #include "frame-base.h"
26 /* A default frame base implementations. If it wasn't for the old
27 FRAME_LOCALS_ADDRESS and FRAME_ARGS_ADDRESS, these could be
28 combined into a single function. All architectures really need to
32 default_frame_base_address (struct frame_info *next_frame, void **this_cache)
34 struct frame_info *this_frame = get_prev_frame (next_frame);
35 return get_frame_base (this_frame); /* sigh! */
39 default_frame_locals_address (struct frame_info *next_frame, void **this_cache)
41 struct frame_info *this_frame = get_prev_frame (next_frame);
42 return FRAME_LOCALS_ADDRESS (this_frame);
46 default_frame_args_address (struct frame_info *next_frame, void **this_cache)
48 struct frame_info *this_frame = get_prev_frame (next_frame);
49 return FRAME_ARGS_ADDRESS (this_frame);
52 const struct frame_base default_frame_base = {
53 NULL, /* No parent. */
54 default_frame_base_address,
55 default_frame_locals_address,
56 default_frame_args_address
59 static struct gdbarch_data *frame_base_data;
61 struct frame_base_table
63 frame_base_p_ftype **p;
64 const struct frame_base *default_base;
69 frame_base_init (struct gdbarch *gdbarch)
71 struct frame_base_table *table = XCALLOC (1, struct frame_base_table);
72 table->default_base = &default_frame_base;
77 frame_base_free (struct gdbarch *gdbarch, void *data)
79 struct frame_base_table *table =
80 gdbarch_data (gdbarch, frame_base_data);
85 static struct frame_base_table *
86 frame_base_table (struct gdbarch *gdbarch)
88 struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
91 /* ULGH, called during architecture initialization. Patch
93 table = frame_base_init (gdbarch);
94 set_gdbarch_data (gdbarch, frame_base_data, table);
99 /* Append a predicate to the end of the table. */
101 append_predicate (struct frame_base_table *table, frame_base_p_ftype *p)
103 table->p = xrealloc (table->p, ((table->nr + 1)
104 * sizeof (frame_base_p_ftype *)));
105 table->p[table->nr] = p;
110 frame_base_append_predicate (struct gdbarch *gdbarch,
111 frame_base_p_ftype *p)
113 struct frame_base_table *table = frame_base_table (gdbarch);
114 append_predicate (table, p);
118 frame_base_set_default (struct gdbarch *gdbarch,
119 const struct frame_base *default_base)
121 struct frame_base_table *table = frame_base_table (gdbarch);
122 table->default_base = default_base;
125 const struct frame_base *
126 frame_base_find_by_pc (struct gdbarch *gdbarch, CORE_ADDR pc)
129 struct frame_base_table *table = frame_base_table (gdbarch);
130 for (i = 0; i < table->nr; i++)
132 const struct frame_base *desc = table->p[i] (pc);
136 return table->default_base;
139 extern initialize_file_ftype _initialize_frame_base; /* -Wmissing-protypes */
142 _initialize_frame_base (void)
144 frame_base_data = register_gdbarch_data (frame_base_init,