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)
25 #include "breakpoint.h"
27 /* For enum target_signal. */
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
37 struct inferior_status
39 enum target_signal stop_signal;
44 int stopped_by_random_signal;
46 CORE_ADDR step_range_start;
47 CORE_ADDR step_range_end;
48 CORE_ADDR step_frame_address;
50 CORE_ADDR step_resume_break_address;
52 int stop_soon_quietly;
53 CORE_ADDR selected_frame_address;
54 char stop_registers[REGISTER_BYTES];
56 /* These are here because if call_function_by_hand has written some
57 registers and then decides to call error(), we better not have changed
59 char registers[REGISTER_BYTES];
62 int breakpoint_proceeded;
63 int restore_stack_info;
64 int proceed_to_finish;
67 /* This macro gives the number of registers actually in use by the
68 inferior. This may be less than the total number of registers,
69 perhaps depending on the actual CPU in use or program being run. */
72 #define ARCH_NUM_REGS NUM_REGS
75 extern void save_inferior_status PARAMS ((struct inferior_status *, int));
77 extern void restore_inferior_status PARAMS ((struct inferior_status *));
79 extern void set_sigint_trap PARAMS ((void));
81 extern void clear_sigint_trap PARAMS ((void));
83 extern void set_sigio_trap PARAMS ((void));
85 extern void clear_sigio_trap PARAMS ((void));
87 /* File name for default use for standard in/out in the inferior. */
89 extern char *inferior_io_terminal;
91 /* Pid of our debugged inferior, or 0 if no inferior now. */
93 extern int inferior_pid;
95 /* This is only valid when inferior_pid is non-zero.
97 If this is 0, then exec events should be noticed and responded to
98 by the debugger (i.e., be reported to the user).
100 If this is > 0, then that many subsequent exec events should be
101 ignored (i.e., not be reported to the user).
103 extern int inferior_ignoring_startup_exec_events;
105 /* This is only valid when inferior_ignoring_startup_exec_events is
108 Some targets (stupidly) report more than one exec event per actual
109 call to an event() system call. If only the last such exec event
110 need actually be noticed and responded to by the debugger (i.e.,
111 be reported to the user), then this is the number of "leading"
112 exec events which should be ignored.
114 extern int inferior_ignoring_leading_exec_events;
116 /* Inferior environment. */
118 extern struct environ *inferior_environ;
120 /* Character array containing an image of the inferior programs' registers. */
122 extern char registers[];
124 /* Array of validity bits (one per register). Nonzero at position XXX_REGNUM
125 means that `registers' contains a valid copy of inferior register XXX.
126 -1 if register value is not available. */
128 extern SIGNED char register_valid[NUM_REGS];
130 extern void clear_proceed_status PARAMS ((void));
132 extern void proceed PARAMS ((CORE_ADDR, enum target_signal, int));
134 extern void kill_inferior PARAMS ((void));
136 extern void generic_mourn_inferior PARAMS ((void));
138 extern void terminal_ours PARAMS ((void));
140 extern int run_stack_dummy PARAMS ((CORE_ADDR, char[REGISTER_BYTES]));
142 extern CORE_ADDR read_pc PARAMS ((void));
144 extern CORE_ADDR read_pc_pid PARAMS ((int));
146 extern void write_pc PARAMS ((CORE_ADDR));
148 extern void write_pc_pid PARAMS ((CORE_ADDR, int));
150 extern CORE_ADDR read_sp PARAMS ((void));
152 extern void write_sp PARAMS ((CORE_ADDR));
154 extern CORE_ADDR read_fp PARAMS ((void));
156 extern void write_fp PARAMS ((CORE_ADDR));
158 extern void wait_for_inferior PARAMS ((void));
160 extern void init_wait_for_inferior PARAMS ((void));
162 extern void close_exec_file PARAMS ((void));
164 extern void reopen_exec_file PARAMS ((void));
166 /* The `resume' routine should only be called in special circumstances.
167 Normally, use `proceed', which handles a lot of bookkeeping. */
169 extern void resume PARAMS ((int, enum target_signal));
171 /* From misc files */
173 extern void store_inferior_registers PARAMS ((int));
175 extern void fetch_inferior_registers PARAMS ((int));
177 extern void solib_create_inferior_hook PARAMS ((void));
179 extern void child_terminal_info PARAMS ((char *, int));
181 extern void term_info PARAMS ((char *, int));
183 extern void terminal_ours_for_output PARAMS ((void));
185 extern void terminal_inferior PARAMS ((void));
187 extern void terminal_init_inferior PARAMS ((void));
189 extern void terminal_init_inferior_with_pgrp PARAMS ((int pgrp));
191 /* From infptrace.c or infttrace.c */
193 extern int attach PARAMS ((int));
195 #if !defined(REQUIRE_ATTACH)
196 #define REQUIRE_ATTACH attach
199 #if !defined(REQUIRE_DETACH)
200 #define REQUIRE_DETACH(pid,siggnal) detach (siggnal)
203 extern void detach PARAMS ((int));
205 int ptrace_wait PARAMS ((int, int *));
207 extern void child_resume PARAMS ((int, int, enum target_signal));
209 #ifndef PTRACE_ARG3_TYPE
210 #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
213 extern int call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int));
215 extern void pre_fork_inferior PARAMS ((void));
219 extern int proc_iterate_over_mappings PARAMS ((int (*)(int, CORE_ADDR)));
221 extern int procfs_first_available PARAMS ((void));
223 extern int procfs_get_pid_fd PARAMS ((int));
225 /* From fork-child.c */
227 extern void fork_inferior PARAMS ((char *, char *, char **,
235 clone_and_follow_inferior PARAMS ((int, int *));
237 extern void startup_inferior PARAMS ((int));
241 extern void new_tty_prefork PARAMS ((char *));
243 extern int gdb_has_a_terminal PARAMS ((void));
247 extern void start_remote PARAMS ((void));
249 extern void normal_stop PARAMS ((void));
251 extern int signal_stop_state PARAMS ((int));
253 extern int signal_print_state PARAMS ((int));
255 extern int signal_pass_state PARAMS ((int));
259 extern void tty_command PARAMS ((char *, int));
261 extern void attach_command PARAMS ((char *, int));
263 /* Last signal that the inferior received (why it stopped). */
265 extern enum target_signal stop_signal;
267 /* Address at which inferior stopped. */
269 extern CORE_ADDR stop_pc;
271 /* Chain containing status of breakpoint(s) that we have stopped at. */
273 extern bpstat stop_bpstat;
275 /* Flag indicating that a command has proceeded the inferior past the
276 current breakpoint. */
278 extern int breakpoint_proceeded;
280 /* Nonzero if stopped due to a step command. */
282 extern int stop_step;
284 /* Nonzero if stopped due to completion of a stack dummy routine. */
286 extern int stop_stack_dummy;
288 /* Nonzero if program stopped due to a random (unexpected) signal in
291 extern int stopped_by_random_signal;
293 /* Range to single step within.
294 If this is nonzero, respond to a single-step signal
295 by continuing to step if the pc is in this range.
297 If step_range_start and step_range_end are both 1, it means to step for
298 a single instruction (FIXME: it might clean up wait_for_inferior in a
299 minor way if this were changed to the address of the instruction and
300 that address plus one. But maybe not.). */
302 extern CORE_ADDR step_range_start; /* Inclusive */
303 extern CORE_ADDR step_range_end;/* Exclusive */
305 /* Stack frame address as of when stepping command was issued.
306 This is how we know when we step into a subroutine call,
307 and how to set the frame for the breakpoint used to step out. */
309 extern CORE_ADDR step_frame_address;
311 /* Our notion of the current stack pointer. */
313 extern CORE_ADDR step_sp;
315 /* 1 means step over all subroutine calls.
316 -1 means step over calls to undebuggable functions. */
318 extern int step_over_calls;
320 /* If stepping, nonzero means step count is > 1
321 so don't print frame next time inferior stops
322 if it stops due to stepping. */
324 extern int step_multi;
326 /* Nonzero means expecting a trap and caller will handle it themselves.
327 It is used after attach, due to attaching to a process;
328 when running in the shell before the child program has been exec'd;
329 and when running some kinds of remote stuff (FIXME?). */
331 extern int stop_soon_quietly;
333 /* Nonzero if proceed is being used for a "finish" command or a similar
334 situation when stop_registers should be saved. */
336 extern int proceed_to_finish;
338 /* Save register contents here when about to pop a stack dummy frame,
339 if-and-only-if proceed_to_finish is set.
340 Thus this contains the return value from the called function (assuming
341 values are returned in a register). */
343 extern char stop_registers[REGISTER_BYTES];
345 /* Nonzero if the child process in inferior_pid was attached rather
348 extern int attach_flag;
350 /* Sigtramp is a routine that the kernel calls (which then calls the
351 signal handler). On most machines it is a library routine that
352 is linked into the executable.
354 This macro, given a program counter value and the name of the
355 function in which that PC resides (which can be null if the
356 name is not known), returns nonzero if the PC and name show
357 that we are in sigtramp.
359 On most machines just see if the name is sigtramp (and if we have
360 no name, assume we are not in sigtramp). */
361 #if !defined (IN_SIGTRAMP)
362 #if defined (SIGTRAMP_START)
363 #define IN_SIGTRAMP(pc, name) \
364 ((pc) >= SIGTRAMP_START(pc) \
365 && (pc) < SIGTRAMP_END(pc) \
368 #define IN_SIGTRAMP(pc, name) \
369 (name && STREQ ("_sigtramp", name))
373 /* Possible values for CALL_DUMMY_LOCATION. */
375 #define BEFORE_TEXT_END 2
376 #define AFTER_TEXT_END 3
377 #define AT_ENTRY_POINT 4
379 #if !defined (CALL_DUMMY_LOCATION)
380 #define CALL_DUMMY_LOCATION ON_STACK
381 #endif /* No CALL_DUMMY_LOCATION. */
383 /* Are we in a call dummy? The code below which allows DECR_PC_AFTER_BREAK
384 below is for infrun.c, which may give the macro a pc without that
386 #if !defined (PC_IN_CALL_DUMMY)
387 #if CALL_DUMMY_LOCATION == BEFORE_TEXT_END
388 extern CORE_ADDR text_end;
389 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
390 ((pc) >= text_end - CALL_DUMMY_LENGTH \
391 && (pc) <= text_end + DECR_PC_AFTER_BREAK)
392 #endif /* Before text_end. */
394 #if CALL_DUMMY_LOCATION == AFTER_TEXT_END
395 extern CORE_ADDR text_end;
396 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
398 && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK)
399 #endif /* After text_end. */
401 #if CALL_DUMMY_LOCATION == ON_STACK
402 /* Is the PC in a call dummy? SP and FRAME_ADDRESS are the bottom and
403 top of the stack frame which we are checking, where "bottom" and
404 "top" refer to some section of memory which contains the code for
405 the call dummy. Calls to this macro assume that the contents of
406 SP_REGNUM and FP_REGNUM (or the saved values thereof), respectively,
407 are the things to pass.
409 This won't work on the 29k, where SP_REGNUM and FP_REGNUM don't
410 have that meaning, but the 29k doesn't use ON_STACK. This could be
411 fixed by generalizing this scheme, perhaps by passing in a frame
412 and adding a few fields, at least on machines which need them for
415 Something simpler, like checking for the stack segment, doesn't work,
416 since various programs (threads implementations, gcc nested function
417 stubs, etc) may either allocate stack frames in another segment, or
418 allocate other kinds of code on the stack. */
420 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
421 (INNER_THAN ((sp), (pc)) && (frame_address != 0) && INNER_THAN ((pc), (frame_address)))
422 #endif /* On stack. */
424 #if CALL_DUMMY_LOCATION == AT_ENTRY_POINT
425 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
426 ((pc) >= CALL_DUMMY_ADDRESS () \
427 && (pc) <= (CALL_DUMMY_ADDRESS () + DECR_PC_AFTER_BREAK))
428 #endif /* At entry point. */
429 #endif /* No PC_IN_CALL_DUMMY. */
431 /* It's often not enough for our clients to know whether the PC is merely
432 somewhere within the call dummy. They may need to know whether the
433 call dummy has actually completed. (For example, wait_for_inferior
434 wants to know when it should truly stop because the call dummy has
435 completed. If we're single-stepping because of slow watchpoints,
436 then we may find ourselves stopped at the entry of the call dummy,
437 and want to continue stepping until we reach the end.)
439 Note that this macro is intended for targets (like HP-UX) which
440 require more than a single breakpoint in their call dummies, and
441 therefore cannot use the CALL_DUMMY_BREAKPOINT_OFFSET mechanism.
443 If a target does define CALL_DUMMY_BREAKPOINT_OFFSET, then this
444 default implementation of CALL_DUMMY_HAS_COMPLETED is sufficient.
445 Else, a target may wish to supply an implementation that works in
446 the presense of multiple breakpoints in its call dummy.
448 #if !defined(CALL_DUMMY_HAS_COMPLETED)
449 #define CALL_DUMMY_HAS_COMPLETED(pc, sp, frame_address) \
450 PC_IN_CALL_DUMMY((pc), (sp), (frame_address))
453 /* If STARTUP_WITH_SHELL is set, GDB's "run"
454 will attempts to start up the debugee under a shell.
455 This is in order for argument-expansion to occur. E.g.,
457 The "*" gets expanded by the shell into a list of files.
458 While this is a nice feature, it turns out to interact badly
459 with some of the catch-fork/catch-exec features we have added.
460 In particular, if the shell does any fork/exec's before
461 the exec of the target program, that can confuse GDB.
462 To disable this feature, set STARTUP_WITH_SHELL to 0.
463 To enable this feature, set STARTUP_WITH_SHELL to 1.
464 The catch-exec traps expected during start-up will
465 be 1 if target is not started up with a shell, 2 if it is.
467 If you disable this, you need to decrement
468 START_INFERIOR_TRAPS_EXPECTED in tm.h. */
469 #define STARTUP_WITH_SHELL 1
470 #if !defined(START_INFERIOR_TRAPS_EXPECTED)
471 #define START_INFERIOR_TRAPS_EXPECTED 2
473 #endif /* !defined (INFERIOR_H) */