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 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 #if !defined (INFERIOR_H)
25 #include "breakpoint.h"
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
38 struct inferior_status {
42 FRAME_ADDR stop_frame_address;
46 int stopped_by_random_signal;
48 CORE_ADDR step_range_start;
49 CORE_ADDR step_range_end;
50 FRAME_ADDR step_frame_address;
52 CORE_ADDR step_resume_break_address;
54 int stop_soon_quietly;
55 FRAME_ADDR selected_frame_address;
57 char stop_registers[REGISTER_BYTES];
58 int breakpoint_proceeded;
59 int restore_stack_info;
60 int proceed_to_finish;
64 save_inferior_status PARAMS ((struct inferior_status *, int));
67 restore_inferior_status PARAMS ((struct inferior_status *));
69 /* File name for default use for standard in/out in the inferior. */
71 extern char *inferior_io_terminal;
73 /* Pid of our debugged inferior, or 0 if no inferior now. */
75 extern int inferior_pid;
77 /* Character array containing an image of the inferior programs' registers. */
79 extern char registers[];
81 /* Array of validity bits (one per register). Nonzero at position XXX_REGNUM
82 means that `registers' contains a valid copy of inferior register XXX. */
84 extern char register_valid[NUM_REGS];
87 clear_proceed_status PARAMS ((void));
90 proceed PARAMS ((CORE_ADDR, int, int));
93 kill_inferior PARAMS ((void));
96 generic_mourn_inferior PARAMS ((void));
99 terminal_ours PARAMS ((void));
102 run_stack_dummy PARAMS ((char*, CORE_ADDR, char [REGISTER_BYTES]));
105 read_pc PARAMS ((void));
108 write_pc PARAMS ((CORE_ADDR));
111 read_sp PARAMS ((void));
114 write_sp PARAMS ((CORE_ADDR));
117 read_fp PARAMS ((void));
120 write_fp PARAMS ((CORE_ADDR));
123 wait_for_inferior PARAMS ((void));
126 init_wait_for_inferior PARAMS ((void));
129 close_exec_file PARAMS ((void));
132 reopen_exec_file PARAMS ((void));
134 /* The `resume' routine should only be called in special circumstances.
135 Normally, use `proceed', which handles a lot of bookkeeping. */
137 resume PARAMS ((int, int));
139 /* From misc files */
142 store_inferior_registers PARAMS ((int));
145 fetch_inferior_registers PARAMS ((int));
148 solib_create_inferior_hook PARAMS ((void));
151 child_terminal_info PARAMS ((char *, int));
154 term_info PARAMS ((char *, int));
157 terminal_ours_for_output PARAMS ((void));
160 terminal_inferior PARAMS ((void));
163 terminal_init_inferior PARAMS ((void));
165 /* From infptrace.c */
168 attach PARAMS ((int));
171 detach PARAMS ((int));
174 child_resume PARAMS ((int, int));
176 #ifndef PTRACE_ARG3_TYPE
177 #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
181 call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int));
186 proc_iterate_over_mappings PARAMS ((int (*) (int, CORE_ADDR)));
188 /* From fork-child.c */
191 fork_inferior PARAMS ((char *, char *, char **,
198 new_tty_prefork PARAMS ((char *));
200 extern int gdb_has_a_terminal PARAMS ((void));
205 start_remote PARAMS ((void));
208 normal_stop PARAMS ((void));
211 signal_stop_state PARAMS ((int));
214 signal_print_state PARAMS ((int));
217 signal_pass_state PARAMS ((int));
222 tty_command PARAMS ((char *, int));
225 attach_command PARAMS ((char *, int));
227 /* Last signal that the inferior received (why it stopped). */
229 extern int stop_signal;
231 /* Address at which inferior stopped. */
233 extern CORE_ADDR stop_pc;
235 /* Stack frame when program stopped. */
237 extern FRAME_ADDR stop_frame_address;
239 /* Chain containing status of breakpoint(s) that we have stopped at. */
241 extern bpstat stop_bpstat;
243 /* Flag indicating that a command has proceeded the inferior past the
244 current breakpoint. */
246 extern int breakpoint_proceeded;
248 /* Nonzero if stopped due to a step command. */
250 extern int stop_step;
252 /* Nonzero if stopped due to completion of a stack dummy routine. */
254 extern int stop_stack_dummy;
256 /* Nonzero if program stopped due to a random (unexpected) signal in
259 extern int stopped_by_random_signal;
261 /* Range to single step within.
262 If this is nonzero, respond to a single-step signal
263 by continuing to step if the pc is in this range. */
265 extern CORE_ADDR step_range_start; /* Inclusive */
266 extern CORE_ADDR step_range_end; /* Exclusive */
268 /* Stack frame address as of when stepping command was issued.
269 This is how we know when we step into a subroutine call,
270 and how to set the frame for the breakpoint used to step out. */
272 extern FRAME_ADDR step_frame_address;
274 /* 1 means step over all subroutine calls.
275 -1 means step over calls to undebuggable functions. */
277 extern int step_over_calls;
279 /* If stepping, nonzero means step count is > 1
280 so don't print frame next time inferior stops
281 if it stops due to stepping. */
283 extern int step_multi;
285 /* Nonzero means expecting a trap and caller will handle it themselves.
286 It is used after attach, due to attaching to a process;
287 when running in the shell before the child program has been exec'd;
288 and when running some kinds of remote stuff (FIXME?). */
290 extern int stop_soon_quietly;
292 /* Nonzero if proceed is being used for a "finish" command or a similar
293 situation when stop_registers should be saved. */
295 extern int proceed_to_finish;
297 /* Save register contents here when about to pop a stack dummy frame,
298 if-and-only-if proceed_to_finish is set.
299 Thus this contains the return value from the called function (assuming
300 values are returned in a register). */
302 extern char stop_registers[REGISTER_BYTES];
304 /* Nonzero if pc has been changed by the debugger
305 since the inferior stopped. */
307 extern int pc_changed;
309 /* Nonzero if the child process in inferior_pid was attached rather
312 extern int attach_flag;
314 /* Sigtramp is a routine that the kernel calls (which then calls the
315 signal handler). On most machines it is a library routine that
316 is linked into the executable.
318 This macro, given a program counter value and the name of the
319 function in which that PC resides (which can be null if the
320 name is not known), returns nonzero if the PC and name show
321 that we are in sigtramp.
323 On most machines just see if the name is sigtramp (and if we have
324 no name, assume we are not in sigtramp). */
325 #if !defined (IN_SIGTRAMP)
326 # if defined (SIGTRAMP_START)
327 # define IN_SIGTRAMP(pc, name) \
328 ((pc) >= SIGTRAMP_START \
329 && (pc) < SIGTRAMP_END \
332 # define IN_SIGTRAMP(pc, name) \
333 (name && STREQ ("_sigtramp", name))
337 /* Possible values for CALL_DUMMY_LOCATION. */
339 #define BEFORE_TEXT_END 2
340 #define AFTER_TEXT_END 3
342 #if !defined (CALL_DUMMY_LOCATION)
343 #define CALL_DUMMY_LOCATION ON_STACK
344 #endif /* No CALL_DUMMY_LOCATION. */
346 /* Are we in a call dummy? The code below which allows DECR_PC_AFTER_BREAK
347 below is for infrun.c, which may give the macro a pc without that
349 #if !defined (PC_IN_CALL_DUMMY)
350 #if CALL_DUMMY_LOCATION == BEFORE_TEXT_END
351 extern CORE_ADDR text_end;
352 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
353 ((pc) >= text_end - CALL_DUMMY_LENGTH \
354 && (pc) <= text_end + DECR_PC_AFTER_BREAK)
355 #else /* Not before text_end. */
356 #if CALL_DUMMY_LOCATION == AFTER_TEXT_END
357 extern CORE_ADDR text_end;
358 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
360 && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK)
361 #else /* On stack. */
363 /* Is the PC in a call dummy? SP and FRAME_ADDRESS are the bottom and
364 top of the stack frame which we are checking, where "bottom" and
365 "top" refer to some section of memory which contains the code for
366 the call dummy. Calls to this macro assume that the contents of
367 SP_REGNUM and FP_REGNUM (or the saved values thereof), respectively,
368 are the things to pass.
370 This won't work on the 29k, where SP_REGNUM and FP_REGNUM don't
371 have that meaning, but the 29k doesn't use ON_STACK. This could be
372 fixed by generalizing this scheme, perhaps by passing in a frame
373 and adding a few fields, at least on machines which need them for
376 Something simpler, like checking for the stack segment, doesn't work,
377 since various programs (threads implementations, gcc nested function
378 stubs, etc) may either allocate stack frames in another segment, or
379 allocate other kinds of code on the stack. */
381 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
382 ((sp) INNER_THAN (pc) && (frame_address != 0) && (pc) INNER_THAN (frame_address))
383 #endif /* On stack. */
384 #endif /* Not before text_end. */
385 #endif /* No PC_IN_CALL_DUMMY. */
387 #endif /* !defined (INFERIOR_H) */