* Fix for PR 18665, from sky branch.
[binutils-gdb.git] / gdb / inferior.h
blob5b72c921a1b79b06094531dbb182413d4dc1e20f
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.
5 This file is part of GDB.
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.
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.
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. */
21 #if !defined (INFERIOR_H)
22 #define INFERIOR_H 1
24 /* For bpstat. */
25 #include "breakpoint.h"
27 /* For enum target_signal. */
28 #include "target.h"
30 /* Structure in which to save the status of the inferior. Save
31 through "save_inferior_status", restore through
32 "restore_inferior_status".
33 This pair of routines should be called around any transfer of
34 control to the inferior which you don't want showing up in your
35 control variables. */
37 struct inferior_status {
38 enum target_signal stop_signal;
39 CORE_ADDR stop_pc;
40 bpstat stop_bpstat;
41 int stop_step;
42 int stop_stack_dummy;
43 int stopped_by_random_signal;
44 int trap_expected;
45 CORE_ADDR step_range_start;
46 CORE_ADDR step_range_end;
47 CORE_ADDR step_frame_address;
48 int step_over_calls;
49 CORE_ADDR step_resume_break_address;
50 int stop_after_trap;
51 int stop_soon_quietly;
52 CORE_ADDR selected_frame_address;
53 char stop_registers[REGISTER_BYTES];
55 /* These are here because if call_function_by_hand has written some
56 registers and then decides to call error(), we better not have changed
57 any registers. */
58 char registers[REGISTER_BYTES];
60 int selected_level;
61 int breakpoint_proceeded;
62 int restore_stack_info;
63 int proceed_to_finish;
66 /* This macro gives the number of registers actually in use by the
67 inferior. This may be less than the total number of registers,
68 perhaps depending on the actual CPU in use or program being run. */
70 #ifndef ARCH_NUM_REGS
71 #define ARCH_NUM_REGS NUM_REGS
72 #endif
74 extern void save_inferior_status PARAMS ((struct inferior_status *, int));
76 extern void restore_inferior_status PARAMS ((struct inferior_status *));
78 extern void set_sigint_trap PARAMS ((void));
80 extern void clear_sigint_trap PARAMS ((void));
82 extern void set_sigio_trap PARAMS ((void));
84 extern void clear_sigio_trap PARAMS ((void));
86 /* File name for default use for standard in/out in the inferior. */
88 extern char *inferior_io_terminal;
90 /* Pid of our debugged inferior, or 0 if no inferior now. */
92 extern int inferior_pid;
94 /* This is only valid when inferior_pid is non-zero.
96 If this is 0, then exec events should be noticed and responded to
97 by the debugger (i.e., be reported to the user).
99 If this is > 0, then that many subsequent exec events should be
100 ignored (i.e., not be reported to the user).
102 extern int inferior_ignoring_startup_exec_events;
104 /* This is only valid when inferior_ignoring_startup_exec_events is
105 zero.
107 Some targets (stupidly) report more than one exec event per actual
108 call to an event() system call. If only the last such exec event
109 need actually be noticed and responded to by the debugger (i.e.,
110 be reported to the user), then this is the number of "leading"
111 exec events which should be ignored.
113 extern int inferior_ignoring_leading_exec_events;
115 /* Inferior environment. */
117 extern struct environ *inferior_environ;
119 /* Character array containing an image of the inferior programs' registers. */
121 extern char registers[];
123 /* Array of validity bits (one per register). Nonzero at position XXX_REGNUM
124 means that `registers' contains a valid copy of inferior register XXX.
125 -1 if register value is not available. */
127 extern SIGNED char register_valid[NUM_REGS];
129 extern void clear_proceed_status PARAMS ((void));
131 extern void proceed PARAMS ((CORE_ADDR, enum target_signal, int));
133 extern void kill_inferior PARAMS ((void));
135 extern void generic_mourn_inferior PARAMS ((void));
137 extern void terminal_ours PARAMS ((void));
139 extern int run_stack_dummy PARAMS ((CORE_ADDR, char [REGISTER_BYTES]));
141 extern CORE_ADDR read_pc PARAMS ((void));
143 extern CORE_ADDR read_pc_pid PARAMS ((int));
145 extern void write_pc PARAMS ((CORE_ADDR));
147 extern void write_pc_pid PARAMS ((CORE_ADDR, int));
149 extern CORE_ADDR read_sp PARAMS ((void));
151 extern void write_sp PARAMS ((CORE_ADDR));
153 extern CORE_ADDR read_fp PARAMS ((void));
155 extern void write_fp PARAMS ((CORE_ADDR));
157 extern void wait_for_inferior PARAMS ((void));
159 extern void init_wait_for_inferior PARAMS ((void));
161 extern void close_exec_file PARAMS ((void));
163 extern void reopen_exec_file PARAMS ((void));
165 /* The `resume' routine should only be called in special circumstances.
166 Normally, use `proceed', which handles a lot of bookkeeping. */
168 extern void resume PARAMS ((int, enum target_signal));
170 /* From misc files */
172 extern void store_inferior_registers PARAMS ((int));
174 extern void fetch_inferior_registers PARAMS ((int));
176 extern void solib_create_inferior_hook PARAMS ((void));
178 extern void child_terminal_info PARAMS ((char *, int));
180 extern void term_info PARAMS ((char *, int));
182 extern void terminal_ours_for_output PARAMS ((void));
184 extern void terminal_inferior PARAMS ((void));
186 extern void terminal_init_inferior PARAMS ((void));
188 extern void terminal_init_inferior_with_pgrp PARAMS ((int pgrp));
190 /* From infptrace.c or infttrace.c */
192 extern int attach PARAMS ((int));
194 #if !defined(REQUIRE_ATTACH)
195 #define REQUIRE_ATTACH attach
196 #endif
198 #if !defined(REQUIRE_DETACH)
199 #define REQUIRE_DETACH(pid,siggnal) detach (siggnal)
200 #endif
202 extern void detach PARAMS ((int));
204 int proc_wait PARAMS ((int, int *));
206 extern void child_resume PARAMS ((int, int, enum target_signal));
208 #ifndef PTRACE_ARG3_TYPE
209 #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
210 #endif
212 extern int call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int));
214 extern void pre_fork_inferior PARAMS ((void));
216 /* From procfs.c */
218 extern int proc_iterate_over_mappings PARAMS ((int (*) (int, CORE_ADDR)));
220 extern int procfs_first_available PARAMS ((void));
222 extern int procfs_get_pid_fd PARAMS ((int));
224 /* From fork-child.c */
226 extern void fork_inferior PARAMS ((char *, char *, char **,
227 void (*) (void),
228 void (*) (int),
229 void (*) (void),
230 char *));
233 extern void
234 clone_and_follow_inferior PARAMS ((int, int *));
236 extern void startup_inferior PARAMS ((int));
238 /* From inflow.c */
240 extern void new_tty_prefork PARAMS ((char *));
242 extern int gdb_has_a_terminal PARAMS ((void));
244 /* From infrun.c */
246 extern void start_remote PARAMS ((void));
248 extern void normal_stop PARAMS ((void));
250 extern int signal_stop_state PARAMS ((int));
252 extern int signal_print_state PARAMS ((int));
254 extern int signal_pass_state PARAMS ((int));
256 /* From infcmd.c */
258 extern void tty_command PARAMS ((char *, int));
260 extern void attach_command PARAMS ((char *, int));
262 /* Last signal that the inferior received (why it stopped). */
264 extern enum target_signal stop_signal;
266 /* Address at which inferior stopped. */
268 extern CORE_ADDR stop_pc;
270 /* Chain containing status of breakpoint(s) that we have stopped at. */
272 extern bpstat stop_bpstat;
274 /* Flag indicating that a command has proceeded the inferior past the
275 current breakpoint. */
277 extern int breakpoint_proceeded;
279 /* Nonzero if stopped due to a step command. */
281 extern int stop_step;
283 /* Nonzero if stopped due to completion of a stack dummy routine. */
285 extern int stop_stack_dummy;
287 /* Nonzero if program stopped due to a random (unexpected) signal in
288 inferior process. */
290 extern int stopped_by_random_signal;
292 /* Range to single step within.
293 If this is nonzero, respond to a single-step signal
294 by continuing to step if the pc is in this range.
296 If step_range_start and step_range_end are both 1, it means to step for
297 a single instruction (FIXME: it might clean up wait_for_inferior in a
298 minor way if this were changed to the address of the instruction and
299 that address plus one. But maybe not.). */
301 extern CORE_ADDR step_range_start; /* Inclusive */
302 extern CORE_ADDR step_range_end; /* Exclusive */
304 /* Stack frame address as of when stepping command was issued.
305 This is how we know when we step into a subroutine call,
306 and how to set the frame for the breakpoint used to step out. */
308 extern CORE_ADDR step_frame_address;
310 /* Our notion of the current stack pointer. */
312 extern CORE_ADDR step_sp;
314 /* 1 means step over all subroutine calls.
315 -1 means step over calls to undebuggable functions. */
317 extern int step_over_calls;
319 /* If stepping, nonzero means step count is > 1
320 so don't print frame next time inferior stops
321 if it stops due to stepping. */
323 extern int step_multi;
325 /* Nonzero means expecting a trap and caller will handle it themselves.
326 It is used after attach, due to attaching to a process;
327 when running in the shell before the child program has been exec'd;
328 and when running some kinds of remote stuff (FIXME?). */
330 extern int stop_soon_quietly;
332 /* Nonzero if proceed is being used for a "finish" command or a similar
333 situation when stop_registers should be saved. */
335 extern int proceed_to_finish;
337 /* Save register contents here when about to pop a stack dummy frame,
338 if-and-only-if proceed_to_finish is set.
339 Thus this contains the return value from the called function (assuming
340 values are returned in a register). */
342 extern char stop_registers[REGISTER_BYTES];
344 /* Nonzero if the child process in inferior_pid was attached rather
345 than forked. */
347 extern int attach_flag;
349 /* Sigtramp is a routine that the kernel calls (which then calls the
350 signal handler). On most machines it is a library routine that
351 is linked into the executable.
353 This macro, given a program counter value and the name of the
354 function in which that PC resides (which can be null if the
355 name is not known), returns nonzero if the PC and name show
356 that we are in sigtramp.
358 On most machines just see if the name is sigtramp (and if we have
359 no name, assume we are not in sigtramp). */
360 #if !defined (IN_SIGTRAMP)
361 # if defined (SIGTRAMP_START)
362 # define IN_SIGTRAMP(pc, name) \
363 ((pc) >= SIGTRAMP_START(pc) \
364 && (pc) < SIGTRAMP_END(pc) \
366 # else
367 # define IN_SIGTRAMP(pc, name) \
368 (name && STREQ ("_sigtramp", name))
369 # endif
370 #endif
372 /* Possible values for CALL_DUMMY_LOCATION. */
373 #define ON_STACK 1
374 #define BEFORE_TEXT_END 2
375 #define AFTER_TEXT_END 3
376 #define AT_ENTRY_POINT 4
378 #if !defined (CALL_DUMMY_LOCATION)
379 #define CALL_DUMMY_LOCATION ON_STACK
380 #endif /* No CALL_DUMMY_LOCATION. */
382 /* Are we in a call dummy? The code below which allows DECR_PC_AFTER_BREAK
383 below is for infrun.c, which may give the macro a pc without that
384 subtracted out. */
385 #if !defined (PC_IN_CALL_DUMMY)
386 #if CALL_DUMMY_LOCATION == BEFORE_TEXT_END
387 extern CORE_ADDR text_end;
388 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
389 ((pc) >= text_end - CALL_DUMMY_LENGTH \
390 && (pc) <= text_end + DECR_PC_AFTER_BREAK)
391 #endif /* Before text_end. */
393 #if CALL_DUMMY_LOCATION == AFTER_TEXT_END
394 extern CORE_ADDR text_end;
395 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
396 ((pc) >= text_end \
397 && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK)
398 #endif /* After text_end. */
400 #if CALL_DUMMY_LOCATION == ON_STACK
401 /* Is the PC in a call dummy? SP and FRAME_ADDRESS are the bottom and
402 top of the stack frame which we are checking, where "bottom" and
403 "top" refer to some section of memory which contains the code for
404 the call dummy. Calls to this macro assume that the contents of
405 SP_REGNUM and FP_REGNUM (or the saved values thereof), respectively,
406 are the things to pass.
408 This won't work on the 29k, where SP_REGNUM and FP_REGNUM don't
409 have that meaning, but the 29k doesn't use ON_STACK. This could be
410 fixed by generalizing this scheme, perhaps by passing in a frame
411 and adding a few fields, at least on machines which need them for
412 PC_IN_CALL_DUMMY.
414 Something simpler, like checking for the stack segment, doesn't work,
415 since various programs (threads implementations, gcc nested function
416 stubs, etc) may either allocate stack frames in another segment, or
417 allocate other kinds of code on the stack. */
419 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
420 (INNER_THAN ((sp), (pc)) && (frame_address != 0) && INNER_THAN ((pc), (frame_address)))
421 #endif /* On stack. */
423 #if CALL_DUMMY_LOCATION == AT_ENTRY_POINT
424 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
425 ((pc) >= CALL_DUMMY_ADDRESS () \
426 && (pc) <= (CALL_DUMMY_ADDRESS () + DECR_PC_AFTER_BREAK))
427 #endif /* At entry point. */
428 #endif /* No PC_IN_CALL_DUMMY. */
430 /* It's often not enough for our clients to know whether the PC is merely
431 somewhere within the call dummy. They may need to know whether the
432 call dummy has actually completed. (For example, wait_for_inferior
433 wants to know when it should truly stop because the call dummy has
434 completed. If we're single-stepping because of slow watchpoints,
435 then we may find ourselves stopped at the entry of the call dummy,
436 and want to continue stepping until we reach the end.)
438 Note that this macro is intended for targets (like HP-UX) which
439 require more than a single breakpoint in their call dummies, and
440 therefore cannot use the CALL_DUMMY_BREAKPOINT_OFFSET mechanism.
442 If a target does define CALL_DUMMY_BREAKPOINT_OFFSET, then this
443 default implementation of CALL_DUMMY_HAS_COMPLETED is sufficient.
444 Else, a target may wish to supply an implementation that works in
445 the presense of multiple breakpoints in its call dummy.
447 #if !defined(CALL_DUMMY_HAS_COMPLETED)
448 #define CALL_DUMMY_HAS_COMPLETED(pc, sp, frame_address) \
449 PC_IN_CALL_DUMMY((pc), (sp), (frame_address))
450 #endif
452 /* If STARTUP_WITH_SHELL is set, GDB's "run"
453 will attempts to start up the debugee under a shell.
454 This is in order for argument-expansion to occur. E.g.,
455 (gdb) run *
456 The "*" gets expanded by the shell into a list of files.
457 While this is a nice feature, it turns out to interact badly
458 with some of the catch-fork/catch-exec features we have added.
459 In particular, if the shell does any fork/exec's before
460 the exec of the target program, that can confuse GDB.
461 To disable this feature, set STARTUP_WITH_SHELL to 0.
462 To enable this feature, set STARTUP_WITH_SHELL to 1.
463 The catch-exec traps expected during start-up will
464 be 1 if target is not started up with a shell, 2 if it is.
465 - RT
466 If you disable this, you need to decrement
467 START_INFERIOR_TRAPS_EXPECTED in tm.h. */
468 #define STARTUP_WITH_SHELL 1
470 #endif /* !defined (INFERIOR_H) */