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
{
41 FRAME_ADDR stop_frame_address
;
45 int stopped_by_random_signal
;
47 CORE_ADDR step_range_start
;
48 CORE_ADDR step_range_end
;
49 FRAME_ADDR step_frame_address
;
51 CORE_ADDR step_resume_break_address
;
53 int stop_soon_quietly
;
54 FRAME_ADDR selected_frame_address
;
56 char stop_registers
[REGISTER_BYTES
];
58 /* These are here because if call_function_by_hand has written some
59 registers and then decides to call error(), we better not have changed
61 char registers
[REGISTER_BYTES
];
63 int breakpoint_proceeded
;
64 int restore_stack_info
;
65 int proceed_to_finish
;
69 save_inferior_status
PARAMS ((struct inferior_status
*, int));
72 restore_inferior_status
PARAMS ((struct inferior_status
*));
74 extern void set_sigint_trap
PARAMS ((void));
75 extern void clear_sigint_trap
PARAMS ((void));
77 /* File name for default use for standard in/out in the inferior. */
79 extern char *inferior_io_terminal
;
81 /* Pid of our debugged inferior, or 0 if no inferior now. */
83 extern int inferior_pid
;
85 /* Character array containing an image of the inferior programs' registers. */
87 extern char registers
[];
89 /* Array of validity bits (one per register). Nonzero at position XXX_REGNUM
90 means that `registers' contains a valid copy of inferior register XXX. */
92 extern char register_valid
[NUM_REGS
];
95 clear_proceed_status
PARAMS ((void));
98 proceed
PARAMS ((CORE_ADDR
, int, int));
101 kill_inferior
PARAMS ((void));
104 generic_mourn_inferior
PARAMS ((void));
107 terminal_ours
PARAMS ((void));
109 extern int run_stack_dummy
PARAMS ((CORE_ADDR
, char [REGISTER_BYTES
]));
112 read_pc
PARAMS ((void));
115 write_pc
PARAMS ((CORE_ADDR
));
118 read_sp
PARAMS ((void));
121 write_sp
PARAMS ((CORE_ADDR
));
124 read_fp
PARAMS ((void));
127 write_fp
PARAMS ((CORE_ADDR
));
130 wait_for_inferior
PARAMS ((void));
133 init_wait_for_inferior
PARAMS ((void));
136 close_exec_file
PARAMS ((void));
139 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 resume
PARAMS ((int, int));
146 /* From misc files */
149 store_inferior_registers
PARAMS ((int));
152 fetch_inferior_registers
PARAMS ((int));
155 solib_create_inferior_hook
PARAMS ((void));
158 child_terminal_info
PARAMS ((char *, int));
161 term_info
PARAMS ((char *, int));
164 terminal_ours_for_output
PARAMS ((void));
167 terminal_inferior
PARAMS ((void));
170 terminal_init_inferior
PARAMS ((void));
172 /* From infptrace.c */
175 attach
PARAMS ((int));
178 detach
PARAMS ((int));
181 child_resume
PARAMS ((int, int, int));
183 #ifndef PTRACE_ARG3_TYPE
184 #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
188 call_ptrace
PARAMS ((int, int, PTRACE_ARG3_TYPE
, int));
193 proc_iterate_over_mappings
PARAMS ((int (*) (int, CORE_ADDR
)));
195 /* From fork-child.c */
198 fork_inferior
PARAMS ((char *, char *, char **,
205 new_tty_prefork
PARAMS ((char *));
207 extern int gdb_has_a_terminal
PARAMS ((void));
212 start_remote
PARAMS ((void));
215 normal_stop
PARAMS ((void));
218 signal_stop_state
PARAMS ((int));
221 signal_print_state
PARAMS ((int));
224 signal_pass_state
PARAMS ((int));
229 tty_command
PARAMS ((char *, int));
232 attach_command
PARAMS ((char *, int));
234 /* Last signal that the inferior received (why it stopped). */
236 extern int stop_signal
;
238 /* Address at which inferior stopped. */
240 extern CORE_ADDR stop_pc
;
242 /* Stack frame when program stopped. */
244 extern FRAME_ADDR stop_frame_address
;
246 /* Chain containing status of breakpoint(s) that we have stopped at. */
248 extern bpstat stop_bpstat
;
250 /* Flag indicating that a command has proceeded the inferior past the
251 current breakpoint. */
253 extern int breakpoint_proceeded
;
255 /* Nonzero if stopped due to a step command. */
257 extern int stop_step
;
259 /* Nonzero if stopped due to completion of a stack dummy routine. */
261 extern int stop_stack_dummy
;
263 /* Nonzero if program stopped due to a random (unexpected) signal in
266 extern int stopped_by_random_signal
;
268 /* Range to single step within.
269 If this is nonzero, respond to a single-step signal
270 by continuing to step if the pc is in this range.
272 If step_range_start and step_range_end are both 1, it means to step for
273 a single instruction (FIXME: it might clean up wait_for_inferior in a
274 minor way if this were changed to the address of the instruction and
275 that address plus one. But maybe not.). */
277 extern CORE_ADDR step_range_start
; /* Inclusive */
278 extern CORE_ADDR step_range_end
; /* Exclusive */
280 /* Stack frame address as of when stepping command was issued.
281 This is how we know when we step into a subroutine call,
282 and how to set the frame for the breakpoint used to step out. */
284 extern FRAME_ADDR step_frame_address
;
286 /* 1 means step over all subroutine calls.
287 -1 means step over calls to undebuggable functions. */
289 extern int step_over_calls
;
291 /* If stepping, nonzero means step count is > 1
292 so don't print frame next time inferior stops
293 if it stops due to stepping. */
295 extern int step_multi
;
297 /* Nonzero means expecting a trap and caller will handle it themselves.
298 It is used after attach, due to attaching to a process;
299 when running in the shell before the child program has been exec'd;
300 and when running some kinds of remote stuff (FIXME?). */
302 extern int stop_soon_quietly
;
304 /* Nonzero if proceed is being used for a "finish" command or a similar
305 situation when stop_registers should be saved. */
307 extern int proceed_to_finish
;
309 /* Save register contents here when about to pop a stack dummy frame,
310 if-and-only-if proceed_to_finish is set.
311 Thus this contains the return value from the called function (assuming
312 values are returned in a register). */
314 extern char stop_registers
[REGISTER_BYTES
];
316 /* Nonzero if the child process in inferior_pid was attached rather
319 extern int attach_flag
;
321 /* Sigtramp is a routine that the kernel calls (which then calls the
322 signal handler). On most machines it is a library routine that
323 is linked into the executable.
325 This macro, given a program counter value and the name of the
326 function in which that PC resides (which can be null if the
327 name is not known), returns nonzero if the PC and name show
328 that we are in sigtramp.
330 On most machines just see if the name is sigtramp (and if we have
331 no name, assume we are not in sigtramp). */
332 #if !defined (IN_SIGTRAMP)
333 # if defined (SIGTRAMP_START)
334 # define IN_SIGTRAMP(pc, name) \
335 ((pc) >= SIGTRAMP_START \
336 && (pc) < SIGTRAMP_END \
339 # define IN_SIGTRAMP(pc, name) \
340 (name && STREQ ("_sigtramp", name))
344 /* Possible values for CALL_DUMMY_LOCATION. */
346 #define BEFORE_TEXT_END 2
347 #define AFTER_TEXT_END 3
348 #define AT_ENTRY_POINT 4
350 #if !defined (CALL_DUMMY_LOCATION)
351 #define CALL_DUMMY_LOCATION ON_STACK
352 #endif /* No CALL_DUMMY_LOCATION. */
354 /* Are we in a call dummy? The code below which allows DECR_PC_AFTER_BREAK
355 below is for infrun.c, which may give the macro a pc without that
357 #if !defined (PC_IN_CALL_DUMMY)
358 #if CALL_DUMMY_LOCATION == BEFORE_TEXT_END
359 extern CORE_ADDR text_end
;
360 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
361 ((pc) >= text_end - CALL_DUMMY_LENGTH \
362 && (pc) <= text_end + DECR_PC_AFTER_BREAK)
363 #endif /* Before text_end. */
365 #if CALL_DUMMY_LOCATION == AFTER_TEXT_END
366 extern CORE_ADDR text_end
;
367 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
369 && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK)
370 #endif /* After text_end. */
372 #if CALL_DUMMY_LOCATION == ON_STACK
373 /* Is the PC in a call dummy? SP and FRAME_ADDRESS are the bottom and
374 top of the stack frame which we are checking, where "bottom" and
375 "top" refer to some section of memory which contains the code for
376 the call dummy. Calls to this macro assume that the contents of
377 SP_REGNUM and FP_REGNUM (or the saved values thereof), respectively,
378 are the things to pass.
380 This won't work on the 29k, where SP_REGNUM and FP_REGNUM don't
381 have that meaning, but the 29k doesn't use ON_STACK. This could be
382 fixed by generalizing this scheme, perhaps by passing in a frame
383 and adding a few fields, at least on machines which need them for
386 Something simpler, like checking for the stack segment, doesn't work,
387 since various programs (threads implementations, gcc nested function
388 stubs, etc) may either allocate stack frames in another segment, or
389 allocate other kinds of code on the stack. */
391 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
392 ((sp) INNER_THAN (pc) && (frame_address != 0) && (pc) INNER_THAN (frame_address))
393 #endif /* On stack. */
395 #if CALL_DUMMY_LOCATION == AT_ENTRY_POINT
397 entry_point_address
PARAMS ((void));
398 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
399 ((pc) >= entry_point_address () \
400 && (pc) <= (entry_point_address () + DECR_PC_AFTER_BREAK))
401 #endif /* At entry point. */
402 #endif /* No PC_IN_CALL_DUMMY. */
404 #endif /* !defined (INFERIOR_H) */