all remaining *.c *.h files from hp merge.
[deliverable/binutils-gdb.git] / gdb / inferior.h
CommitLineData
bd5635a1
RP
1/* Variables that describe the inferior process running under GDB:
2 Where it is, why it stopped, and how to step it.
65b07ddc 3 Copyright 1986, 1989, 1992, 1996, 1998 Free Software Foundation, Inc.
bd5635a1
RP
4
5This file is part of GDB.
6
bdbd5f50 7This program is free software; you can redistribute it and/or modify
bd5635a1 8it under the terms of the GNU General Public License as published by
bdbd5f50
JG
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
bd5635a1 11
bdbd5f50 12This program is distributed in the hope that it will be useful,
bd5635a1
RP
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
bdbd5f50 18along with this program; if not, write to the Free Software
647e52ea 19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
bd5635a1 20
cc221e76
FF
21#if !defined (INFERIOR_H)
22#define INFERIOR_H 1
23
bd5635a1
RP
24/* For bpstat. */
25#include "breakpoint.h"
26
49b476bd
SS
27/* For enum target_signal. */
28#include "target.h"
29
647e52ea
SG
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
35 control variables. */
36
bd5635a1 37struct inferior_status {
49b476bd 38 enum target_signal stop_signal;
100f92e2 39 CORE_ADDR stop_pc;
bd5635a1
RP
40 bpstat stop_bpstat;
41 int stop_step;
42 int stop_stack_dummy;
43 int stopped_by_random_signal;
44 int trap_expected;
45 CORE_ADDR step_range_start;
46 CORE_ADDR step_range_end;
647e52ea 47 CORE_ADDR step_frame_address;
bd5635a1
RP
48 int step_over_calls;
49 CORE_ADDR step_resume_break_address;
50 int stop_after_trap;
51 int stop_soon_quietly;
647e52ea 52 CORE_ADDR selected_frame_address;
bd5635a1 53 char stop_registers[REGISTER_BYTES];
100f92e2
JK
54
55 /* These are here because if call_function_by_hand has written some
56 registers and then decides to call error(), we better not have changed
57 any registers. */
58 char registers[REGISTER_BYTES];
59
65b07ddc 60 int selected_level;
bd5635a1
RP
61 int breakpoint_proceeded;
62 int restore_stack_info;
63 int proceed_to_finish;
64};
65
647e52ea
SG
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. */
69
70#ifndef ARCH_NUM_REGS
71#define ARCH_NUM_REGS NUM_REGS
72#endif
73
74extern void save_inferior_status PARAMS ((struct inferior_status *, int));
cc221e76 75
647e52ea 76extern void restore_inferior_status PARAMS ((struct inferior_status *));
bd5635a1 77
100f92e2 78extern void set_sigint_trap PARAMS ((void));
647e52ea 79
100f92e2
JK
80extern void clear_sigint_trap PARAMS ((void));
81
49b476bd 82extern void set_sigio_trap PARAMS ((void));
647e52ea 83
49b476bd
SS
84extern void clear_sigio_trap PARAMS ((void));
85
bd5635a1
RP
86/* File name for default use for standard in/out in the inferior. */
87
88extern char *inferior_io_terminal;
89
90/* Pid of our debugged inferior, or 0 if no inferior now. */
91
92extern int inferior_pid;
93
65b07ddc
DT
94/* This is only valid when inferior_pid is non-zero.
95
96 If this is 0, then exec events should be noticed and responded to
97 by the debugger (i.e., be reported to the user).
98
99 If this is > 0, then that many subsequent exec events should be
100 ignored (i.e., not be reported to the user).
101 */
102extern int inferior_ignoring_startup_exec_events;
103
104/* This is only valid when inferior_ignoring_startup_exec_events is
105 zero.
106
107 Some targets (stupidly) report more than one exec event per actual
108 call to an event() system call. If only the last such exec event
109 need actually be noticed and responded to by the debugger (i.e.,
110 be reported to the user), then this is the number of "leading"
111 exec events which should be ignored.
112 */
113extern int inferior_ignoring_leading_exec_events;
114
647e52ea
SG
115/* Inferior environment. */
116
117extern struct environ *inferior_environ;
118
bd5635a1
RP
119/* Character array containing an image of the inferior programs' registers. */
120
121extern char registers[];
122
310cc570 123/* Array of validity bits (one per register). Nonzero at position XXX_REGNUM
65b07ddc
DT
124 means that `registers' contains a valid copy of inferior register XXX.
125 -1 if register value is not available. */
310cc570 126
65b07ddc 127extern SIGNED char register_valid[NUM_REGS];
310cc570 128
647e52ea 129extern void clear_proceed_status PARAMS ((void));
cc221e76 130
647e52ea 131extern void proceed PARAMS ((CORE_ADDR, enum target_signal, int));
cc221e76 132
647e52ea 133extern void kill_inferior PARAMS ((void));
cc221e76 134
647e52ea 135extern void generic_mourn_inferior PARAMS ((void));
cc221e76 136
647e52ea 137extern void terminal_ours PARAMS ((void));
cc221e76 138
100f92e2 139extern int run_stack_dummy PARAMS ((CORE_ADDR, char [REGISTER_BYTES]));
cc221e76 140
647e52ea 141extern CORE_ADDR read_pc PARAMS ((void));
cc221e76 142
647e52ea 143extern CORE_ADDR read_pc_pid PARAMS ((int));
49b476bd 144
647e52ea 145extern void write_pc PARAMS ((CORE_ADDR));
cc221e76 146
65b07ddc
DT
147extern void write_pc_pid PARAMS ((CORE_ADDR, int));
148
647e52ea 149extern CORE_ADDR read_sp PARAMS ((void));
23a8e291 150
647e52ea 151extern void write_sp PARAMS ((CORE_ADDR));
23a8e291 152
647e52ea 153extern CORE_ADDR read_fp PARAMS ((void));
23a8e291 154
647e52ea 155extern void write_fp PARAMS ((CORE_ADDR));
23a8e291 156
647e52ea 157extern void wait_for_inferior PARAMS ((void));
cc221e76 158
647e52ea 159extern void init_wait_for_inferior PARAMS ((void));
cc221e76 160
647e52ea 161extern void close_exec_file PARAMS ((void));
cc221e76 162
647e52ea 163extern void reopen_exec_file PARAMS ((void));
cc221e76 164
3aa6856a
JG
165/* The `resume' routine should only be called in special circumstances.
166 Normally, use `proceed', which handles a lot of bookkeeping. */
647e52ea
SG
167
168extern void resume PARAMS ((int, enum target_signal));
310cc570 169
cc221e76
FF
170/* From misc files */
171
647e52ea 172extern void store_inferior_registers PARAMS ((int));
cc221e76 173
647e52ea 174extern void fetch_inferior_registers PARAMS ((int));
cc221e76 175
647e52ea 176extern void solib_create_inferior_hook PARAMS ((void));
cc221e76 177
647e52ea 178extern void child_terminal_info PARAMS ((char *, int));
cc221e76 179
647e52ea 180extern void term_info PARAMS ((char *, int));
cc221e76 181
647e52ea 182extern void terminal_ours_for_output PARAMS ((void));
cc221e76 183
647e52ea 184extern void terminal_inferior PARAMS ((void));
cc221e76 185
647e52ea
SG
186extern void terminal_init_inferior PARAMS ((void));
187
65b07ddc 188extern void terminal_init_inferior_with_pgrp PARAMS ((int pgrp));
cc221e76 189
65b07ddc 190/* From infptrace.c or infttrace.c */
cc221e76 191
647e52ea 192extern int attach PARAMS ((int));
cc221e76 193
65b07ddc
DT
194#if !defined(REQUIRE_ATTACH)
195#define REQUIRE_ATTACH attach
196#endif
197
198#if !defined(REQUIRE_DETACH)
199#define REQUIRE_DETACH(pid,siggnal) detach (siggnal)
200#endif
201
202extern void detach PARAMS ((int));
203
204int proc_wait PARAMS ((int, int *));
cc221e76 205
647e52ea 206extern void child_resume PARAMS ((int, int, enum target_signal));
cc221e76 207
310cc570
RP
208#ifndef PTRACE_ARG3_TYPE
209#define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
210#endif
211
647e52ea 212extern int call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int));
310cc570 213
65b07ddc
DT
214extern void pre_fork_inferior PARAMS ((void));
215
cc221e76
FF
216/* From procfs.c */
217
647e52ea 218extern int proc_iterate_over_mappings PARAMS ((int (*) (int, CORE_ADDR)));
cc221e76 219
65b07ddc
DT
220extern int procfs_first_available PARAMS ((void));
221
222extern int procfs_get_pid_fd PARAMS ((int));
223
34517ebc 224/* From fork-child.c */
bd5635a1 225
49b476bd 226extern void fork_inferior PARAMS ((char *, char *, char **,
65b07ddc
DT
227 void (*) (void),
228 void (*) (int),
229 void (*) (void),
230 char *));
231
232
233extern void
234clone_and_follow_inferior PARAMS ((int, int *));
49b476bd
SS
235
236extern void startup_inferior PARAMS ((int));
cc221e76
FF
237
238/* From inflow.c */
239
647e52ea 240extern void new_tty_prefork PARAMS ((char *));
cc221e76 241
23a8e291
JK
242extern int gdb_has_a_terminal PARAMS ((void));
243
cc221e76
FF
244/* From infrun.c */
245
647e52ea 246extern void start_remote PARAMS ((void));
cc221e76 247
647e52ea 248extern void normal_stop PARAMS ((void));
cc221e76 249
647e52ea 250extern int signal_stop_state PARAMS ((int));
cc221e76 251
647e52ea 252extern int signal_print_state PARAMS ((int));
cc221e76 253
647e52ea 254extern int signal_pass_state PARAMS ((int));
cc221e76
FF
255
256/* From infcmd.c */
257
647e52ea 258extern void tty_command PARAMS ((char *, int));
cc221e76 259
647e52ea 260extern void attach_command PARAMS ((char *, int));
cc221e76 261
bd5635a1
RP
262/* Last signal that the inferior received (why it stopped). */
263
49b476bd 264extern enum target_signal stop_signal;
bd5635a1
RP
265
266/* Address at which inferior stopped. */
267
268extern CORE_ADDR stop_pc;
269
bd5635a1
RP
270/* Chain containing status of breakpoint(s) that we have stopped at. */
271
272extern bpstat stop_bpstat;
273
274/* Flag indicating that a command has proceeded the inferior past the
275 current breakpoint. */
276
277extern int breakpoint_proceeded;
278
279/* Nonzero if stopped due to a step command. */
280
281extern int stop_step;
282
283/* Nonzero if stopped due to completion of a stack dummy routine. */
284
285extern int stop_stack_dummy;
286
287/* Nonzero if program stopped due to a random (unexpected) signal in
288 inferior process. */
289
290extern int stopped_by_random_signal;
291
292/* Range to single step within.
293 If this is nonzero, respond to a single-step signal
100f92e2
JK
294 by continuing to step if the pc is in this range.
295
296 If step_range_start and step_range_end are both 1, it means to step for
297 a single instruction (FIXME: it might clean up wait_for_inferior in a
298 minor way if this were changed to the address of the instruction and
299 that address plus one. But maybe not.). */
bd5635a1
RP
300
301extern CORE_ADDR step_range_start; /* Inclusive */
302extern CORE_ADDR step_range_end; /* Exclusive */
303
304/* Stack frame address as of when stepping command was issued.
305 This is how we know when we step into a subroutine call,
306 and how to set the frame for the breakpoint used to step out. */
307
647e52ea
SG
308extern CORE_ADDR step_frame_address;
309
310/* Our notion of the current stack pointer. */
311
312extern CORE_ADDR step_sp;
bd5635a1
RP
313
314/* 1 means step over all subroutine calls.
315 -1 means step over calls to undebuggable functions. */
316
317extern int step_over_calls;
318
319/* If stepping, nonzero means step count is > 1
320 so don't print frame next time inferior stops
321 if it stops due to stepping. */
322
323extern int step_multi;
324
bdbd5f50
JG
325/* Nonzero means expecting a trap and caller will handle it themselves.
326 It is used after attach, due to attaching to a process;
327 when running in the shell before the child program has been exec'd;
328 and when running some kinds of remote stuff (FIXME?). */
329
cc221e76 330extern int stop_soon_quietly;
bdbd5f50 331
bd5635a1
RP
332/* Nonzero if proceed is being used for a "finish" command or a similar
333 situation when stop_registers should be saved. */
334
335extern int proceed_to_finish;
336
337/* Save register contents here when about to pop a stack dummy frame,
338 if-and-only-if proceed_to_finish is set.
339 Thus this contains the return value from the called function (assuming
340 values are returned in a register). */
341
342extern char stop_registers[REGISTER_BYTES];
343
bd5635a1
RP
344/* Nonzero if the child process in inferior_pid was attached rather
345 than forked. */
346
cc221e76 347extern int attach_flag;
bd5635a1 348\f
23a8e291
JK
349/* Sigtramp is a routine that the kernel calls (which then calls the
350 signal handler). On most machines it is a library routine that
351 is linked into the executable.
352
353 This macro, given a program counter value and the name of the
354 function in which that PC resides (which can be null if the
355 name is not known), returns nonzero if the PC and name show
356 that we are in sigtramp.
357
358 On most machines just see if the name is sigtramp (and if we have
359 no name, assume we are not in sigtramp). */
360#if !defined (IN_SIGTRAMP)
361# if defined (SIGTRAMP_START)
362# define IN_SIGTRAMP(pc, name) \
65b07ddc
DT
363 ((pc) >= SIGTRAMP_START(pc) \
364 && (pc) < SIGTRAMP_END(pc) \
23a8e291
JK
365 )
366# else
367# define IN_SIGTRAMP(pc, name) \
368 (name && STREQ ("_sigtramp", name))
369# endif
370#endif
371\f
bd5635a1
RP
372/* Possible values for CALL_DUMMY_LOCATION. */
373#define ON_STACK 1
374#define BEFORE_TEXT_END 2
375#define AFTER_TEXT_END 3
100f92e2 376#define AT_ENTRY_POINT 4
bd5635a1
RP
377
378#if !defined (CALL_DUMMY_LOCATION)
bd5635a1 379#define CALL_DUMMY_LOCATION ON_STACK
bd5635a1
RP
380#endif /* No CALL_DUMMY_LOCATION. */
381
382/* Are we in a call dummy? The code below which allows DECR_PC_AFTER_BREAK
383 below is for infrun.c, which may give the macro a pc without that
384 subtracted out. */
385#if !defined (PC_IN_CALL_DUMMY)
386#if CALL_DUMMY_LOCATION == BEFORE_TEXT_END
cc221e76 387extern CORE_ADDR text_end;
bd5635a1
RP
388#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
389 ((pc) >= text_end - CALL_DUMMY_LENGTH \
34517ebc 390 && (pc) <= text_end + DECR_PC_AFTER_BREAK)
100f92e2
JK
391#endif /* Before text_end. */
392
bd5635a1 393#if CALL_DUMMY_LOCATION == AFTER_TEXT_END
cc221e76 394extern CORE_ADDR text_end;
bd5635a1
RP
395#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
396 ((pc) >= text_end \
34517ebc 397 && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK)
100f92e2 398#endif /* After text_end. */
f49cf589 399
100f92e2 400#if CALL_DUMMY_LOCATION == ON_STACK
23a8e291
JK
401/* Is the PC in a call dummy? SP and FRAME_ADDRESS are the bottom and
402 top of the stack frame which we are checking, where "bottom" and
403 "top" refer to some section of memory which contains the code for
404 the call dummy. Calls to this macro assume that the contents of
405 SP_REGNUM and FP_REGNUM (or the saved values thereof), respectively,
406 are the things to pass.
407
408 This won't work on the 29k, where SP_REGNUM and FP_REGNUM don't
409 have that meaning, but the 29k doesn't use ON_STACK. This could be
410 fixed by generalizing this scheme, perhaps by passing in a frame
411 and adding a few fields, at least on machines which need them for
412 PC_IN_CALL_DUMMY.
413
414 Something simpler, like checking for the stack segment, doesn't work,
415 since various programs (threads implementations, gcc nested function
416 stubs, etc) may either allocate stack frames in another segment, or
417 allocate other kinds of code on the stack. */
f49cf589 418
bd5635a1 419#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
65b07ddc 420 (INNER_THAN ((sp), (pc)) && (frame_address != 0) && INNER_THAN ((pc), (frame_address)))
bd5635a1 421#endif /* On stack. */
100f92e2
JK
422
423#if CALL_DUMMY_LOCATION == AT_ENTRY_POINT
100f92e2 424#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
49b476bd
SS
425 ((pc) >= CALL_DUMMY_ADDRESS () \
426 && (pc) <= (CALL_DUMMY_ADDRESS () + DECR_PC_AFTER_BREAK))
100f92e2 427#endif /* At entry point. */
bd5635a1 428#endif /* No PC_IN_CALL_DUMMY. */
cc221e76 429
65b07ddc
DT
430/* It's often not enough for our clients to know whether the PC is merely
431 somewhere within the call dummy. They may need to know whether the
432 call dummy has actually completed. (For example, wait_for_inferior
433 wants to know when it should truly stop because the call dummy has
434 completed. If we're single-stepping because of slow watchpoints,
435 then we may find ourselves stopped at the entry of the call dummy,
436 and want to continue stepping until we reach the end.)
437
438 Note that this macro is intended for targets (like HP-UX) which
439 require more than a single breakpoint in their call dummies, and
440 therefore cannot use the CALL_DUMMY_BREAKPOINT_OFFSET mechanism.
441
442 If a target does define CALL_DUMMY_BREAKPOINT_OFFSET, then this
443 default implementation of CALL_DUMMY_HAS_COMPLETED is sufficient.
444 Else, a target may wish to supply an implementation that works in
445 the presense of multiple breakpoints in its call dummy.
446 */
447#if !defined(CALL_DUMMY_HAS_COMPLETED)
448#define CALL_DUMMY_HAS_COMPLETED(pc, sp, frame_address) \
449 PC_IN_CALL_DUMMY((pc), (sp), (frame_address))
450#endif
451
452/* If STARTUP_WITH_SHELL is set, GDB's "run"
453 * will attempts to start up the debugee under a shell.
454 * This is in order for argument-expansion to occur. E.g.,
455 * (gdb) run *
456 * The "*" gets expanded by the shell into a list of files.
457 * While this is a nice feature, it turns out to interact badly
458 * with some of the catch-fork/catch-exec features we have added.
459 * In particular, if the shell does any fork/exec's before
460 * the exec of the target program, that can confuse GDB.
461 * To disable this feature, set STARTUP_WITH_SHELL to 0.
462 * To enable this feature, set STARTUP_WITH_SHELL to 1.
463 * The catch-exec traps expected during start-up will
464 * be 1 if target is not started up with a shell, 2 if it is.
465 * - RT
466 */
467#define STARTUP_WITH_SHELL 1
468#define START_INFERIOR_TRAPS_EXPECTED (STARTUP_WITH_SHELL + 1)
469
cc221e76 470#endif /* !defined (INFERIOR_H) */
65b07ddc 471
This page took 0.409951 seconds and 4 git commands to generate.