GDB (xrefs)
/tmp/gdb-7.10/gdb/frame-base.c
Go to the documentation of this file.
1 /* Definitions for frame address handler, for GDB, the GNU debugger.
2 
3  Copyright (C) 2003-2015 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>. */
19 
20 #include "defs.h"
21 #include "frame-base.h"
22 #include "frame.h"
23 #include "gdb_obstack.h"
24 
25 /* A default frame base implementations. If it wasn't for the old
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. */
29 
30 static CORE_ADDR
31 default_frame_base_address (struct frame_info *this_frame, void **this_cache)
32 {
33  return get_frame_base (this_frame); /* sigh! */
34 }
35 
36 static CORE_ADDR
37 default_frame_locals_address (struct frame_info *this_frame, void **this_cache)
38 {
39  return default_frame_base_address (this_frame, this_cache);
40 }
41 
42 static CORE_ADDR
43 default_frame_args_address (struct frame_info *this_frame, void **this_cache)
44 {
45  return default_frame_base_address (this_frame, this_cache);
46 }
47 
48 const struct frame_base default_frame_base = {
49  NULL, /* No parent. */
53 };
54 
56 
58 {
61 };
62 
64 {
67  const struct frame_base *default_base;
68 };
69 
70 static void *
71 frame_base_init (struct obstack *obstack)
72 {
73  struct frame_base_table *table
74  = OBSTACK_ZALLOC (obstack, struct frame_base_table);
75 
76  table->tail = &table->head;
78  return table;
79 }
80 
81 void
83  frame_base_sniffer_ftype *sniffer)
84 {
85  struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
86 
87  (*table->tail)
89  (*table->tail)->sniffer = sniffer;
90  table->tail = &(*table->tail)->next;
91 }
92 
93 void
95  const struct frame_base *default_base)
96 {
97  struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
98 
99  table->default_base = default_base;
100 }
101 
102 const struct frame_base *
104 {
105  struct gdbarch *gdbarch = get_frame_arch (this_frame);
106  struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
107  struct frame_base_table_entry *entry;
108 
109  for (entry = table->head; entry != NULL; entry = entry->next)
110  {
111  const struct frame_base *desc = NULL;
112 
113  desc = entry->sniffer (this_frame);
114  if (desc != NULL)
115  return desc;
116  }
117  return table->default_base;
118 }
119 
120 extern initialize_file_ftype _initialize_frame_base; /* -Wmissing-prototypes */
121 
122 void
124 {
126 }
bfd_vma CORE_ADDR
Definition: common-types.h:41
const struct frame_base *( frame_base_sniffer_ftype)(struct frame_info *this_frame)
Definition: frame-base.h:71
const struct frame_base * default_base
Definition: frame-base.c:67
void * gdbarch_data(struct gdbarch *gdbarch, struct gdbarch_data *data)
Definition: gdbarch.c:4845
struct gdbarch_data * gdbarch_data_register_pre_init(gdbarch_data_pre_init_ftype *pre_init)
Definition: gdbarch.c:4806
#define GDBARCH_OBSTACK_ZALLOC(GDBARCH, TYPE)
Definition: gdbarch.h:1615
static CORE_ADDR default_frame_locals_address(struct frame_info *this_frame, void **this_cache)
Definition: frame-base.c:37
initialize_file_ftype _initialize_frame_base
static CORE_ADDR default_frame_base_address(struct frame_info *this_frame, void **this_cache)
Definition: frame-base.c:31
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
Definition: frame-base.c:94
void initialize_file_ftype(void)
Definition: defs.h:281
static struct gdbarch_data * frame_base_data
Definition: frame-base.c:55
struct frame_base_table_entry ** tail
Definition: frame-base.c:66
frame_base_sniffer_ftype * sniffer
Definition: frame-base.c:59
static CORE_ADDR default_frame_args_address(struct frame_info *this_frame, void **this_cache)
Definition: frame-base.c:43
CORE_ADDR get_frame_base(struct frame_info *fi)
Definition: frame.c:2388
static void * frame_base_init(struct obstack *obstack)
Definition: frame-base.c:71
void frame_base_append_sniffer(struct gdbarch *gdbarch, frame_base_sniffer_ftype *sniffer)
Definition: frame-base.c:82
struct frame_base_table_entry * next
Definition: frame-base.c:60
#define OBSTACK_ZALLOC(OBSTACK, TYPE)
Definition: gdb_obstack.h:27
const struct frame_base default_frame_base
Definition: frame-base.c:48
Definition: frame-base.c:57
struct frame_base_table_entry * head
Definition: frame-base.c:65
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
Definition: frame.c:2535
const struct frame_base * frame_base_find_by_frame(struct frame_info *this_frame)
Definition: frame-base.c:103