Sort includes for files gdb/[a-f]*.[chyl].
[deliverable/binutils-gdb.git] / gdb / frame-base.c
CommitLineData
da62e633
AC
1/* Definitions for frame address handler, for GDB, the GNU debugger.
2
42a4f53d 3 Copyright (C) 2003-2019 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"
d55e5aa6
TT
21
22/* Local non-gdb includes. */
da62e633
AC
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
669fac23 33default_frame_base_address (struct frame_info *this_frame, void **this_cache)
da62e633 34{
da62e633
AC
35 return get_frame_base (this_frame); /* sigh! */
36}
37
38static CORE_ADDR
669fac23 39default_frame_locals_address (struct frame_info *this_frame, void **this_cache)
da62e633 40{
669fac23 41 return default_frame_base_address (this_frame, this_cache);
da62e633
AC
42}
43
44static CORE_ADDR
669fac23 45default_frame_args_address (struct frame_info *this_frame, void **this_cache)
da62e633 46{
669fac23 47 return default_frame_base_address (this_frame, this_cache);
da62e633
AC
48}
49
50const struct frame_base default_frame_base = {
51 NULL, /* No parent. */
52 default_frame_base_address,
53 default_frame_locals_address,
54 default_frame_args_address
55};
56
57static struct gdbarch_data *frame_base_data;
58
0cad6aec
AC
59struct frame_base_table_entry
60{
61 frame_base_sniffer_ftype *sniffer;
62 struct frame_base_table_entry *next;
63};
64
da62e633
AC
65struct frame_base_table
66{
0cad6aec
AC
67 struct frame_base_table_entry *head;
68 struct frame_base_table_entry **tail;
da62e633 69 const struct frame_base *default_base;
da62e633
AC
70};
71
72static void *
0cad6aec 73frame_base_init (struct obstack *obstack)
da62e633 74{
0cad6aec
AC
75 struct frame_base_table *table
76 = OBSTACK_ZALLOC (obstack, struct frame_base_table);
bb9bcb69 77
0cad6aec 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{
9a3c8263
SM
87 struct frame_base_table *table
88 = (struct frame_base_table *) gdbarch_data (gdbarch, frame_base_data);
bb9bcb69 89
3e43a32a
MS
90 (*table->tail)
91 = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_base_table_entry);
0cad6aec
AC
92 (*table->tail)->sniffer = sniffer;
93 table->tail = &(*table->tail)->next;
da62e633
AC
94}
95
96void
97frame_base_set_default (struct gdbarch *gdbarch,
98 const struct frame_base *default_base)
99{
9a3c8263
SM
100 struct frame_base_table *table
101 = (struct frame_base_table *) gdbarch_data (gdbarch, frame_base_data);
bb9bcb69 102
da62e633
AC
103 table->default_base = default_base;
104}
105
106const struct frame_base *
669fac23 107frame_base_find_by_frame (struct frame_info *this_frame)
da62e633 108{
669fac23 109 struct gdbarch *gdbarch = get_frame_arch (this_frame);
9a3c8263
SM
110 struct frame_base_table *table
111 = (struct frame_base_table *) gdbarch_data (gdbarch, frame_base_data);
0cad6aec
AC
112 struct frame_base_table_entry *entry;
113
114 for (entry = table->head; entry != NULL; entry = entry->next)
da62e633 115 {
e8a89fe2 116 const struct frame_base *desc = NULL;
bb9bcb69 117
669fac23 118 desc = entry->sniffer (this_frame);
da62e633
AC
119 if (desc != NULL)
120 return desc;
121 }
122 return table->default_base;
123}
124
125void
126_initialize_frame_base (void)
127{
0cad6aec 128 frame_base_data = gdbarch_data_register_pre_init (frame_base_init);
da62e633 129}
This page took 1.141573 seconds and 4 git commands to generate.