Commit | Line | Data |
---|---|---|
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 | |
4 | This file is part of GDB. | |
5 | ||
d541211d | 6 | This program is free software; you can redistribute it and/or modify |
bd5635a1 | 7 | it under the terms of the GNU General Public License as published by |
d541211d PS |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | |
bd5635a1 | 10 | |
d541211d | 11 | This program is distributed in the hope that it will be useful, |
bd5635a1 RP |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
d541211d PS |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, 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 | 38 | typedef 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 *". */ | |
44 | extern struct frame_info * | |
45 | get_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 | 51 | typedef 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 |
78 | struct 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 | 100 | /* Anything extra for this structure that may have been defined |
2f03f9a6 | 101 | in the machine dependent files. */ |
bd5635a1 RP |
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 | ||
116 | struct 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 | ||
173 | extern 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 | ||
179 | extern int selected_frame_level; | |
180 | ||
181 | extern struct frame_info * | |
182 | get_prev_frame_info PARAMS ((FRAME)); | |
183 | ||
184 | extern FRAME | |
185 | create_new_frame PARAMS ((FRAME_ADDR, CORE_ADDR)); | |
186 | ||
187 | extern void | |
188 | flush_cached_frames PARAMS ((void)); | |
189 | ||
190 | extern void | |
191 | reinit_frame_cache PARAMS ((void)); | |
192 | ||
193 | extern void | |
194 | get_frame_saved_regs PARAMS ((struct frame_info *, struct frame_saved_regs *)); | |
195 | ||
196 | extern void | |
197 | set_current_frame PARAMS ((FRAME)); | |
198 | ||
199 | extern FRAME | |
200 | get_prev_frame PARAMS ((FRAME)); | |
201 | ||
202 | extern FRAME | |
203 | get_current_frame PARAMS ((void)); | |
204 | ||
205 | extern FRAME | |
206 | get_next_frame PARAMS ((FRAME)); | |
207 | ||
208 | extern struct block * | |
209 | get_frame_block PARAMS ((FRAME)); | |
210 | ||
211 | extern struct block * | |
212 | get_current_block PARAMS ((void)); | |
213 | ||
214 | extern struct block * | |
215 | get_selected_block PARAMS ((void)); | |
216 | ||
217 | extern struct symbol * | |
218 | get_frame_function PARAMS ((FRAME)); | |
219 | ||
220 | extern CORE_ADDR | |
221 | get_frame_pc PARAMS ((FRAME)); | |
222 | ||
223 | extern CORE_ADDR | |
224 | get_pc_function_start PARAMS ((CORE_ADDR)); | |
225 | ||
479fdd26 | 226 | extern struct block * block_for_pc PARAMS ((CORE_ADDR)); |
d541211d | 227 | |
479fdd26 | 228 | extern int frameless_look_for_prologue PARAMS ((FRAME)); |
d541211d | 229 | |
479fdd26 JK |
230 | extern void print_frame_args PARAMS ((struct symbol *, struct frame_info *, |
231 | int, FILE *)); | |
bd5635a1 | 232 | |
479fdd26 | 233 | extern FRAME find_relative_frame PARAMS ((FRAME, int*)); |
bd5635a1 | 234 | |
479fdd26 | 235 | extern void print_stack_frame PARAMS ((FRAME, int, int)); |
bd5635a1 | 236 | |
479fdd26 | 237 | extern void select_frame PARAMS ((FRAME, int)); |
bd5635a1 | 238 | |
479fdd26 | 239 | extern void record_selected_frame PARAMS ((FRAME_ADDR *, int *)); |
bd5635a1 | 240 | |
479fdd26 | 241 | extern void print_frame_info PARAMS ((struct frame_info *, int, int, int)); |
bd5635a1 | 242 | |
479fdd26 | 243 | extern CORE_ADDR find_saved_register PARAMS ((FRAME, int)); |
bd5635a1 | 244 | |
479fdd26 JK |
245 | extern FRAME block_innermost_frame PARAMS ((struct block *)); |
246 | ||
247 | extern CORE_ADDR sigtramp_saved_pc PARAMS ((FRAME)); | |
bd5635a1 | 248 | |
d541211d | 249 | #endif /* !defined (FRAME_H) */ |