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