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"
30 /* For enum target_signal. */
34 * Structure in which to save the status of the inferior. Save
35 * through "save_inferior_status", restore through
36 * "restore_inferior_status".
37 * This pair of routines should be called around any transfer of
38 * control to the inferior which you don't want showing up in your
41 struct inferior_status {
42 enum target_signal stop_signal;
44 FRAME_ADDR stop_frame_address;
48 int stopped_by_random_signal;
50 CORE_ADDR step_range_start;
51 CORE_ADDR step_range_end;
52 FRAME_ADDR step_frame_address;
54 CORE_ADDR step_resume_break_address;
56 int stop_soon_quietly;
57 FRAME_ADDR selected_frame_address;
59 char stop_registers[REGISTER_BYTES];
61 /* These are here because if call_function_by_hand has written some
62 registers and then decides to call error(), we better not have changed
64 char registers[REGISTER_BYTES];
66 int breakpoint_proceeded;
67 int restore_stack_info;
68 int proceed_to_finish;
72 save_inferior_status PARAMS ((struct inferior_status *, int));
75 restore_inferior_status PARAMS ((struct inferior_status *));
77 extern void set_sigint_trap PARAMS ((void));
78 extern void clear_sigint_trap PARAMS ((void));
80 extern void set_sigio_trap PARAMS ((void));
81 extern void clear_sigio_trap PARAMS ((void));
83 /* File name for default use for standard in/out in the inferior. */
85 extern char *inferior_io_terminal;
87 /* Pid of our debugged inferior, or 0 if no inferior now. */
89 extern int inferior_pid;
91 /* Character array containing an image of the inferior programs' registers. */
93 extern char registers[];
95 /* Array of validity bits (one per register). Nonzero at position XXX_REGNUM
96 means that `registers' contains a valid copy of inferior register XXX. */
98 extern char register_valid[NUM_REGS];
101 clear_proceed_status PARAMS ((void));
104 proceed PARAMS ((CORE_ADDR, enum target_signal, int));
107 kill_inferior PARAMS ((void));
110 generic_mourn_inferior PARAMS ((void));
113 terminal_ours PARAMS ((void));
115 extern int run_stack_dummy PARAMS ((CORE_ADDR, char [REGISTER_BYTES]));
118 read_pc PARAMS ((void));
121 read_pc_pid PARAMS ((int));
124 write_pc PARAMS ((CORE_ADDR));
127 read_sp PARAMS ((void));
130 write_sp PARAMS ((CORE_ADDR));
133 read_fp PARAMS ((void));
136 write_fp PARAMS ((CORE_ADDR));
139 wait_for_inferior PARAMS ((void));
142 init_wait_for_inferior PARAMS ((void));
145 close_exec_file PARAMS ((void));
148 reopen_exec_file PARAMS ((void));
150 /* The `resume' routine should only be called in special circumstances.
151 Normally, use `proceed', which handles a lot of bookkeeping. */
153 resume PARAMS ((int, enum target_signal));
155 /* From misc files */
158 store_inferior_registers PARAMS ((int));
161 fetch_inferior_registers PARAMS ((int));
164 solib_create_inferior_hook PARAMS ((void));
167 child_terminal_info PARAMS ((char *, int));
170 term_info PARAMS ((char *, int));
173 terminal_ours_for_output PARAMS ((void));
176 terminal_inferior PARAMS ((void));
179 terminal_init_inferior PARAMS ((void));
181 /* From infptrace.c */
184 attach PARAMS ((int));
187 detach PARAMS ((int));
190 child_resume PARAMS ((int, int, enum target_signal));
192 #ifndef PTRACE_ARG3_TYPE
193 #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
197 call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int));
202 proc_iterate_over_mappings PARAMS ((int (*) (int, CORE_ADDR)));
204 /* From fork-child.c */
206 extern void fork_inferior PARAMS ((char *, char *, char **,
208 void (*) (int), char *));
210 extern void startup_inferior PARAMS ((int));
215 new_tty_prefork PARAMS ((char *));
217 extern int gdb_has_a_terminal PARAMS ((void));
222 start_remote PARAMS ((void));
225 normal_stop PARAMS ((void));
228 signal_stop_state PARAMS ((int));
231 signal_print_state PARAMS ((int));
234 signal_pass_state PARAMS ((int));
239 tty_command PARAMS ((char *, int));
242 attach_command PARAMS ((char *, int));
244 /* Last signal that the inferior received (why it stopped). */
246 extern enum target_signal stop_signal;
248 /* Address at which inferior stopped. */
250 extern CORE_ADDR stop_pc;
252 /* Stack frame when program stopped. */
254 extern FRAME_ADDR stop_frame_address;
256 /* Chain containing status of breakpoint(s) that we have stopped at. */
258 extern bpstat stop_bpstat;
260 /* Flag indicating that a command has proceeded the inferior past the
261 current breakpoint. */
263 extern int breakpoint_proceeded;
265 /* Nonzero if stopped due to a step command. */
267 extern int stop_step;
269 /* Nonzero if stopped due to completion of a stack dummy routine. */
271 extern int stop_stack_dummy;
273 /* Nonzero if program stopped due to a random (unexpected) signal in
276 extern int stopped_by_random_signal;
278 /* Range to single step within.
279 If this is nonzero, respond to a single-step signal
280 by continuing to step if the pc is in this range.
282 If step_range_start and step_range_end are both 1, it means to step for
283 a single instruction (FIXME: it might clean up wait_for_inferior in a
284 minor way if this were changed to the address of the instruction and
285 that address plus one. But maybe not.). */
287 extern CORE_ADDR step_range_start; /* Inclusive */
288 extern CORE_ADDR step_range_end; /* Exclusive */
290 /* Stack frame address as of when stepping command was issued.
291 This is how we know when we step into a subroutine call,
292 and how to set the frame for the breakpoint used to step out. */
294 extern FRAME_ADDR step_frame_address;
296 /* 1 means step over all subroutine calls.
297 -1 means step over calls to undebuggable functions. */
299 extern int step_over_calls;
301 /* If stepping, nonzero means step count is > 1
302 so don't print frame next time inferior stops
303 if it stops due to stepping. */
305 extern int step_multi;
307 /* Nonzero means expecting a trap and caller will handle it themselves.
308 It is used after attach, due to attaching to a process;
309 when running in the shell before the child program has been exec'd;
310 and when running some kinds of remote stuff (FIXME?). */
312 extern int stop_soon_quietly;
314 /* Nonzero if proceed is being used for a "finish" command or a similar
315 situation when stop_registers should be saved. */
317 extern int proceed_to_finish;
319 /* Save register contents here when about to pop a stack dummy frame,
320 if-and-only-if proceed_to_finish is set.
321 Thus this contains the return value from the called function (assuming
322 values are returned in a register). */
324 extern char stop_registers[REGISTER_BYTES];
326 /* Nonzero if the child process in inferior_pid was attached rather
329 extern int attach_flag;
331 /* Sigtramp is a routine that the kernel calls (which then calls the
332 signal handler). On most machines it is a library routine that
333 is linked into the executable.
335 This macro, given a program counter value and the name of the
336 function in which that PC resides (which can be null if the
337 name is not known), returns nonzero if the PC and name show
338 that we are in sigtramp.
340 On most machines just see if the name is sigtramp (and if we have
341 no name, assume we are not in sigtramp). */
342 #if !defined (IN_SIGTRAMP)
343 # if defined (SIGTRAMP_START)
344 # define IN_SIGTRAMP(pc, name) \
345 ((pc) >= SIGTRAMP_START \
346 && (pc) < SIGTRAMP_END \
349 # define IN_SIGTRAMP(pc, name) \
350 (name && STREQ ("_sigtramp", name))
354 /* Possible values for CALL_DUMMY_LOCATION. */
356 #define BEFORE_TEXT_END 2
357 #define AFTER_TEXT_END 3
358 #define AT_ENTRY_POINT 4
360 #if !defined (CALL_DUMMY_LOCATION)
361 #define CALL_DUMMY_LOCATION ON_STACK
362 #endif /* No CALL_DUMMY_LOCATION. */
364 /* Are we in a call dummy? The code below which allows DECR_PC_AFTER_BREAK
365 below is for infrun.c, which may give the macro a pc without that
367 #if !defined (PC_IN_CALL_DUMMY)
368 #if CALL_DUMMY_LOCATION == BEFORE_TEXT_END
369 extern CORE_ADDR text_end;
370 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
371 ((pc) >= text_end - CALL_DUMMY_LENGTH \
372 && (pc) <= text_end + DECR_PC_AFTER_BREAK)
373 #endif /* Before text_end. */
375 #if CALL_DUMMY_LOCATION == AFTER_TEXT_END
376 extern CORE_ADDR text_end;
377 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
379 && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK)
380 #endif /* After text_end. */
382 #if CALL_DUMMY_LOCATION == ON_STACK
383 /* Is the PC in a call dummy? SP and FRAME_ADDRESS are the bottom and
384 top of the stack frame which we are checking, where "bottom" and
385 "top" refer to some section of memory which contains the code for
386 the call dummy. Calls to this macro assume that the contents of
387 SP_REGNUM and FP_REGNUM (or the saved values thereof), respectively,
388 are the things to pass.
390 This won't work on the 29k, where SP_REGNUM and FP_REGNUM don't
391 have that meaning, but the 29k doesn't use ON_STACK. This could be
392 fixed by generalizing this scheme, perhaps by passing in a frame
393 and adding a few fields, at least on machines which need them for
396 Something simpler, like checking for the stack segment, doesn't work,
397 since various programs (threads implementations, gcc nested function
398 stubs, etc) may either allocate stack frames in another segment, or
399 allocate other kinds of code on the stack. */
401 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
402 ((sp) INNER_THAN (pc) && (frame_address != 0) && (pc) INNER_THAN (frame_address))
403 #endif /* On stack. */
405 #if CALL_DUMMY_LOCATION == AT_ENTRY_POINT
406 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
407 ((pc) >= CALL_DUMMY_ADDRESS () \
408 && (pc) <= (CALL_DUMMY_ADDRESS () + DECR_PC_AFTER_BREAK))
409 #endif /* At entry point. */
410 #endif /* No PC_IN_CALL_DUMMY. */
412 #endif /* !defined (INFERIOR_H) */