2011-01-07 Michael Snyder <msnyder@vmware.com>
[deliverable/binutils-gdb.git] / gdb / frame-base.c
CommitLineData
da62e633
AC
1/* Definitions for frame address handler, for GDB, the GNU debugger.
2
7b6bb8da 3 Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011
4c38e0a4 4 Free Software Foundation, Inc.
da62e633
AC
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
da62e633
AC
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
da62e633
AC
20
21#include "defs.h"
22#include "frame-base.h"
23#include "frame.h"
0cad6aec 24#include "gdb_obstack.h"
da62e633
AC
25
26/* A default frame base implementations. If it wasn't for the old
42efa47a
AC
27 DEPRECATED_FRAME_LOCALS_ADDRESS and DEPRECATED_FRAME_ARGS_ADDRESS,
28 these could be combined into a single function. All architectures
29 really need to override this. */
da62e633
AC
30
31static CORE_ADDR
669fac23 32default_frame_base_address (struct frame_info *this_frame, void **this_cache)
da62e633 33{
da62e633
AC
34 return get_frame_base (this_frame); /* sigh! */
35}
36
37static CORE_ADDR
669fac23 38default_frame_locals_address (struct frame_info *this_frame, void **this_cache)
da62e633 39{
669fac23 40 return default_frame_base_address (this_frame, this_cache);
da62e633
AC
41}
42
43static CORE_ADDR
669fac23 44default_frame_args_address (struct frame_info *this_frame, void **this_cache)
da62e633 45{
669fac23 46 return default_frame_base_address (this_frame, this_cache);
da62e633
AC
47}
48
49const struct frame_base default_frame_base = {
50 NULL, /* No parent. */
51 default_frame_base_address,
52 default_frame_locals_address,
53 default_frame_args_address
54};
55
56static struct gdbarch_data *frame_base_data;
57
0cad6aec
AC
58struct frame_base_table_entry
59{
60 frame_base_sniffer_ftype *sniffer;
61 struct frame_base_table_entry *next;
62};
63
da62e633
AC
64struct frame_base_table
65{
0cad6aec
AC
66 struct frame_base_table_entry *head;
67 struct frame_base_table_entry **tail;
da62e633 68 const struct frame_base *default_base;
da62e633
AC
69};
70
71static void *
0cad6aec 72frame_base_init (struct obstack *obstack)
da62e633 73{
0cad6aec
AC
74 struct frame_base_table *table
75 = OBSTACK_ZALLOC (obstack, struct frame_base_table);
bb9bcb69 76
0cad6aec 77 table->tail = &table->head;
da62e633
AC
78 table->default_base = &default_frame_base;
79 return table;
80}
81
e8a89fe2
AC
82void
83frame_base_append_sniffer (struct gdbarch *gdbarch,
84 frame_base_sniffer_ftype *sniffer)
85{
0cad6aec 86 struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
bb9bcb69 87
3e43a32a
MS
88 (*table->tail)
89 = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_base_table_entry);
0cad6aec
AC
90 (*table->tail)->sniffer = sniffer;
91 table->tail = &(*table->tail)->next;
da62e633
AC
92}
93
94void
95frame_base_set_default (struct gdbarch *gdbarch,
96 const struct frame_base *default_base)
97{
0cad6aec 98 struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
bb9bcb69 99
da62e633
AC
100 table->default_base = default_base;
101}
102
103const struct frame_base *
669fac23 104frame_base_find_by_frame (struct frame_info *this_frame)
da62e633 105{
669fac23 106 struct gdbarch *gdbarch = get_frame_arch (this_frame);
0cad6aec
AC
107 struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
108 struct frame_base_table_entry *entry;
109
110 for (entry = table->head; entry != NULL; entry = entry->next)
da62e633 111 {
e8a89fe2 112 const struct frame_base *desc = NULL;
bb9bcb69 113
669fac23 114 desc = entry->sniffer (this_frame);
da62e633
AC
115 if (desc != NULL)
116 return desc;
117 }
118 return table->default_base;
119}
120
a78f21af 121extern initialize_file_ftype _initialize_frame_base; /* -Wmissing-prototypes */
b9362cc7 122
da62e633
AC
123void
124_initialize_frame_base (void)
125{
0cad6aec 126 frame_base_data = gdbarch_data_register_pre_init (frame_base_init);
da62e633 127}
This page took 0.66583 seconds and 4 git commands to generate.