]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* Variables that describe the inferior process running under GDB: |
2 | Where it is, why it stopped, and how to step it. | |
3 | Copyright 1986, 1989, 1992, 1996, 1998 Free Software Foundation, Inc. | |
4 | ||
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
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 | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | #if !defined (INFERIOR_H) | |
22 | #define INFERIOR_H 1 | |
23 | ||
24 | /* For bpstat. */ | |
25 | #include "breakpoint.h" | |
26 | ||
27 | /* For enum target_signal. */ | |
28 | #include "target.h" | |
29 | ||
7a292a7a | 30 | /* Structure in which to save the status of the inferior. Create/Save |
c906108c SS |
31 | through "save_inferior_status", restore through |
32 | "restore_inferior_status". | |
7a292a7a | 33 | |
c906108c SS |
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 | ||
7a292a7a SS |
38 | #ifdef __STDC__ |
39 | struct inferior_status; | |
40 | #endif | |
41 | ||
42 | extern struct inferior_status *save_inferior_status PARAMS ((int)); | |
43 | ||
44 | extern void restore_inferior_status PARAMS ((struct inferior_status *)); | |
45 | ||
46 | extern void discard_inferior_status PARAMS ((struct inferior_status *)); | |
47 | ||
48 | extern void write_inferior_status_register PARAMS ((struct inferior_status *inf_status, int regno, LONGEST val)); | |
c906108c SS |
49 | |
50 | /* This macro gives the number of registers actually in use by the | |
51 | inferior. This may be less than the total number of registers, | |
52 | perhaps depending on the actual CPU in use or program being run. */ | |
53 | ||
54 | #ifndef ARCH_NUM_REGS | |
55 | #define ARCH_NUM_REGS NUM_REGS | |
56 | #endif | |
57 | ||
c906108c SS |
58 | extern void set_sigint_trap PARAMS ((void)); |
59 | ||
60 | extern void clear_sigint_trap PARAMS ((void)); | |
61 | ||
62 | extern void set_sigio_trap PARAMS ((void)); | |
63 | ||
64 | extern void clear_sigio_trap PARAMS ((void)); | |
65 | ||
66 | /* File name for default use for standard in/out in the inferior. */ | |
67 | ||
68 | extern char *inferior_io_terminal; | |
69 | ||
70 | /* Pid of our debugged inferior, or 0 if no inferior now. */ | |
71 | ||
72 | extern int inferior_pid; | |
73 | ||
74 | /* This is only valid when inferior_pid is non-zero. | |
75 | ||
76 | If this is 0, then exec events should be noticed and responded to | |
77 | by the debugger (i.e., be reported to the user). | |
78 | ||
79 | If this is > 0, then that many subsequent exec events should be | |
80 | ignored (i.e., not be reported to the user). | |
81 | */ | |
82 | extern int inferior_ignoring_startup_exec_events; | |
83 | ||
84 | /* This is only valid when inferior_ignoring_startup_exec_events is | |
85 | zero. | |
86 | ||
87 | Some targets (stupidly) report more than one exec event per actual | |
88 | call to an event() system call. If only the last such exec event | |
89 | need actually be noticed and responded to by the debugger (i.e., | |
90 | be reported to the user), then this is the number of "leading" | |
91 | exec events which should be ignored. | |
92 | */ | |
93 | extern int inferior_ignoring_leading_exec_events; | |
94 | ||
95 | /* Inferior environment. */ | |
96 | ||
97 | extern struct environ *inferior_environ; | |
98 | ||
7a292a7a SS |
99 | /* Character array containing an image of the inferior programs' |
100 | registers. */ | |
c906108c | 101 | |
7a292a7a | 102 | extern char *registers; |
c906108c | 103 | |
7a292a7a SS |
104 | /* Character array containing the current state of each register |
105 | (unavailable<0, valid=0, invalid>0). */ | |
c906108c | 106 | |
7a292a7a | 107 | extern signed char *register_valid; |
c906108c SS |
108 | |
109 | extern void clear_proceed_status PARAMS ((void)); | |
110 | ||
111 | extern void proceed PARAMS ((CORE_ADDR, enum target_signal, int)); | |
112 | ||
113 | extern void kill_inferior PARAMS ((void)); | |
114 | ||
115 | extern void generic_mourn_inferior PARAMS ((void)); | |
116 | ||
117 | extern void terminal_ours PARAMS ((void)); | |
118 | ||
7a292a7a | 119 | extern int run_stack_dummy PARAMS ((CORE_ADDR, char*)); |
c906108c SS |
120 | |
121 | extern CORE_ADDR read_pc PARAMS ((void)); | |
122 | ||
123 | extern CORE_ADDR read_pc_pid PARAMS ((int)); | |
124 | ||
125 | extern void write_pc PARAMS ((CORE_ADDR)); | |
126 | ||
127 | extern void write_pc_pid PARAMS ((CORE_ADDR, int)); | |
128 | ||
129 | extern CORE_ADDR read_sp PARAMS ((void)); | |
130 | ||
131 | extern void write_sp PARAMS ((CORE_ADDR)); | |
132 | ||
133 | extern CORE_ADDR read_fp PARAMS ((void)); | |
134 | ||
135 | extern void write_fp PARAMS ((CORE_ADDR)); | |
136 | ||
137 | extern void wait_for_inferior PARAMS ((void)); | |
138 | ||
139 | extern void init_wait_for_inferior PARAMS ((void)); | |
140 | ||
141 | extern void close_exec_file PARAMS ((void)); | |
142 | ||
143 | extern void reopen_exec_file PARAMS ((void)); | |
144 | ||
145 | /* The `resume' routine should only be called in special circumstances. | |
146 | Normally, use `proceed', which handles a lot of bookkeeping. */ | |
147 | ||
148 | extern void resume PARAMS ((int, enum target_signal)); | |
149 | ||
150 | /* From misc files */ | |
151 | ||
152 | extern void store_inferior_registers PARAMS ((int)); | |
153 | ||
154 | extern void fetch_inferior_registers PARAMS ((int)); | |
155 | ||
156 | extern void solib_create_inferior_hook PARAMS ((void)); | |
157 | ||
158 | extern void child_terminal_info PARAMS ((char *, int)); | |
159 | ||
160 | extern void term_info PARAMS ((char *, int)); | |
161 | ||
162 | extern void terminal_ours_for_output PARAMS ((void)); | |
163 | ||
164 | extern void terminal_inferior PARAMS ((void)); | |
165 | ||
166 | extern void terminal_init_inferior PARAMS ((void)); | |
167 | ||
168 | extern void terminal_init_inferior_with_pgrp PARAMS ((int pgrp)); | |
169 | ||
170 | /* From infptrace.c or infttrace.c */ | |
171 | ||
172 | extern int attach PARAMS ((int)); | |
173 | ||
174 | #if !defined(REQUIRE_ATTACH) | |
175 | #define REQUIRE_ATTACH attach | |
176 | #endif | |
177 | ||
178 | #if !defined(REQUIRE_DETACH) | |
179 | #define REQUIRE_DETACH(pid,siggnal) detach (siggnal) | |
180 | #endif | |
181 | ||
182 | extern void detach PARAMS ((int)); | |
183 | ||
7a292a7a | 184 | /* PTRACE method of waiting for inferior process. */ |
c906108c SS |
185 | int ptrace_wait PARAMS ((int, int *)); |
186 | ||
187 | extern void child_resume PARAMS ((int, int, enum target_signal)); | |
188 | ||
189 | #ifndef PTRACE_ARG3_TYPE | |
190 | #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */ | |
191 | #endif | |
192 | ||
193 | extern int call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int)); | |
194 | ||
195 | extern void pre_fork_inferior PARAMS ((void)); | |
196 | ||
197 | /* From procfs.c */ | |
198 | ||
199 | extern int proc_iterate_over_mappings PARAMS ((int (*)(int, CORE_ADDR))); | |
200 | ||
201 | extern int procfs_first_available PARAMS ((void)); | |
202 | ||
203 | extern int procfs_get_pid_fd PARAMS ((int)); | |
204 | ||
205 | /* From fork-child.c */ | |
206 | ||
207 | extern void fork_inferior PARAMS ((char *, char *, char **, | |
208 | void (*)(void), | |
209 | void (*)(int), | |
210 | void (*)(void), | |
211 | char *)); | |
212 | ||
213 | ||
214 | extern void | |
215 | clone_and_follow_inferior PARAMS ((int, int *)); | |
216 | ||
217 | extern void startup_inferior PARAMS ((int)); | |
218 | ||
219 | /* From inflow.c */ | |
220 | ||
221 | extern void new_tty_prefork PARAMS ((char *)); | |
222 | ||
223 | extern int gdb_has_a_terminal PARAMS ((void)); | |
224 | ||
225 | /* From infrun.c */ | |
226 | ||
227 | extern void start_remote PARAMS ((void)); | |
228 | ||
229 | extern void normal_stop PARAMS ((void)); | |
230 | ||
231 | extern int signal_stop_state PARAMS ((int)); | |
232 | ||
233 | extern int signal_print_state PARAMS ((int)); | |
234 | ||
235 | extern int signal_pass_state PARAMS ((int)); | |
236 | ||
237 | /* From infcmd.c */ | |
238 | ||
239 | extern void tty_command PARAMS ((char *, int)); | |
240 | ||
241 | extern void attach_command PARAMS ((char *, int)); | |
242 | ||
243 | /* Last signal that the inferior received (why it stopped). */ | |
244 | ||
245 | extern enum target_signal stop_signal; | |
246 | ||
247 | /* Address at which inferior stopped. */ | |
248 | ||
249 | extern CORE_ADDR stop_pc; | |
250 | ||
251 | /* Chain containing status of breakpoint(s) that we have stopped at. */ | |
252 | ||
253 | extern bpstat stop_bpstat; | |
254 | ||
255 | /* Flag indicating that a command has proceeded the inferior past the | |
256 | current breakpoint. */ | |
257 | ||
258 | extern int breakpoint_proceeded; | |
259 | ||
260 | /* Nonzero if stopped due to a step command. */ | |
261 | ||
262 | extern int stop_step; | |
263 | ||
264 | /* Nonzero if stopped due to completion of a stack dummy routine. */ | |
265 | ||
266 | extern int stop_stack_dummy; | |
267 | ||
268 | /* Nonzero if program stopped due to a random (unexpected) signal in | |
269 | inferior process. */ | |
270 | ||
271 | extern int stopped_by_random_signal; | |
272 | ||
273 | /* Range to single step within. | |
274 | If this is nonzero, respond to a single-step signal | |
275 | by continuing to step if the pc is in this range. | |
276 | ||
277 | If step_range_start and step_range_end are both 1, it means to step for | |
278 | a single instruction (FIXME: it might clean up wait_for_inferior in a | |
279 | minor way if this were changed to the address of the instruction and | |
280 | that address plus one. But maybe not.). */ | |
281 | ||
282 | extern CORE_ADDR step_range_start; /* Inclusive */ | |
283 | extern CORE_ADDR step_range_end;/* Exclusive */ | |
284 | ||
285 | /* Stack frame address as of when stepping command was issued. | |
286 | This is how we know when we step into a subroutine call, | |
287 | and how to set the frame for the breakpoint used to step out. */ | |
288 | ||
289 | extern CORE_ADDR step_frame_address; | |
290 | ||
291 | /* Our notion of the current stack pointer. */ | |
292 | ||
293 | extern CORE_ADDR step_sp; | |
294 | ||
295 | /* 1 means step over all subroutine calls. | |
296 | -1 means step over calls to undebuggable functions. */ | |
297 | ||
298 | extern int step_over_calls; | |
299 | ||
300 | /* If stepping, nonzero means step count is > 1 | |
301 | so don't print frame next time inferior stops | |
302 | if it stops due to stepping. */ | |
303 | ||
304 | extern int step_multi; | |
305 | ||
306 | /* Nonzero means expecting a trap and caller will handle it themselves. | |
307 | It is used after attach, due to attaching to a process; | |
308 | when running in the shell before the child program has been exec'd; | |
309 | and when running some kinds of remote stuff (FIXME?). */ | |
310 | ||
311 | extern int stop_soon_quietly; | |
312 | ||
313 | /* Nonzero if proceed is being used for a "finish" command or a similar | |
314 | situation when stop_registers should be saved. */ | |
315 | ||
316 | extern int proceed_to_finish; | |
317 | ||
318 | /* Save register contents here when about to pop a stack dummy frame, | |
319 | if-and-only-if proceed_to_finish is set. | |
320 | Thus this contains the return value from the called function (assuming | |
321 | values are returned in a register). */ | |
322 | ||
7a292a7a | 323 | extern char *stop_registers; |
c906108c SS |
324 | |
325 | /* Nonzero if the child process in inferior_pid was attached rather | |
326 | than forked. */ | |
327 | ||
328 | extern int attach_flag; | |
329 | \f | |
330 | /* Sigtramp is a routine that the kernel calls (which then calls the | |
331 | signal handler). On most machines it is a library routine that | |
332 | is linked into the executable. | |
333 | ||
334 | This macro, given a program counter value and the name of the | |
335 | function in which that PC resides (which can be null if the | |
336 | name is not known), returns nonzero if the PC and name show | |
337 | that we are in sigtramp. | |
338 | ||
339 | On most machines just see if the name is sigtramp (and if we have | |
340 | no name, assume we are not in sigtramp). */ | |
341 | #if !defined (IN_SIGTRAMP) | |
342 | #if defined (SIGTRAMP_START) | |
343 | #define IN_SIGTRAMP(pc, name) \ | |
344 | ((pc) >= SIGTRAMP_START(pc) \ | |
345 | && (pc) < SIGTRAMP_END(pc) \ | |
346 | ) | |
347 | #else | |
348 | #define IN_SIGTRAMP(pc, name) \ | |
349 | (name && STREQ ("_sigtramp", name)) | |
350 | #endif | |
351 | #endif | |
352 | \f | |
353 | /* Possible values for CALL_DUMMY_LOCATION. */ | |
354 | #define ON_STACK 1 | |
355 | #define BEFORE_TEXT_END 2 | |
356 | #define AFTER_TEXT_END 3 | |
357 | #define AT_ENTRY_POINT 4 | |
358 | ||
7a292a7a SS |
359 | #if !defined (USE_GENERIC_DUMMY_FRAMES) |
360 | #define USE_GENERIC_DUMMY_FRAMES 0 | |
361 | #endif | |
362 | ||
c906108c SS |
363 | #if !defined (CALL_DUMMY_LOCATION) |
364 | #define CALL_DUMMY_LOCATION ON_STACK | |
365 | #endif /* No CALL_DUMMY_LOCATION. */ | |
366 | ||
7a292a7a SS |
367 | #if !defined (CALL_DUMMY_ADDRESS) |
368 | #define CALL_DUMMY_ADDRESS() (abort (), 0) /* anything to abort GDB */ | |
369 | #endif | |
370 | #if !defined (CALL_DUMMY_START_OFFSET) | |
371 | #define CALL_DUMMY_START_OFFSET (abort (), 0) /* anything to abort GDB */ | |
372 | #endif | |
373 | #if !defined (CALL_DUMMY_BREAKPOINT_OFFSET) | |
374 | #define CALL_DUMMY_BREAKPOINT_OFFSET_P (0) | |
375 | #define CALL_DUMMY_BREAKPOINT_OFFSET (abort (), 0) /* anything to abort GDB */ | |
376 | #endif | |
377 | #if !defined CALL_DUMMY_BREAKPOINT_OFFSET_P | |
378 | #define CALL_DUMMY_BREAKPOINT_OFFSET_P (1) | |
379 | #endif | |
380 | #if !defined (CALL_DUMMY_LENGTH) | |
381 | #define CALL_DUMMY_LENGTH (abort (), 0) /* anything to abort GDB */ | |
382 | #endif | |
383 | ||
384 | #if defined (CALL_DUMMY_STACK_ADJUST) | |
385 | #if !defined (CALL_DUMMY_STACK_ADJUST_P) | |
386 | #define CALL_DUMMY_STACK_ADJUST_P (1) | |
387 | #endif | |
388 | #endif | |
389 | #if !defined (CALL_DUMMY_STACK_ADJUST) | |
390 | #define CALL_DUMMY_STACK_ADJUST (abort (), 0) | |
391 | #endif | |
392 | #if !defined (CALL_DUMMY_STACK_ADJUST_P) | |
393 | #define CALL_DUMMY_STACK_ADJUST_P (0) | |
394 | #endif | |
395 | ||
396 | #if !defined (CALL_DUMMY_P) | |
397 | #if defined (CALL_DUMMY) | |
398 | #define CALL_DUMMY_P 1 | |
399 | #else | |
400 | #define CALL_DUMMY_P 0 | |
401 | #endif | |
402 | #endif | |
403 | ||
404 | #if !defined (CALL_DUMMY_WORDS) | |
405 | #if defined (CALL_DUMMY) | |
406 | extern LONGEST call_dummy_words[]; | |
407 | #define CALL_DUMMY_WORDS (call_dummy_words) | |
408 | #else | |
409 | #define CALL_DUMMY_WORDS (abort (), (void*) 0) /* anything to abort GDB */ | |
410 | #endif | |
411 | #endif | |
412 | ||
413 | #if !defined (SIZEOF_CALL_DUMMY_WORDS) | |
414 | #if defined (CALL_DUMMY) | |
415 | extern int sizeof_call_dummy_words; | |
416 | #define SIZEOF_CALL_DUMMY_WORDS (sizeof_call_dummy_words) | |
417 | #else | |
418 | #define SIZEOF_CALL_DUMMY_WORDS (abort (), 0) /* anything to abort GDB */ | |
419 | #endif | |
420 | #endif | |
421 | ||
422 | #if !defined PUSH_DUMMY_FRAME | |
423 | #define PUSH_DUMMY_FRAME (abort ()) | |
424 | #endif | |
425 | ||
426 | #if !defined FIX_CALL_DUMMY | |
427 | #define FIX_CALL_DUMMY(a1,a2,a3,a4,a5,a6,a7) (abort ()) | |
428 | #endif | |
429 | ||
430 | #if !defined STORE_STRUCT_RETURN | |
431 | #define STORE_STRUCT_RETURN(a1,a2) (abort ()) | |
432 | #endif | |
433 | ||
434 | ||
435 | /* Are we in a call dummy? */ | |
436 | ||
437 | extern int pc_in_call_dummy_before_text_end PARAMS ((CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address)); | |
438 | #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == BEFORE_TEXT_END | |
439 | #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_before_text_end (pc, sp, frame_address) | |
c906108c SS |
440 | #endif /* Before text_end. */ |
441 | ||
7a292a7a SS |
442 | extern int pc_in_call_dummy_after_text_end PARAMS ((CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address)); |
443 | #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == AFTER_TEXT_END | |
444 | #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_after_text_end (pc, sp, frame_address) | |
445 | #endif | |
446 | ||
447 | extern int pc_in_call_dummy_on_stack PARAMS ((CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address)); | |
448 | #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == ON_STACK | |
449 | #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_on_stack (pc, sp, frame_address) | |
450 | #endif | |
451 | ||
452 | extern int pc_in_call_dummy_at_entry_point PARAMS ((CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address)); | |
453 | #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == AT_ENTRY_POINT | |
454 | #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_at_entry_point (pc, sp, frame_address) | |
455 | #endif | |
c906108c SS |
456 | |
457 | /* It's often not enough for our clients to know whether the PC is merely | |
458 | somewhere within the call dummy. They may need to know whether the | |
459 | call dummy has actually completed. (For example, wait_for_inferior | |
460 | wants to know when it should truly stop because the call dummy has | |
461 | completed. If we're single-stepping because of slow watchpoints, | |
462 | then we may find ourselves stopped at the entry of the call dummy, | |
463 | and want to continue stepping until we reach the end.) | |
464 | ||
465 | Note that this macro is intended for targets (like HP-UX) which | |
466 | require more than a single breakpoint in their call dummies, and | |
467 | therefore cannot use the CALL_DUMMY_BREAKPOINT_OFFSET mechanism. | |
468 | ||
469 | If a target does define CALL_DUMMY_BREAKPOINT_OFFSET, then this | |
470 | default implementation of CALL_DUMMY_HAS_COMPLETED is sufficient. | |
471 | Else, a target may wish to supply an implementation that works in | |
472 | the presense of multiple breakpoints in its call dummy. | |
473 | */ | |
474 | #if !defined(CALL_DUMMY_HAS_COMPLETED) | |
475 | #define CALL_DUMMY_HAS_COMPLETED(pc, sp, frame_address) \ | |
476 | PC_IN_CALL_DUMMY((pc), (sp), (frame_address)) | |
477 | #endif | |
478 | ||
479 | /* If STARTUP_WITH_SHELL is set, GDB's "run" | |
480 | will attempts to start up the debugee under a shell. | |
481 | This is in order for argument-expansion to occur. E.g., | |
482 | (gdb) run * | |
483 | The "*" gets expanded by the shell into a list of files. | |
484 | While this is a nice feature, it turns out to interact badly | |
485 | with some of the catch-fork/catch-exec features we have added. | |
486 | In particular, if the shell does any fork/exec's before | |
487 | the exec of the target program, that can confuse GDB. | |
488 | To disable this feature, set STARTUP_WITH_SHELL to 0. | |
489 | To enable this feature, set STARTUP_WITH_SHELL to 1. | |
490 | The catch-exec traps expected during start-up will | |
491 | be 1 if target is not started up with a shell, 2 if it is. | |
492 | - RT | |
493 | If you disable this, you need to decrement | |
494 | START_INFERIOR_TRAPS_EXPECTED in tm.h. */ | |
495 | #define STARTUP_WITH_SHELL 1 | |
496 | #if !defined(START_INFERIOR_TRAPS_EXPECTED) | |
497 | #define START_INFERIOR_TRAPS_EXPECTED 2 | |
498 | #endif | |
499 | #endif /* !defined (INFERIOR_H) */ |