1 /* Definitions for frame address handler, for GDB, the GNU debugger.
3 Copyright (C) 2003, 2004 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 2 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, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
23 #include "frame-base.h"
25 #include "gdb_obstack.h"
27 /* A default frame base implementations. If it wasn't for the old
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. */
33 default_frame_base_address (struct frame_info
*next_frame
, void **this_cache
)
35 struct frame_info
*this_frame
= get_prev_frame (next_frame
);
36 return get_frame_base (this_frame
); /* sigh! */
40 default_frame_locals_address (struct frame_info
*next_frame
, void **this_cache
)
42 return default_frame_base_address (next_frame
, this_cache
);
46 default_frame_args_address (struct frame_info
*next_frame
, void **this_cache
)
48 return default_frame_base_address (next_frame
, this_cache
);
51 const struct frame_base default_frame_base
= {
52 NULL
, /* No parent. */
53 default_frame_base_address
,
54 default_frame_locals_address
,
55 default_frame_args_address
58 static struct gdbarch_data
*frame_base_data
;
60 struct frame_base_table_entry
62 frame_base_sniffer_ftype
*sniffer
;
63 struct frame_base_table_entry
*next
;
66 struct frame_base_table
68 struct frame_base_table_entry
*head
;
69 struct frame_base_table_entry
**tail
;
70 const struct frame_base
*default_base
;
74 frame_base_init (struct obstack
*obstack
)
76 struct frame_base_table
*table
77 = OBSTACK_ZALLOC (obstack
, struct frame_base_table
);
78 table
->tail
= &table
->head
;
79 table
->default_base
= &default_frame_base
;
84 frame_base_append_sniffer (struct gdbarch
*gdbarch
,
85 frame_base_sniffer_ftype
*sniffer
)
87 struct frame_base_table
*table
= gdbarch_data (gdbarch
, frame_base_data
);
88 (*table
->tail
) = GDBARCH_OBSTACK_ZALLOC (gdbarch
, struct frame_base_table_entry
);
89 (*table
->tail
)->sniffer
= sniffer
;
90 table
->tail
= &(*table
->tail
)->next
;
94 frame_base_set_default (struct gdbarch
*gdbarch
,
95 const struct frame_base
*default_base
)
97 struct frame_base_table
*table
= gdbarch_data (gdbarch
, frame_base_data
);
98 table
->default_base
= default_base
;
101 const struct frame_base
*
102 frame_base_find_by_frame (struct frame_info
*next_frame
)
104 struct gdbarch
*gdbarch
= get_frame_arch (next_frame
);
105 struct frame_base_table
*table
= gdbarch_data (gdbarch
, frame_base_data
);
106 struct frame_base_table_entry
*entry
;
108 for (entry
= table
->head
; entry
!= NULL
; entry
= entry
->next
)
110 const struct frame_base
*desc
= NULL
;
111 desc
= entry
->sniffer (next_frame
);
115 return table
->default_base
;
118 extern initialize_file_ftype _initialize_frame_base
; /* -Wmissing-prototypes */
121 _initialize_frame_base (void)
123 frame_base_data
= gdbarch_data_register_pre_init (frame_base_init
);