b87bca9899db1d56efe9cfbff18bd6808b85e42f
[deliverable/binutils-gdb.git] / gdb / inferior.h
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
30 /* Structure in which to save the status of the inferior. Create/Save
31 through "save_inferior_status", restore through
32 "restore_inferior_status".
33
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 #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));
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
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
99 /* Character array containing an image of the inferior programs'
100 registers. */
101
102 extern char *registers;
103
104 /* Character array containing the current state of each register
105 (unavailable<0, valid=0, invalid>0). */
106
107 extern signed char *register_valid;
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
119 extern int run_stack_dummy PARAMS ((CORE_ADDR, char*));
120
121 extern CORE_ADDR read_pc PARAMS ((void));
122
123 extern CORE_ADDR read_pc_pid PARAMS ((int));
124
125 extern CORE_ADDR generic_target_read_pc PARAMS ((int));
126
127 extern void write_pc PARAMS ((CORE_ADDR));
128
129 extern void write_pc_pid PARAMS ((CORE_ADDR, int));
130
131 extern void generic_target_write_pc PARAMS ((CORE_ADDR, int));
132
133 extern CORE_ADDR read_sp PARAMS ((void));
134
135 extern CORE_ADDR generic_target_read_sp PARAMS ((void));
136
137 extern void write_sp PARAMS ((CORE_ADDR));
138
139 extern void generic_target_write_sp PARAMS ((CORE_ADDR));
140
141 extern CORE_ADDR read_fp PARAMS ((void));
142
143 extern CORE_ADDR generic_target_read_fp PARAMS ((void));
144
145 extern void write_fp PARAMS ((CORE_ADDR));
146
147 extern void generic_target_write_fp PARAMS ((CORE_ADDR));
148
149 extern void wait_for_inferior PARAMS ((void));
150
151 extern void init_wait_for_inferior PARAMS ((void));
152
153 extern void close_exec_file PARAMS ((void));
154
155 extern void reopen_exec_file PARAMS ((void));
156
157 /* The `resume' routine should only be called in special circumstances.
158 Normally, use `proceed', which handles a lot of bookkeeping. */
159
160 extern void resume PARAMS ((int, enum target_signal));
161
162 /* From misc files */
163
164 extern void store_inferior_registers PARAMS ((int));
165
166 extern void fetch_inferior_registers PARAMS ((int));
167
168 extern void solib_create_inferior_hook PARAMS ((void));
169
170 extern void child_terminal_info PARAMS ((char *, int));
171
172 extern void term_info PARAMS ((char *, int));
173
174 extern void terminal_ours_for_output PARAMS ((void));
175
176 extern void terminal_inferior PARAMS ((void));
177
178 extern void terminal_init_inferior PARAMS ((void));
179
180 extern void terminal_init_inferior_with_pgrp PARAMS ((int pgrp));
181
182 /* From infptrace.c or infttrace.c */
183
184 extern int attach PARAMS ((int));
185
186 #if !defined(REQUIRE_ATTACH)
187 #define REQUIRE_ATTACH attach
188 #endif
189
190 #if !defined(REQUIRE_DETACH)
191 #define REQUIRE_DETACH(pid,siggnal) detach (siggnal)
192 #endif
193
194 extern void detach PARAMS ((int));
195
196 /* PTRACE method of waiting for inferior process. */
197 int ptrace_wait PARAMS ((int, int *));
198
199 extern void child_resume PARAMS ((int, int, enum target_signal));
200
201 #ifndef PTRACE_ARG3_TYPE
202 #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
203 #endif
204
205 extern int call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int));
206
207 extern void pre_fork_inferior PARAMS ((void));
208
209 /* From procfs.c */
210
211 extern int proc_iterate_over_mappings PARAMS ((int (*)(int, CORE_ADDR)));
212
213 extern int procfs_first_available PARAMS ((void));
214
215 extern int procfs_get_pid_fd PARAMS ((int));
216
217 /* From fork-child.c */
218
219 extern void fork_inferior PARAMS ((char *, char *, char **,
220 void (*)(void),
221 void (*)(int),
222 void (*)(void),
223 char *));
224
225
226 extern void
227 clone_and_follow_inferior PARAMS ((int, int *));
228
229 extern void startup_inferior PARAMS ((int));
230
231 /* From inflow.c */
232
233 extern void new_tty_prefork PARAMS ((char *));
234
235 extern int gdb_has_a_terminal PARAMS ((void));
236
237 /* From infrun.c */
238
239 extern void start_remote PARAMS ((void));
240
241 extern void normal_stop PARAMS ((void));
242
243 extern int signal_stop_state PARAMS ((int));
244
245 extern int signal_print_state PARAMS ((int));
246
247 extern int signal_pass_state PARAMS ((int));
248
249 /* From infcmd.c */
250
251 extern void tty_command PARAMS ((char *, int));
252
253 extern void attach_command PARAMS ((char *, int));
254
255 /* Last signal that the inferior received (why it stopped). */
256
257 extern enum target_signal stop_signal;
258
259 /* Address at which inferior stopped. */
260
261 extern CORE_ADDR stop_pc;
262
263 /* Chain containing status of breakpoint(s) that we have stopped at. */
264
265 extern bpstat stop_bpstat;
266
267 /* Flag indicating that a command has proceeded the inferior past the
268 current breakpoint. */
269
270 extern int breakpoint_proceeded;
271
272 /* Nonzero if stopped due to a step command. */
273
274 extern int stop_step;
275
276 /* Nonzero if stopped due to completion of a stack dummy routine. */
277
278 extern int stop_stack_dummy;
279
280 /* Nonzero if program stopped due to a random (unexpected) signal in
281 inferior process. */
282
283 extern int stopped_by_random_signal;
284
285 /* Range to single step within.
286 If this is nonzero, respond to a single-step signal
287 by continuing to step if the pc is in this range.
288
289 If step_range_start and step_range_end are both 1, it means to step for
290 a single instruction (FIXME: it might clean up wait_for_inferior in a
291 minor way if this were changed to the address of the instruction and
292 that address plus one. But maybe not.). */
293
294 extern CORE_ADDR step_range_start; /* Inclusive */
295 extern CORE_ADDR step_range_end;/* Exclusive */
296
297 /* Stack frame address as of when stepping command was issued.
298 This is how we know when we step into a subroutine call,
299 and how to set the frame for the breakpoint used to step out. */
300
301 extern CORE_ADDR step_frame_address;
302
303 /* Our notion of the current stack pointer. */
304
305 extern CORE_ADDR step_sp;
306
307 /* 1 means step over all subroutine calls.
308 -1 means step over calls to undebuggable functions. */
309
310 extern int step_over_calls;
311
312 /* If stepping, nonzero means step count is > 1
313 so don't print frame next time inferior stops
314 if it stops due to stepping. */
315
316 extern int step_multi;
317
318 /* Nonzero means expecting a trap and caller will handle it themselves.
319 It is used after attach, due to attaching to a process;
320 when running in the shell before the child program has been exec'd;
321 and when running some kinds of remote stuff (FIXME?). */
322
323 extern int stop_soon_quietly;
324
325 /* Nonzero if proceed is being used for a "finish" command or a similar
326 situation when stop_registers should be saved. */
327
328 extern int proceed_to_finish;
329
330 /* Save register contents here when about to pop a stack dummy frame,
331 if-and-only-if proceed_to_finish is set.
332 Thus this contains the return value from the called function (assuming
333 values are returned in a register). */
334
335 extern char *stop_registers;
336
337 /* Nonzero if the child process in inferior_pid was attached rather
338 than forked. */
339
340 extern int attach_flag;
341 \f
342 /* Sigtramp is a routine that the kernel calls (which then calls the
343 signal handler). On most machines it is a library routine that
344 is linked into the executable.
345
346 This macro, given a program counter value and the name of the
347 function in which that PC resides (which can be null if the
348 name is not known), returns nonzero if the PC and name show
349 that we are in sigtramp.
350
351 On most machines just see if the name is sigtramp (and if we have
352 no name, assume we are not in sigtramp). */
353 #if !defined (IN_SIGTRAMP)
354 #if defined (SIGTRAMP_START)
355 #define IN_SIGTRAMP(pc, name) \
356 ((pc) >= SIGTRAMP_START(pc) \
357 && (pc) < SIGTRAMP_END(pc) \
358 )
359 #else
360 #define IN_SIGTRAMP(pc, name) \
361 (name && STREQ ("_sigtramp", name))
362 #endif
363 #endif
364 \f
365 /* Possible values for CALL_DUMMY_LOCATION. */
366 #define ON_STACK 1
367 #define BEFORE_TEXT_END 2
368 #define AFTER_TEXT_END 3
369 #define AT_ENTRY_POINT 4
370
371 #if !defined (USE_GENERIC_DUMMY_FRAMES)
372 #define USE_GENERIC_DUMMY_FRAMES 0
373 #endif
374
375 #if !defined (CALL_DUMMY_LOCATION)
376 #define CALL_DUMMY_LOCATION ON_STACK
377 #endif /* No CALL_DUMMY_LOCATION. */
378
379 #if !defined (CALL_DUMMY_ADDRESS)
380 #define CALL_DUMMY_ADDRESS() (abort (), 0) /* anything to abort GDB */
381 #endif
382 #if !defined (CALL_DUMMY_START_OFFSET)
383 #define CALL_DUMMY_START_OFFSET (abort (), 0) /* anything to abort GDB */
384 #endif
385 #if !defined (CALL_DUMMY_BREAKPOINT_OFFSET)
386 #define CALL_DUMMY_BREAKPOINT_OFFSET_P (0)
387 #define CALL_DUMMY_BREAKPOINT_OFFSET (abort (), 0) /* anything to abort GDB */
388 #endif
389 #if !defined CALL_DUMMY_BREAKPOINT_OFFSET_P
390 #define CALL_DUMMY_BREAKPOINT_OFFSET_P (1)
391 #endif
392 #if !defined (CALL_DUMMY_LENGTH)
393 #define CALL_DUMMY_LENGTH (abort (), 0) /* anything to abort GDB */
394 #endif
395
396 #if defined (CALL_DUMMY_STACK_ADJUST)
397 #if !defined (CALL_DUMMY_STACK_ADJUST_P)
398 #define CALL_DUMMY_STACK_ADJUST_P (1)
399 #endif
400 #endif
401 #if !defined (CALL_DUMMY_STACK_ADJUST)
402 #define CALL_DUMMY_STACK_ADJUST (abort (), 0)
403 #endif
404 #if !defined (CALL_DUMMY_STACK_ADJUST_P)
405 #define CALL_DUMMY_STACK_ADJUST_P (0)
406 #endif
407
408 #if !defined (CALL_DUMMY_P)
409 #if defined (CALL_DUMMY)
410 #define CALL_DUMMY_P 1
411 #else
412 #define CALL_DUMMY_P 0
413 #endif
414 #endif
415
416 #if !defined (CALL_DUMMY_WORDS)
417 #if defined (CALL_DUMMY)
418 extern LONGEST call_dummy_words[];
419 #define CALL_DUMMY_WORDS (call_dummy_words)
420 #else
421 #define CALL_DUMMY_WORDS (abort (), (void*) 0) /* anything to abort GDB */
422 #endif
423 #endif
424
425 #if !defined (SIZEOF_CALL_DUMMY_WORDS)
426 #if defined (CALL_DUMMY)
427 extern int sizeof_call_dummy_words;
428 #define SIZEOF_CALL_DUMMY_WORDS (sizeof_call_dummy_words)
429 #else
430 #define SIZEOF_CALL_DUMMY_WORDS (abort (), 0) /* anything to abort GDB */
431 #endif
432 #endif
433
434 #if !defined PUSH_DUMMY_FRAME
435 #define PUSH_DUMMY_FRAME (abort ())
436 #endif
437
438 #if !defined FIX_CALL_DUMMY
439 #define FIX_CALL_DUMMY(a1,a2,a3,a4,a5,a6,a7) (abort ())
440 #endif
441
442 #if !defined STORE_STRUCT_RETURN
443 #define STORE_STRUCT_RETURN(a1,a2) (abort ())
444 #endif
445
446
447 /* Are we in a call dummy? */
448
449 extern int pc_in_call_dummy_before_text_end PARAMS ((CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address));
450 #if !GDB_MULTI_ARCH
451 #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == BEFORE_TEXT_END
452 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_before_text_end (pc, sp, frame_address)
453 #endif /* Before text_end. */
454 #endif
455
456 extern int pc_in_call_dummy_after_text_end PARAMS ((CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address));
457 #if !GDB_MULTI_ARCH
458 #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == AFTER_TEXT_END
459 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_after_text_end (pc, sp, frame_address)
460 #endif
461 #endif
462
463 extern int pc_in_call_dummy_on_stack PARAMS ((CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address));
464 #if !GDB_MULTI_ARCH
465 #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == ON_STACK
466 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_on_stack (pc, sp, frame_address)
467 #endif
468 #endif
469
470 extern int pc_in_call_dummy_at_entry_point PARAMS ((CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address));
471 #if !GDB_MULTI_ARCH
472 #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == AT_ENTRY_POINT
473 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_at_entry_point (pc, sp, frame_address)
474 #endif
475 #endif
476
477 /* It's often not enough for our clients to know whether the PC is merely
478 somewhere within the call dummy. They may need to know whether the
479 call dummy has actually completed. (For example, wait_for_inferior
480 wants to know when it should truly stop because the call dummy has
481 completed. If we're single-stepping because of slow watchpoints,
482 then we may find ourselves stopped at the entry of the call dummy,
483 and want to continue stepping until we reach the end.)
484
485 Note that this macro is intended for targets (like HP-UX) which
486 require more than a single breakpoint in their call dummies, and
487 therefore cannot use the CALL_DUMMY_BREAKPOINT_OFFSET mechanism.
488
489 If a target does define CALL_DUMMY_BREAKPOINT_OFFSET, then this
490 default implementation of CALL_DUMMY_HAS_COMPLETED is sufficient.
491 Else, a target may wish to supply an implementation that works in
492 the presense of multiple breakpoints in its call dummy.
493 */
494 #if !defined(CALL_DUMMY_HAS_COMPLETED)
495 #define CALL_DUMMY_HAS_COMPLETED(pc, sp, frame_address) \
496 PC_IN_CALL_DUMMY((pc), (sp), (frame_address))
497 #endif
498
499 /* If STARTUP_WITH_SHELL is set, GDB's "run"
500 will attempts to start up the debugee under a shell.
501 This is in order for argument-expansion to occur. E.g.,
502 (gdb) run *
503 The "*" gets expanded by the shell into a list of files.
504 While this is a nice feature, it turns out to interact badly
505 with some of the catch-fork/catch-exec features we have added.
506 In particular, if the shell does any fork/exec's before
507 the exec of the target program, that can confuse GDB.
508 To disable this feature, set STARTUP_WITH_SHELL to 0.
509 To enable this feature, set STARTUP_WITH_SHELL to 1.
510 The catch-exec traps expected during start-up will
511 be 1 if target is not started up with a shell, 2 if it is.
512 - RT
513 If you disable this, you need to decrement
514 START_INFERIOR_TRAPS_EXPECTED in tm.h. */
515 #define STARTUP_WITH_SHELL 1
516 #if !defined(START_INFERIOR_TRAPS_EXPECTED)
517 #define START_INFERIOR_TRAPS_EXPECTED 2
518 #endif
519 #endif /* !defined (INFERIOR_H) */
This page took 0.041176 seconds and 4 git commands to generate.