]>
Commit | Line | Data |
---|---|---|
bd5635a1 RP |
1 | /* Variables that describe the inferior process running under GDB: |
2 | Where it is, why it stopped, and how to step it. | |
cc221e76 | 3 | Copyright 1986, 1989, 1992 Free Software Foundation, Inc. |
bd5635a1 RP |
4 | |
5 | This file is part of GDB. | |
6 | ||
bdbd5f50 | 7 | This program is free software; you can redistribute it and/or modify |
bd5635a1 | 8 | it under the terms of the GNU General Public License as published by |
bdbd5f50 JG |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | |
bd5635a1 | 11 | |
bdbd5f50 | 12 | This program is distributed in the hope that it will be useful, |
bd5635a1 RP |
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 | |
bdbd5f50 JG |
18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
bd5635a1 | 20 | |
cc221e76 FF |
21 | #if !defined (INFERIOR_H) |
22 | #define INFERIOR_H 1 | |
23 | ||
bd5635a1 RP |
24 | /* For bpstat. */ |
25 | #include "breakpoint.h" | |
26 | ||
27 | /* For FRAME_ADDR. */ | |
28 | #include "frame.h" | |
29 | ||
30 | /* | |
31 | * Structure in which to save the status of the inferior. Save | |
32 | * through "save_inferior_status", restore through | |
33 | * "restore_inferior_status". | |
34 | * This pair of routines should be called around any transfer of | |
35 | * control to the inferior which you don't want showing up in your | |
36 | * control variables. | |
37 | */ | |
38 | struct inferior_status { | |
39 | int pc_changed; | |
40 | int stop_signal; | |
41 | int stop_pc; | |
42 | FRAME_ADDR stop_frame_address; | |
43 | bpstat stop_bpstat; | |
44 | int stop_step; | |
45 | int stop_stack_dummy; | |
46 | int stopped_by_random_signal; | |
47 | int trap_expected; | |
48 | CORE_ADDR step_range_start; | |
49 | CORE_ADDR step_range_end; | |
50 | FRAME_ADDR step_frame_address; | |
51 | int step_over_calls; | |
52 | CORE_ADDR step_resume_break_address; | |
53 | int stop_after_trap; | |
54 | int stop_soon_quietly; | |
55 | FRAME_ADDR selected_frame_address; | |
56 | int selected_level; | |
57 | char stop_registers[REGISTER_BYTES]; | |
58 | int breakpoint_proceeded; | |
59 | int restore_stack_info; | |
60 | int proceed_to_finish; | |
61 | }; | |
62 | ||
cc221e76 FF |
63 | extern void |
64 | save_inferior_status PARAMS ((struct inferior_status *, int)); | |
65 | ||
66 | extern void | |
67 | restore_inferior_status PARAMS ((struct inferior_status *)); | |
bd5635a1 RP |
68 | |
69 | /* File name for default use for standard in/out in the inferior. */ | |
70 | ||
71 | extern char *inferior_io_terminal; | |
72 | ||
73 | /* Pid of our debugged inferior, or 0 if no inferior now. */ | |
74 | ||
75 | extern int inferior_pid; | |
76 | ||
77 | /* Character array containing an image of the inferior programs' registers. */ | |
78 | ||
79 | extern char registers[]; | |
80 | ||
310cc570 RP |
81 | /* Array of validity bits (one per register). Nonzero at position XXX_REGNUM |
82 | means that `registers' contains a valid copy of inferior register XXX. */ | |
83 | ||
84 | extern char register_valid[NUM_REGS]; | |
85 | ||
cc221e76 FF |
86 | extern void |
87 | clear_proceed_status PARAMS ((void)); | |
88 | ||
89 | extern void | |
90 | proceed PARAMS ((CORE_ADDR, int, int)); | |
91 | ||
92 | extern void | |
93 | kill_inferior PARAMS ((void)); | |
94 | ||
cc221e76 FF |
95 | extern void |
96 | generic_mourn_inferior PARAMS ((void)); | |
97 | ||
98 | extern void | |
99 | terminal_ours PARAMS ((void)); | |
100 | ||
101 | extern void | |
360ea8c5 | 102 | run_stack_dummy PARAMS ((char*, CORE_ADDR, char [REGISTER_BYTES])); |
cc221e76 FF |
103 | |
104 | extern CORE_ADDR | |
105 | read_pc PARAMS ((void)); | |
106 | ||
107 | extern void | |
108 | write_pc PARAMS ((CORE_ADDR)); | |
109 | ||
23a8e291 JK |
110 | extern CORE_ADDR |
111 | read_sp PARAMS ((void)); | |
112 | ||
113 | extern void | |
114 | write_sp PARAMS ((CORE_ADDR)); | |
115 | ||
116 | extern CORE_ADDR | |
117 | read_fp PARAMS ((void)); | |
118 | ||
119 | extern void | |
120 | write_fp PARAMS ((CORE_ADDR)); | |
121 | ||
cc221e76 FF |
122 | extern void |
123 | wait_for_inferior PARAMS ((void)); | |
124 | ||
125 | extern void | |
126 | init_wait_for_inferior PARAMS ((void)); | |
127 | ||
128 | extern void | |
129 | close_exec_file PARAMS ((void)); | |
130 | ||
131 | extern void | |
132 | reopen_exec_file PARAMS ((void)); | |
133 | ||
3aa6856a JG |
134 | /* The `resume' routine should only be called in special circumstances. |
135 | Normally, use `proceed', which handles a lot of bookkeeping. */ | |
310cc570 RP |
136 | extern void |
137 | resume PARAMS ((int, int)); | |
138 | ||
cc221e76 FF |
139 | /* From misc files */ |
140 | ||
141 | extern void | |
142 | store_inferior_registers PARAMS ((int)); | |
143 | ||
144 | extern void | |
145 | fetch_inferior_registers PARAMS ((int)); | |
146 | ||
147 | extern void | |
148 | solib_create_inferior_hook PARAMS ((void)); | |
149 | ||
cc221e76 FF |
150 | extern void |
151 | child_terminal_info PARAMS ((char *, int)); | |
152 | ||
153 | extern void | |
154 | term_info PARAMS ((char *, int)); | |
155 | ||
156 | extern void | |
157 | terminal_ours_for_output PARAMS ((void)); | |
158 | ||
159 | extern void | |
160 | terminal_inferior PARAMS ((void)); | |
161 | ||
162 | extern void | |
163 | terminal_init_inferior PARAMS ((void)); | |
164 | ||
34517ebc | 165 | /* From infptrace.c */ |
cc221e76 FF |
166 | |
167 | extern int | |
168 | attach PARAMS ((int)); | |
169 | ||
170 | void | |
171 | detach PARAMS ((int)); | |
172 | ||
173 | extern void | |
174 | child_resume PARAMS ((int, int)); | |
175 | ||
310cc570 RP |
176 | #ifndef PTRACE_ARG3_TYPE |
177 | #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */ | |
178 | #endif | |
179 | ||
180 | extern int | |
181 | call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int)); | |
182 | ||
cc221e76 FF |
183 | /* From procfs.c */ |
184 | ||
cc221e76 FF |
185 | extern int |
186 | proc_iterate_over_mappings PARAMS ((int (*) (int, CORE_ADDR))); | |
187 | ||
34517ebc | 188 | /* From fork-child.c */ |
bd5635a1 | 189 | |
34517ebc JG |
190 | extern void |
191 | fork_inferior PARAMS ((char *, char *, char **, | |
192 | void (*) (void), | |
193 | void (*) (int))); | |
cc221e76 FF |
194 | |
195 | /* From inflow.c */ | |
196 | ||
197 | extern void | |
198 | new_tty_prefork PARAMS ((char *)); | |
199 | ||
23a8e291 JK |
200 | extern int gdb_has_a_terminal PARAMS ((void)); |
201 | ||
cc221e76 FF |
202 | /* From infrun.c */ |
203 | ||
204 | extern void | |
205 | start_remote PARAMS ((void)); | |
206 | ||
cc221e76 FF |
207 | extern void |
208 | normal_stop PARAMS ((void)); | |
209 | ||
210 | extern int | |
211 | signal_stop_state PARAMS ((int)); | |
212 | ||
213 | extern int | |
214 | signal_print_state PARAMS ((int)); | |
215 | ||
216 | extern int | |
217 | signal_pass_state PARAMS ((int)); | |
218 | ||
219 | /* From infcmd.c */ | |
220 | ||
221 | extern void | |
222 | tty_command PARAMS ((char *, int)); | |
223 | ||
224 | extern void | |
225 | attach_command PARAMS ((char *, int)); | |
226 | ||
bd5635a1 RP |
227 | /* Last signal that the inferior received (why it stopped). */ |
228 | ||
229 | extern int stop_signal; | |
230 | ||
231 | /* Address at which inferior stopped. */ | |
232 | ||
233 | extern CORE_ADDR stop_pc; | |
234 | ||
235 | /* Stack frame when program stopped. */ | |
236 | ||
237 | extern FRAME_ADDR stop_frame_address; | |
238 | ||
239 | /* Chain containing status of breakpoint(s) that we have stopped at. */ | |
240 | ||
241 | extern bpstat stop_bpstat; | |
242 | ||
243 | /* Flag indicating that a command has proceeded the inferior past the | |
244 | current breakpoint. */ | |
245 | ||
246 | extern int breakpoint_proceeded; | |
247 | ||
248 | /* Nonzero if stopped due to a step command. */ | |
249 | ||
250 | extern int stop_step; | |
251 | ||
252 | /* Nonzero if stopped due to completion of a stack dummy routine. */ | |
253 | ||
254 | extern int stop_stack_dummy; | |
255 | ||
256 | /* Nonzero if program stopped due to a random (unexpected) signal in | |
257 | inferior process. */ | |
258 | ||
259 | extern int stopped_by_random_signal; | |
260 | ||
261 | /* Range to single step within. | |
262 | If this is nonzero, respond to a single-step signal | |
263 | by continuing to step if the pc is in this range. */ | |
264 | ||
265 | extern CORE_ADDR step_range_start; /* Inclusive */ | |
266 | extern CORE_ADDR step_range_end; /* Exclusive */ | |
267 | ||
268 | /* Stack frame address as of when stepping command was issued. | |
269 | This is how we know when we step into a subroutine call, | |
270 | and how to set the frame for the breakpoint used to step out. */ | |
271 | ||
272 | extern FRAME_ADDR step_frame_address; | |
273 | ||
274 | /* 1 means step over all subroutine calls. | |
275 | -1 means step over calls to undebuggable functions. */ | |
276 | ||
277 | extern int step_over_calls; | |
278 | ||
279 | /* If stepping, nonzero means step count is > 1 | |
280 | so don't print frame next time inferior stops | |
281 | if it stops due to stepping. */ | |
282 | ||
283 | extern int step_multi; | |
284 | ||
bdbd5f50 JG |
285 | /* Nonzero means expecting a trap and caller will handle it themselves. |
286 | It is used after attach, due to attaching to a process; | |
287 | when running in the shell before the child program has been exec'd; | |
288 | and when running some kinds of remote stuff (FIXME?). */ | |
289 | ||
cc221e76 | 290 | extern int stop_soon_quietly; |
bdbd5f50 | 291 | |
bd5635a1 RP |
292 | /* Nonzero if proceed is being used for a "finish" command or a similar |
293 | situation when stop_registers should be saved. */ | |
294 | ||
295 | extern int proceed_to_finish; | |
296 | ||
297 | /* Save register contents here when about to pop a stack dummy frame, | |
298 | if-and-only-if proceed_to_finish is set. | |
299 | Thus this contains the return value from the called function (assuming | |
300 | values are returned in a register). */ | |
301 | ||
302 | extern char stop_registers[REGISTER_BYTES]; | |
303 | ||
304 | /* Nonzero if pc has been changed by the debugger | |
305 | since the inferior stopped. */ | |
306 | ||
307 | extern int pc_changed; | |
308 | ||
309 | /* Nonzero if the child process in inferior_pid was attached rather | |
310 | than forked. */ | |
311 | ||
cc221e76 | 312 | extern int attach_flag; |
bd5635a1 | 313 | \f |
23a8e291 JK |
314 | /* Sigtramp is a routine that the kernel calls (which then calls the |
315 | signal handler). On most machines it is a library routine that | |
316 | is linked into the executable. | |
317 | ||
318 | This macro, given a program counter value and the name of the | |
319 | function in which that PC resides (which can be null if the | |
320 | name is not known), returns nonzero if the PC and name show | |
321 | that we are in sigtramp. | |
322 | ||
323 | On most machines just see if the name is sigtramp (and if we have | |
324 | no name, assume we are not in sigtramp). */ | |
325 | #if !defined (IN_SIGTRAMP) | |
326 | # if defined (SIGTRAMP_START) | |
327 | # define IN_SIGTRAMP(pc, name) \ | |
328 | ((pc) >= SIGTRAMP_START \ | |
329 | && (pc) < SIGTRAMP_END \ | |
330 | ) | |
331 | # else | |
332 | # define IN_SIGTRAMP(pc, name) \ | |
333 | (name && STREQ ("_sigtramp", name)) | |
334 | # endif | |
335 | #endif | |
336 | \f | |
bd5635a1 RP |
337 | /* Possible values for CALL_DUMMY_LOCATION. */ |
338 | #define ON_STACK 1 | |
339 | #define BEFORE_TEXT_END 2 | |
340 | #define AFTER_TEXT_END 3 | |
341 | ||
342 | #if !defined (CALL_DUMMY_LOCATION) | |
bd5635a1 | 343 | #define CALL_DUMMY_LOCATION ON_STACK |
bd5635a1 RP |
344 | #endif /* No CALL_DUMMY_LOCATION. */ |
345 | ||
346 | /* Are we in a call dummy? The code below which allows DECR_PC_AFTER_BREAK | |
347 | below is for infrun.c, which may give the macro a pc without that | |
348 | subtracted out. */ | |
349 | #if !defined (PC_IN_CALL_DUMMY) | |
350 | #if CALL_DUMMY_LOCATION == BEFORE_TEXT_END | |
cc221e76 | 351 | extern CORE_ADDR text_end; |
bd5635a1 RP |
352 | #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \ |
353 | ((pc) >= text_end - CALL_DUMMY_LENGTH \ | |
34517ebc | 354 | && (pc) <= text_end + DECR_PC_AFTER_BREAK) |
bd5635a1 RP |
355 | #else /* Not before text_end. */ |
356 | #if CALL_DUMMY_LOCATION == AFTER_TEXT_END | |
cc221e76 | 357 | extern CORE_ADDR text_end; |
bd5635a1 RP |
358 | #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \ |
359 | ((pc) >= text_end \ | |
34517ebc | 360 | && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK) |
bd5635a1 | 361 | #else /* On stack. */ |
f49cf589 | 362 | |
23a8e291 JK |
363 | /* Is the PC in a call dummy? SP and FRAME_ADDRESS are the bottom and |
364 | top of the stack frame which we are checking, where "bottom" and | |
365 | "top" refer to some section of memory which contains the code for | |
366 | the call dummy. Calls to this macro assume that the contents of | |
367 | SP_REGNUM and FP_REGNUM (or the saved values thereof), respectively, | |
368 | are the things to pass. | |
369 | ||
370 | This won't work on the 29k, where SP_REGNUM and FP_REGNUM don't | |
371 | have that meaning, but the 29k doesn't use ON_STACK. This could be | |
372 | fixed by generalizing this scheme, perhaps by passing in a frame | |
373 | and adding a few fields, at least on machines which need them for | |
374 | PC_IN_CALL_DUMMY. | |
375 | ||
376 | Something simpler, like checking for the stack segment, doesn't work, | |
377 | since various programs (threads implementations, gcc nested function | |
378 | stubs, etc) may either allocate stack frames in another segment, or | |
379 | allocate other kinds of code on the stack. */ | |
f49cf589 | 380 | |
bd5635a1 | 381 | #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \ |
f49cf589 | 382 | ((sp) INNER_THAN (pc) && (frame_address != 0) && (pc) INNER_THAN (frame_address)) |
bd5635a1 RP |
383 | #endif /* On stack. */ |
384 | #endif /* Not before text_end. */ | |
385 | #endif /* No PC_IN_CALL_DUMMY. */ | |
cc221e76 FF |
386 | |
387 | #endif /* !defined (INFERIOR_H) */ |