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