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