* symtab.h (enum address_class): Remove LOC_INDIRECT and
[deliverable/binutils-gdb.git] / gdb / frame-base.c
CommitLineData
da62e633
AC
1/* Definitions for frame address handler, for GDB, the GNU debugger.
2
9b254dd1 3 Copyright (C) 2003, 2004, 2007, 2008 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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
da62e633
AC
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
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
da62e633
AC
19
20#include "defs.h"
21#include "frame-base.h"
22#include "frame.h"
0cad6aec 23#include "gdb_obstack.h"
da62e633
AC
24
25/* A default frame base implementations. If it wasn't for the old
42efa47a
AC
26 DEPRECATED_FRAME_LOCALS_ADDRESS and DEPRECATED_FRAME_ARGS_ADDRESS,
27 these could be combined into a single function. All architectures
28 really need to override this. */
da62e633
AC
29
30static CORE_ADDR
669fac23 31default_frame_base_address (struct frame_info *this_frame, void **this_cache)
da62e633 32{
da62e633
AC
33 return get_frame_base (this_frame); /* sigh! */
34}
35
36static CORE_ADDR
669fac23 37default_frame_locals_address (struct frame_info *this_frame, void **this_cache)
da62e633 38{
669fac23 39 return default_frame_base_address (this_frame, this_cache);
da62e633
AC
40}
41
42static CORE_ADDR
669fac23 43default_frame_args_address (struct frame_info *this_frame, void **this_cache)
da62e633 44{
669fac23 45 return default_frame_base_address (this_frame, this_cache);
da62e633
AC
46}
47
48const struct frame_base default_frame_base = {
49 NULL, /* No parent. */
50 default_frame_base_address,
51 default_frame_locals_address,
52 default_frame_args_address
53};
54
55static struct gdbarch_data *frame_base_data;
56
0cad6aec
AC
57struct frame_base_table_entry
58{
59 frame_base_sniffer_ftype *sniffer;
60 struct frame_base_table_entry *next;
61};
62
da62e633
AC
63struct frame_base_table
64{
0cad6aec
AC
65 struct frame_base_table_entry *head;
66 struct frame_base_table_entry **tail;
da62e633 67 const struct frame_base *default_base;
da62e633
AC
68};
69
70static void *
0cad6aec 71frame_base_init (struct obstack *obstack)
da62e633 72{
0cad6aec
AC
73 struct frame_base_table *table
74 = OBSTACK_ZALLOC (obstack, struct frame_base_table);
75 table->tail = &table->head;
da62e633
AC
76 table->default_base = &default_frame_base;
77 return table;
78}
79
e8a89fe2
AC
80void
81frame_base_append_sniffer (struct gdbarch *gdbarch,
82 frame_base_sniffer_ftype *sniffer)
83{
0cad6aec
AC
84 struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
85 (*table->tail) = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_base_table_entry);
86 (*table->tail)->sniffer = sniffer;
87 table->tail = &(*table->tail)->next;
da62e633
AC
88}
89
90void
91frame_base_set_default (struct gdbarch *gdbarch,
92 const struct frame_base *default_base)
93{
0cad6aec 94 struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
da62e633
AC
95 table->default_base = default_base;
96}
97
98const struct frame_base *
669fac23 99frame_base_find_by_frame (struct frame_info *this_frame)
da62e633 100{
669fac23 101 struct gdbarch *gdbarch = get_frame_arch (this_frame);
0cad6aec
AC
102 struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
103 struct frame_base_table_entry *entry;
104
105 for (entry = table->head; entry != NULL; entry = entry->next)
da62e633 106 {
e8a89fe2 107 const struct frame_base *desc = NULL;
669fac23 108 desc = entry->sniffer (this_frame);
da62e633
AC
109 if (desc != NULL)
110 return desc;
111 }
112 return table->default_base;
113}
114
a78f21af 115extern initialize_file_ftype _initialize_frame_base; /* -Wmissing-prototypes */
b9362cc7 116
da62e633
AC
117void
118_initialize_frame_base (void)
119{
0cad6aec 120 frame_base_data = gdbarch_data_register_pre_init (frame_base_init);
da62e633 121}
This page took 0.351909 seconds and 4 git commands to generate.