* aoutx.h (aout_get_external_symbols): Declare 'amt' locally.
[deliverable/binutils-gdb.git] / gdb / frame-unwind.h
CommitLineData
494cca16
AC
1/* Definitions for a frame unwinder, for GDB, the GNU debugger.
2
0fb0cc75 3 Copyright (C) 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
494cca16
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
494cca16
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/>. */
494cca16
AC
19
20#if !defined (FRAME_UNWIND_H)
21#define FRAME_UNWIND_H 1
22
82417da5 23struct frame_data;
494cca16
AC
24struct frame_info;
25struct frame_id;
26struct frame_unwind;
27struct gdbarch;
28struct regcache;
669fac23 29struct value;
494cca16 30
7df05f2b
AC
31#include "frame.h" /* For enum frame_type. */
32
6dc42492
AC
33/* The following unwind functions assume a chain of frames forming the
34 sequence: (outer) prev <-> this <-> next (inner). All the
938f5214
TJB
35 functions are called with the next frame's `struct frame_info'
36 and this frame's prologue cache.
6dc42492
AC
37
38 THIS frame's register values can be obtained by unwinding NEXT
39 frame's registers (a recursive operation).
40
41 THIS frame's prologue cache can be used to cache information such
42 as where this frame's prologue stores the previous frame's
43 registers. */
44
669fac23 45/* Given THIS frame, take a whiff of its registers (namely
82417da5
AC
46 the PC and attributes) and if SELF is the applicable unwinder,
47 return non-zero. Possibly also initialize THIS_PROLOGUE_CACHE. */
48
49typedef int (frame_sniffer_ftype) (const struct frame_unwind *self,
669fac23 50 struct frame_info *this_frame,
82417da5
AC
51 void **this_prologue_cache);
52
669fac23
DJ
53/* A default frame sniffer which always accepts the frame. Used by
54 fallback prologue unwinders. */
55
56int default_frame_sniffer (const struct frame_unwind *self,
57 struct frame_info *this_frame,
58 void **this_prologue_cache);
59
6dc42492 60/* Assuming the frame chain: (outer) prev <-> this <-> next (inner);
669fac23
DJ
61 use THIS frame, and through it the NEXT frame's register unwind
62 method, to determine the frame ID of THIS frame.
6dc42492
AC
63
64 A frame ID provides an invariant that can be used to re-identify an
65 instance of a frame. It is a combination of the frame's `base' and
66 the frame's function's code address.
67
68 Traditionally, THIS frame's ID was determined by examining THIS
69 frame's function's prologue, and identifying the register/offset
70 used as THIS frame's base.
71
72 Example: An examination of THIS frame's prologue reveals that, on
73 entry, it saves the PC(+12), SP(+8), and R1(+4) registers
74 (decrementing the SP by 12). Consequently, the frame ID's base can
75 be determined by adding 12 to the THIS frame's stack-pointer, and
76 the value of THIS frame's SP can be obtained by unwinding the NEXT
77 frame's SP.
78
79 THIS_PROLOGUE_CACHE can be used to share any prolog analysis data
80 with the other unwind methods. Memory for that cache should be
35d5d4ee 81 allocated using FRAME_OBSTACK_ZALLOC(). */
6dc42492 82
669fac23 83typedef void (frame_this_id_ftype) (struct frame_info *this_frame,
6dc42492
AC
84 void **this_prologue_cache,
85 struct frame_id *this_id);
86
87/* Assuming the frame chain: (outer) prev <-> this <-> next (inner);
669fac23
DJ
88 use THIS frame, and implicitly the NEXT frame's register unwind
89 method, to unwind THIS frame's registers (returning the value of
90 the specified register REGNUM in the previous frame).
6dc42492
AC
91
92 Traditionally, THIS frame's registers were unwound by examining
93 THIS frame's function's prologue and identifying which registers
94 that prolog code saved on the stack.
95
96 Example: An examination of THIS frame's prologue reveals that, on
97 entry, it saves the PC(+12), SP(+8), and R1(+4) registers
98 (decrementing the SP by 12). Consequently, the value of the PC
99 register in the previous frame is found in memory at SP+12, and
100 THIS frame's SP can be obtained by unwinding the NEXT frame's SP.
101
669fac23
DJ
102 This function takes THIS_FRAME as an argument. It can find the
103 values of registers in THIS frame by calling get_frame_register
104 (THIS_FRAME), and reinvoke itself to find other registers in the
105 PREVIOUS frame by calling frame_unwind_register (THIS_FRAME).
6dc42492 106
669fac23
DJ
107 The result is a GDB value object describing the register value. It
108 may be a lazy reference to memory, a lazy reference to the value of
109 a register in THIS frame, or a non-lvalue.
6dc42492
AC
110
111 THIS_PROLOGUE_CACHE can be used to share any prolog analysis data
112 with the other unwind methods. Memory for that cache should be
35d5d4ee 113 allocated using FRAME_OBSTACK_ZALLOC(). */
6dc42492 114
669fac23
DJ
115typedef struct value * (frame_prev_register_ftype)
116 (struct frame_info *this_frame, void **this_prologue_cache,
117 int regnum);
cbafadeb 118
272dfcfd
AS
119/* Deallocate extra memory associated with the frame cache if any. */
120
121typedef void (frame_dealloc_cache_ftype) (struct frame_info *self,
122 void *this_cache);
cbafadeb 123
494cca16
AC
124struct frame_unwind
125{
7df05f2b
AC
126 /* The frame's type. Should this instead be a collection of
127 predicates that test the frame for various attributes? */
128 enum frame_type type;
494cca16
AC
129 /* Should an attribute indicating the frame's address-in-block go
130 here? */
6dc42492
AC
131 frame_this_id_ftype *this_id;
132 frame_prev_register_ftype *prev_register;
82417da5
AC
133 const struct frame_data *unwind_data;
134 frame_sniffer_ftype *sniffer;
272dfcfd 135 frame_dealloc_cache_ftype *dealloc_cache;
494cca16
AC
136};
137
fb2be677
AC
138/* Register a frame unwinder, _prepending_ it to the front of the
139 search list (so it is sniffed before previously registered
140 unwinders). By using a prepend, later calls can install unwinders
141 that override earlier calls. This allows, for instance, an OSABI
142 to install a a more specific sigtramp unwinder that overrides the
143 traditional brute-force unwinder. */
144extern void frame_unwind_prepend_unwinder (struct gdbarch *gdbarch,
145 const struct frame_unwind *unwinder);
82417da5 146
e8a89fe2
AC
147/* Add a frame sniffer to the list. The predicates are polled in the
148 order that they are appended. The initial list contains the dummy
149 frame sniffer. */
150
669fac23
DJ
151extern void frame_unwind_append_unwinder (struct gdbarch *gdbarch,
152 const struct frame_unwind *unwinder);
e8a89fe2 153
669fac23 154/* Iterate through sniffers for THIS frame until one returns with an
82417da5 155 unwinder implementation. Possibly initialize THIS_CACHE. */
e8a89fe2 156
669fac23 157extern const struct frame_unwind *frame_unwind_find_by_frame (struct frame_info *this_frame,
82417da5 158 void **this_cache);
e8a89fe2 159
669fac23
DJ
160/* Helper functions for value-based register unwinding. These return
161 a (possibly lazy) value of the appropriate type. */
162
163/* Return a value which indicates that FRAME did not save REGNUM. */
164
165struct value *frame_unwind_got_optimized (struct frame_info *frame,
166 int regnum);
167
168/* Return a value which indicates that FRAME copied REGNUM into
169 register NEW_REGNUM. */
170
171struct value *frame_unwind_got_register (struct frame_info *frame, int regnum,
172 int new_regnum);
173
174/* Return a value which indicates that FRAME saved REGNUM in memory at
175 ADDR. */
176
177struct value *frame_unwind_got_memory (struct frame_info *frame, int regnum,
178 CORE_ADDR addr);
179
180/* Return a value which indicates that FRAME's saved version of
181 REGNUM has a known constant (computed) value of VAL. */
182
183struct value *frame_unwind_got_constant (struct frame_info *frame, int regnum,
184 ULONGEST val);
185
15c1e57f
JB
186/* Return a value which indicates that FRAME's saved version of
187 REGNUM has a known constant (computed) value which is stored
188 inside BUF. */
189
190struct value *frame_unwind_got_bytes (struct frame_info *frame, int regnum,
191 gdb_byte *buf);
192
669fac23
DJ
193/* Return a value which indicates that FRAME's saved version of REGNUM
194 has a known constant (computed) value of ADDR. Convert the
195 CORE_ADDR to a target address if necessary. */
196
197struct value *frame_unwind_got_address (struct frame_info *frame, int regnum,
198 CORE_ADDR addr);
199
494cca16 200#endif
This page took 0.489568 seconds and 4 git commands to generate.