* stabs.texinfo (Stack Variables): Re-write.
[deliverable/binutils-gdb.git] / gdb / frame.h
CommitLineData
bd5635a1 1/* Definitions for dealing with stack frames, for GDB, the GNU debugger.
d541211d 2 Copyright 1986, 1989, 1991, 1992 Free Software Foundation, Inc.
bd5635a1
RP
3
4This file is part of GDB.
5
d541211d 6This program is free software; you can redistribute it and/or modify
bd5635a1 7it under the terms of the GNU General Public License as published by
d541211d
PS
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
bd5635a1 10
d541211d 11This program is distributed in the hope that it will be useful,
bd5635a1
RP
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
d541211d
PS
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
bd5635a1
RP
19
20#if !defined (FRAME_H)
21#define FRAME_H 1
d541211d
PS
22
23/* A FRAME identifies a specific stack frame. It is not constant over
24 calls to the inferior (frame addresses are, see below).
25
26 This is implemented as a "struct frame_info *". This file and
27 blockframe.c are the only places which are allowed to use the
28 equivalence between FRAME and struct frame_info *. Exception:
29 Prototypes in other files use "struct frame_info *" because this
30 file might not be included.
31
32 The distinction between a FRAME and a "struct frame_info *" is made
33 with the idea of maybe someday changing a FRAME to be something else,
34 but seems to me that a "struct frame_info *" is fully general (since
35 any necessarily fields can be added; changing the meaning of existing
36 fields is not helped by the FRAME distinction), and this distinction
37 merely creates unnecessary hair. -kingdon, 18 May 93. */
bd5635a1 38typedef struct frame_info *FRAME;
d541211d
PS
39
40/* Convert from a "struct frame_info *" into a FRAME. */
41#define FRAME_INFO_ID(f) (f)
42
43/* Convert from a FRAME into a "struct frame_info *". */
44extern struct frame_info *
45get_frame_info PARAMS ((FRAME));
46
47/* Type of the address of a frame. It is widely assumed (at least in
48 prototypes in headers which might not include this header) that
49 this is the same as CORE_ADDR, and no one can think of a case in
50 which it wouldn't be, so it might be best to remove this typedef. */
bd5635a1 51typedef CORE_ADDR FRAME_ADDR;
d541211d
PS
52
53/* Convert from a FRAME into a frame address. Except in the
54 machine-dependent *FRAME* macros, a frame address has no defined
55 meaning other than as a magic cookie which identifies a frame over
56 calls to the inferior. The only known exception is inferior.h
57 (PC_IN_CALL_DUMMY) [ON_STACK]; see comments there. You cannot
58 assume that a frame address contains enough information to
59 reconstruct the frame; if you want more than just to identify the
60 frame (e.g. be able to fetch variables relative to that frame),
61 then save the whole struct frame_info (and the next struct
62 frame_info, since the latter is used for fetching variables on some
63 machines). */
64
bd5635a1 65#define FRAME_FP(fr) ((fr)->frame)
bd5635a1 66
d541211d
PS
67/* We keep a cache of stack frames, each of which is a "struct
68 frame_info". The innermost one gets allocated (in
69 wait_for_inferior) each time the inferior stops; current_frame
70 points to it. Additional frames get allocated (in
71 get_prev_frame_info) as needed, and are chained through the next
72 and prev fields. Any time that the frame cache becomes invalid
73 (most notably when we execute something, but also if we change how
74 we interpret the frames (e.g. "set heuristic-fence-post" in
75 mips-tdep.c, or anything which reads new symbols)), we should call
76 reinit_frame_cache. */
77
bd5635a1
RP
78struct frame_info
79 {
d541211d
PS
80 /* Nominal address of the frame described. See comments at FRAME_FP
81 about what this means outside the *FRAME* macros; in the *FRAME*
82 macros, it can mean whatever makes most sense for this machine. */
bd5635a1 83 FRAME_ADDR frame;
d541211d 84
bd5635a1
RP
85 /* Address at which execution is occurring in this frame.
86 For the innermost frame, it's the current pc.
87 For other frames, it is a pc saved in the next frame. */
88 CORE_ADDR pc;
d541211d
PS
89
90 /* Nonzero if this is a frame associated with calling a signal handler.
91
92 Set by machine-dependent code. On some machines, if
93 the machine-dependent code fails to check for this, the backtrace
94 will look relatively normal. For example, on the i386
95 #3 0x158728 in sighold ()
96 On other machines (e.g. rs6000), the machine-dependent code better
97 set this to prevent us from trying to print it like a normal frame. */
98 int signal_handler_caller;
99
bd5635a1
RP
100 /* Anything extra for this structure that may have been defined
101 in the machine depedent files. */
102#ifdef EXTRA_FRAME_INFO
103 EXTRA_FRAME_INFO
104#endif
d541211d
PS
105
106 /* We should probably also store a "struct frame_saved_regs" here.
107 This is already done by some machines (e.g. config/m88k/tm-m88k.h)
108 but there is no reason it couldn't be general. */
109
110 /* Pointers to the next and previous frame_info's in the frame cache. */
bd5635a1
RP
111 FRAME next, prev;
112 };
113
114/* Describe the saved registers of a frame. */
115
116struct frame_saved_regs
117 {
d541211d
PS
118
119 /* For each register, address of where it was saved on entry to
120 the frame, or zero if it was not saved on entry to this frame.
121 This includes special registers such as pc and fp saved in
122 special ways in the stack frame. The SP_REGNUM is even more
123 special, the address here is the sp for the next frame, not the
124 address where the sp was saved. */
125
bd5635a1
RP
126 CORE_ADDR regs[NUM_REGS];
127 };
128
d541211d
PS
129/* Define a default FRAME_CHAIN_VALID, in the form that is suitable for most
130 targets. If FRAME_CHAIN_VALID returns zero it means that the given frame
131 is the outermost one and has no caller.
132
133 If a particular target needs a different definition, then it can override
134 the definition here by providing one in the tm file. */
135
136#if !defined (FRAME_CHAIN_VALID)
137
138#if defined (FRAME_CHAIN_VALID_ALTERNATE)
139
140/* Use the alternate method of avoiding running up off the end of the frame
141 chain or following frames back into the startup code. See the comments
142 in objfiles.h. */
143
144#define FRAME_CHAIN_VALID(chain, thisframe) \
145 ((chain) != 0 \
146 && !inside_main_func ((thisframe) -> pc) \
147 && !inside_entry_func ((thisframe) -> pc))
148
149#else
150
151#define FRAME_CHAIN_VALID(chain, thisframe) \
152 ((chain) != 0 \
153 && !inside_entry_file (FRAME_SAVED_PC (thisframe)))
154
155#endif /* FRAME_CHAIN_VALID_ALTERNATE */
156
157#endif /* FRAME_CHAIN_VALID */
158
159/* If we encounter a request to use base register addressing of variables
160 on a machine for which gdb has not been configured to support such
161 access, report the failure to support this access mode. */
162
163#if !defined (FRAME_GET_BASEREG_VALUE)
164
165#define FRAME_GET_BASEREG_VALUE(frame, regno) \
166 (error ("Missing valid method for finding contents of base register."),0)
167
168#endif
169
bd5635a1
RP
170/* The stack frame that the user has specified for commands to act on.
171 Note that one cannot assume this is the address of valid data. */
172
173extern FRAME selected_frame;
174
d541211d
PS
175/* Level of the selected frame:
176 0 for innermost, 1 for its caller, ...
177 or -1 for frame specified by address with no defined level. */
178
179extern int selected_frame_level;
180
181extern struct frame_info *
182get_prev_frame_info PARAMS ((FRAME));
183
184extern FRAME
185create_new_frame PARAMS ((FRAME_ADDR, CORE_ADDR));
186
187extern void
188flush_cached_frames PARAMS ((void));
189
190extern void
191reinit_frame_cache PARAMS ((void));
192
193extern void
194get_frame_saved_regs PARAMS ((struct frame_info *, struct frame_saved_regs *));
195
196extern void
197set_current_frame PARAMS ((FRAME));
198
199extern FRAME
200get_prev_frame PARAMS ((FRAME));
201
202extern FRAME
203get_current_frame PARAMS ((void));
204
205extern FRAME
206get_next_frame PARAMS ((FRAME));
207
208extern struct block *
209get_frame_block PARAMS ((FRAME));
210
211extern struct block *
212get_current_block PARAMS ((void));
213
214extern struct block *
215get_selected_block PARAMS ((void));
216
217extern struct symbol *
218get_frame_function PARAMS ((FRAME));
219
220extern CORE_ADDR
221get_frame_pc PARAMS ((FRAME));
222
223extern CORE_ADDR
224get_pc_function_start PARAMS ((CORE_ADDR));
225
226extern struct block *
227block_for_pc PARAMS ((CORE_ADDR));
228
229extern int
230frameless_look_for_prologue PARAMS ((FRAME));
231
232extern void
233print_frame_args PARAMS ((struct symbol *, struct frame_info *, int, FILE *));
bd5635a1 234
d541211d
PS
235extern FRAME
236find_relative_frame PARAMS ((FRAME, int*));
bd5635a1 237
d541211d
PS
238extern void
239print_stack_frame PARAMS ((FRAME, int, int));
bd5635a1 240
d541211d
PS
241extern void
242select_frame PARAMS ((FRAME, int));
bd5635a1 243
d541211d
PS
244extern void
245record_selected_frame PARAMS ((FRAME_ADDR *, int *));
bd5635a1 246
d541211d
PS
247extern void
248print_frame_info PARAMS ((struct frame_info *, int, int, int));
bd5635a1 249
d541211d
PS
250extern CORE_ADDR
251find_saved_register PARAMS ((FRAME, int));
bd5635a1 252
d541211d
PS
253extern CORE_ADDR
254sigtramp_saved_pc PARAMS ((FRAME));
bd5635a1 255
d541211d 256#endif /* !defined (FRAME_H) */
This page took 0.152102 seconds and 4 git commands to generate.