]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/frame-base.c
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / frame-base.c
CommitLineData
da62e633
AC
1/* Definitions for frame address handler, for GDB, the GNU debugger.
2
6aba47ca 3 Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
da62e633
AC
4
5 This file is part of GDB.
6
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.
11
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.
16
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
197e01b6
EZ
19 Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
da62e633
AC
21
22#include "defs.h"
23#include "frame-base.h"
24#include "frame.h"
0cad6aec 25#include "gdb_obstack.h"
da62e633
AC
26
27/* A default frame base implementations. If it wasn't for the old
42efa47a
AC
28 DEPRECATED_FRAME_LOCALS_ADDRESS and DEPRECATED_FRAME_ARGS_ADDRESS,
29 these could be combined into a single function. All architectures
30 really need to override this. */
da62e633
AC
31
32static CORE_ADDR
33default_frame_base_address (struct frame_info *next_frame, void **this_cache)
34{
35 struct frame_info *this_frame = get_prev_frame (next_frame);
36 return get_frame_base (this_frame); /* sigh! */
37}
38
39static CORE_ADDR
40default_frame_locals_address (struct frame_info *next_frame, void **this_cache)
41{
42efa47a 42 return default_frame_base_address (next_frame, this_cache);
da62e633
AC
43}
44
45static CORE_ADDR
46default_frame_args_address (struct frame_info *next_frame, void **this_cache)
47{
42efa47a 48 return default_frame_base_address (next_frame, this_cache);
da62e633
AC
49}
50
51const struct frame_base default_frame_base = {
52 NULL, /* No parent. */
53 default_frame_base_address,
54 default_frame_locals_address,
55 default_frame_args_address
56};
57
58static struct gdbarch_data *frame_base_data;
59
0cad6aec
AC
60struct frame_base_table_entry
61{
62 frame_base_sniffer_ftype *sniffer;
63 struct frame_base_table_entry *next;
64};
65
da62e633
AC
66struct frame_base_table
67{
0cad6aec
AC
68 struct frame_base_table_entry *head;
69 struct frame_base_table_entry **tail;
da62e633 70 const struct frame_base *default_base;
da62e633
AC
71};
72
73static void *
0cad6aec 74frame_base_init (struct obstack *obstack)
da62e633 75{
0cad6aec
AC
76 struct frame_base_table *table
77 = OBSTACK_ZALLOC (obstack, struct frame_base_table);
78 table->tail = &table->head;
da62e633
AC
79 table->default_base = &default_frame_base;
80 return table;
81}
82
e8a89fe2
AC
83void
84frame_base_append_sniffer (struct gdbarch *gdbarch,
85 frame_base_sniffer_ftype *sniffer)
86{
0cad6aec
AC
87 struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
88 (*table->tail) = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_base_table_entry);
89 (*table->tail)->sniffer = sniffer;
90 table->tail = &(*table->tail)->next;
da62e633
AC
91}
92
93void
94frame_base_set_default (struct gdbarch *gdbarch,
95 const struct frame_base *default_base)
96{
0cad6aec 97 struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
da62e633
AC
98 table->default_base = default_base;
99}
100
101const struct frame_base *
e8a89fe2 102frame_base_find_by_frame (struct frame_info *next_frame)
da62e633 103{
e8a89fe2 104 struct gdbarch *gdbarch = get_frame_arch (next_frame);
0cad6aec
AC
105 struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
106 struct frame_base_table_entry *entry;
107
108 for (entry = table->head; entry != NULL; entry = entry->next)
da62e633 109 {
e8a89fe2 110 const struct frame_base *desc = NULL;
0cad6aec 111 desc = entry->sniffer (next_frame);
da62e633
AC
112 if (desc != NULL)
113 return desc;
114 }
115 return table->default_base;
116}
117
a78f21af 118extern initialize_file_ftype _initialize_frame_base; /* -Wmissing-prototypes */
b9362cc7 119
da62e633
AC
120void
121_initialize_frame_base (void)
122{
0cad6aec 123 frame_base_data = gdbarch_data_register_pre_init (frame_base_init);
da62e633 124}