nm: Add --quiet to suppress "no symbols" diagnostic
[binutils-gdb.git] / gdb / frame-base.c
blob4d3fb03e838fbd6f9450f996678d6ae3871fa800
1 /* Definitions for frame address handler, for GDB, the GNU debugger.
3 Copyright (C) 2003-2021 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 3 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, see <http://www.gnu.org/licenses/>. */
20 #include "defs.h"
21 #include "frame-base.h"
22 #include "frame.h"
23 #include "gdb_obstack.h"
24 #include "gdbarch.h"
26 /* A default frame base implementations. If it wasn't for the old
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. */
31 static CORE_ADDR
32 default_frame_base_address (struct frame_info *this_frame, void **this_cache)
34 return get_frame_base (this_frame); /* sigh! */
37 static CORE_ADDR
38 default_frame_locals_address (struct frame_info *this_frame, void **this_cache)
40 return default_frame_base_address (this_frame, this_cache);
43 static CORE_ADDR
44 default_frame_args_address (struct frame_info *this_frame, void **this_cache)
46 return default_frame_base_address (this_frame, this_cache);
49 const 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
56 static struct gdbarch_data *frame_base_data;
58 struct frame_base_table_entry
60 frame_base_sniffer_ftype *sniffer;
61 struct frame_base_table_entry *next;
64 struct frame_base_table
66 struct frame_base_table_entry *head;
67 struct frame_base_table_entry **tail;
68 const struct frame_base *default_base;
71 static void *
72 frame_base_init (struct obstack *obstack)
74 struct frame_base_table *table
75 = OBSTACK_ZALLOC (obstack, struct frame_base_table);
77 table->tail = &table->head;
78 table->default_base = &default_frame_base;
79 return table;
82 void
83 frame_base_append_sniffer (struct gdbarch *gdbarch,
84 frame_base_sniffer_ftype *sniffer)
86 struct frame_base_table *table
87 = (struct frame_base_table *) gdbarch_data (gdbarch, frame_base_data);
89 (*table->tail)
90 = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_base_table_entry);
91 (*table->tail)->sniffer = sniffer;
92 table->tail = &(*table->tail)->next;
95 void
96 frame_base_set_default (struct gdbarch *gdbarch,
97 const struct frame_base *default_base)
99 struct frame_base_table *table
100 = (struct frame_base_table *) gdbarch_data (gdbarch, frame_base_data);
102 table->default_base = default_base;
105 const struct frame_base *
106 frame_base_find_by_frame (struct frame_info *this_frame)
108 struct gdbarch *gdbarch = get_frame_arch (this_frame);
109 struct frame_base_table *table
110 = (struct frame_base_table *) gdbarch_data (gdbarch, frame_base_data);
111 struct frame_base_table_entry *entry;
113 for (entry = table->head; entry != NULL; entry = entry->next)
115 const struct frame_base *desc = NULL;
117 desc = entry->sniffer (this_frame);
118 if (desc != NULL)
119 return desc;
121 return table->default_base;
124 void _initialize_frame_base ();
125 void
126 _initialize_frame_base ()
128 frame_base_data = gdbarch_data_register_pre_init (frame_base_init);