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 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 {
38 enum target_signal stop_signal;
43 int stopped_by_random_signal;
45 CORE_ADDR step_range_start;
46 CORE_ADDR step_range_end;
47 CORE_ADDR step_frame_address;
49 CORE_ADDR step_resume_break_address;
51 int stop_soon_quietly;
52 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];
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. */
71 #define ARCH_NUM_REGS NUM_REGS
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 /* Inferior environment. */
96 extern struct environ *inferior_environ;
98 /* Character array containing an image of the inferior programs' registers. */
100 extern char registers[];
102 /* Array of validity bits (one per register). Nonzero at position XXX_REGNUM
103 means that `registers' contains a valid copy of inferior register XXX. */
105 extern char register_valid[NUM_REGS];
107 extern void clear_proceed_status PARAMS ((void));
109 extern void proceed PARAMS ((CORE_ADDR, enum target_signal, int));
111 extern void kill_inferior PARAMS ((void));
113 extern void generic_mourn_inferior PARAMS ((void));
115 extern void terminal_ours PARAMS ((void));
117 extern int run_stack_dummy PARAMS ((CORE_ADDR, char [REGISTER_BYTES]));
119 extern CORE_ADDR read_pc PARAMS ((void));
121 extern CORE_ADDR read_pc_pid PARAMS ((int));
123 extern void write_pc PARAMS ((CORE_ADDR));
125 extern CORE_ADDR read_sp PARAMS ((void));
127 extern void write_sp PARAMS ((CORE_ADDR));
129 extern CORE_ADDR read_fp PARAMS ((void));
131 extern void write_fp PARAMS ((CORE_ADDR));
133 extern void wait_for_inferior PARAMS ((void));
135 extern void init_wait_for_inferior PARAMS ((void));
137 extern void close_exec_file PARAMS ((void));
139 extern void reopen_exec_file PARAMS ((void));
141 /* The `resume' routine should only be called in special circumstances.
142 Normally, use `proceed', which handles a lot of bookkeeping. */
144 extern void resume PARAMS ((int, enum target_signal));
146 /* From misc files */
148 extern void store_inferior_registers PARAMS ((int));
150 extern void fetch_inferior_registers PARAMS ((int));
152 extern void solib_create_inferior_hook PARAMS ((void));
154 extern void child_terminal_info PARAMS ((char *, int));
156 extern void term_info PARAMS ((char *, int));
158 extern void terminal_ours_for_output PARAMS ((void));
160 extern void terminal_inferior PARAMS ((void));
162 extern void terminal_init_inferior PARAMS ((void));
164 #ifdef PROCESS_GROUP_TYPE
165 extern void terminal_init_inferior_with_pgrp PARAMS ((PROCESS_GROUP_TYPE pgrp));
168 /* From infptrace.c */
170 extern int attach PARAMS ((int));
172 void detach PARAMS ((int));
174 extern void child_resume PARAMS ((int, int, enum target_signal));
176 #ifndef PTRACE_ARG3_TYPE
177 #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
180 extern int call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int));
184 extern int proc_iterate_over_mappings PARAMS ((int (*) (int, CORE_ADDR)));
186 /* From fork-child.c */
188 extern void fork_inferior PARAMS ((char *, char *, char **,
190 int (*) (int), char *));
192 extern void startup_inferior PARAMS ((int));
196 extern void new_tty_prefork PARAMS ((char *));
198 extern int gdb_has_a_terminal PARAMS ((void));
202 extern void start_remote PARAMS ((void));
204 extern void normal_stop PARAMS ((void));
206 extern int signal_stop_state PARAMS ((int));
208 extern int signal_print_state PARAMS ((int));
210 extern int signal_pass_state PARAMS ((int));
214 extern void tty_command PARAMS ((char *, int));
216 extern void attach_command PARAMS ((char *, int));
218 /* Last signal that the inferior received (why it stopped). */
220 extern enum target_signal stop_signal;
222 /* Address at which inferior stopped. */
224 extern CORE_ADDR stop_pc;
226 /* Chain containing status of breakpoint(s) that we have stopped at. */
228 extern bpstat stop_bpstat;
230 /* Flag indicating that a command has proceeded the inferior past the
231 current breakpoint. */
233 extern int breakpoint_proceeded;
235 /* Nonzero if stopped due to a step command. */
237 extern int stop_step;
239 /* Nonzero if stopped due to completion of a stack dummy routine. */
241 extern int stop_stack_dummy;
243 /* Nonzero if program stopped due to a random (unexpected) signal in
246 extern int stopped_by_random_signal;
248 /* Range to single step within.
249 If this is nonzero, respond to a single-step signal
250 by continuing to step if the pc is in this range.
252 If step_range_start and step_range_end are both 1, it means to step for
253 a single instruction (FIXME: it might clean up wait_for_inferior in a
254 minor way if this were changed to the address of the instruction and
255 that address plus one. But maybe not.). */
257 extern CORE_ADDR step_range_start; /* Inclusive */
258 extern CORE_ADDR step_range_end; /* Exclusive */
260 /* Stack frame address as of when stepping command was issued.
261 This is how we know when we step into a subroutine call,
262 and how to set the frame for the breakpoint used to step out. */
264 extern CORE_ADDR step_frame_address;
266 /* Our notion of the current stack pointer. */
268 extern CORE_ADDR step_sp;
270 /* 1 means step over all subroutine calls.
271 -1 means step over calls to undebuggable functions. */
273 extern int step_over_calls;
275 /* If stepping, nonzero means step count is > 1
276 so don't print frame next time inferior stops
277 if it stops due to stepping. */
279 extern int step_multi;
281 /* Nonzero means expecting a trap and caller will handle it themselves.
282 It is used after attach, due to attaching to a process;
283 when running in the shell before the child program has been exec'd;
284 and when running some kinds of remote stuff (FIXME?). */
286 extern int stop_soon_quietly;
288 /* Nonzero if proceed is being used for a "finish" command or a similar
289 situation when stop_registers should be saved. */
291 extern int proceed_to_finish;
293 /* Save register contents here when about to pop a stack dummy frame,
294 if-and-only-if proceed_to_finish is set.
295 Thus this contains the return value from the called function (assuming
296 values are returned in a register). */
298 extern char stop_registers[REGISTER_BYTES];
300 /* Nonzero if the child process in inferior_pid was attached rather
303 extern int attach_flag;
305 /* Sigtramp is a routine that the kernel calls (which then calls the
306 signal handler). On most machines it is a library routine that
307 is linked into the executable.
309 This macro, given a program counter value and the name of the
310 function in which that PC resides (which can be null if the
311 name is not known), returns nonzero if the PC and name show
312 that we are in sigtramp.
314 On most machines just see if the name is sigtramp (and if we have
315 no name, assume we are not in sigtramp). */
316 #if !defined (IN_SIGTRAMP)
317 # if defined (SIGTRAMP_START)
318 # define IN_SIGTRAMP(pc, name) \
319 ((pc) >= SIGTRAMP_START \
320 && (pc) < SIGTRAMP_END \
323 # define IN_SIGTRAMP(pc, name) \
324 (name && STREQ ("_sigtramp", name))
328 /* Possible values for CALL_DUMMY_LOCATION. */
330 #define BEFORE_TEXT_END 2
331 #define AFTER_TEXT_END 3
332 #define AT_ENTRY_POINT 4
334 #if !defined (CALL_DUMMY_LOCATION)
335 #define CALL_DUMMY_LOCATION ON_STACK
336 #endif /* No CALL_DUMMY_LOCATION. */
338 /* Are we in a call dummy? The code below which allows DECR_PC_AFTER_BREAK
339 below is for infrun.c, which may give the macro a pc without that
341 #if !defined (PC_IN_CALL_DUMMY)
342 #if CALL_DUMMY_LOCATION == BEFORE_TEXT_END
343 extern CORE_ADDR text_end;
344 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
345 ((pc) >= text_end - CALL_DUMMY_LENGTH \
346 && (pc) <= text_end + DECR_PC_AFTER_BREAK)
347 #endif /* Before text_end. */
349 #if CALL_DUMMY_LOCATION == AFTER_TEXT_END
350 extern CORE_ADDR text_end;
351 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
353 && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK)
354 #endif /* After text_end. */
356 #if CALL_DUMMY_LOCATION == ON_STACK
357 /* Is the PC in a call dummy? SP and FRAME_ADDRESS are the bottom and
358 top of the stack frame which we are checking, where "bottom" and
359 "top" refer to some section of memory which contains the code for
360 the call dummy. Calls to this macro assume that the contents of
361 SP_REGNUM and FP_REGNUM (or the saved values thereof), respectively,
362 are the things to pass.
364 This won't work on the 29k, where SP_REGNUM and FP_REGNUM don't
365 have that meaning, but the 29k doesn't use ON_STACK. This could be
366 fixed by generalizing this scheme, perhaps by passing in a frame
367 and adding a few fields, at least on machines which need them for
370 Something simpler, like checking for the stack segment, doesn't work,
371 since various programs (threads implementations, gcc nested function
372 stubs, etc) may either allocate stack frames in another segment, or
373 allocate other kinds of code on the stack. */
375 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
376 ((sp) INNER_THAN (pc) && (frame_address != 0) && (pc) INNER_THAN (frame_address))
377 #endif /* On stack. */
379 #if CALL_DUMMY_LOCATION == AT_ENTRY_POINT
380 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
381 ((pc) >= CALL_DUMMY_ADDRESS () \
382 && (pc) <= (CALL_DUMMY_ADDRESS () + DECR_PC_AFTER_BREAK))
383 #endif /* At entry point. */
384 #endif /* No PC_IN_CALL_DUMMY. */
386 #endif /* !defined (INFERIOR_H) */