Fri Apr 7 13:44:38 2000 glen mccready <gkm@pobox.com>
[deliverable/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
c5aa993b 5 This file is part of GDB.
c906108c 6
c5aa993b
JM
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.
c906108c 11
c5aa993b
JM
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.
c906108c 16
c5aa993b
JM
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,
20 Boston, MA 02111-1307, USA. */
c906108c
SS
21
22#if !defined (INFERIOR_H)
23#define INFERIOR_H 1
24
25/* For bpstat. */
26#include "breakpoint.h"
27
28/* For enum target_signal. */
29#include "target.h"
30
7a292a7a 31/* Structure in which to save the status of the inferior. Create/Save
c906108c
SS
32 through "save_inferior_status", restore through
33 "restore_inferior_status".
7a292a7a 34
c906108c
SS
35 This pair of routines should be called around any transfer of
36 control to the inferior which you don't want showing up in your
37 control variables. */
38
7a292a7a 39struct inferior_status;
7a292a7a
SS
40
41extern struct inferior_status *save_inferior_status PARAMS ((int));
42
43extern void restore_inferior_status PARAMS ((struct inferior_status *));
44
45extern void discard_inferior_status PARAMS ((struct inferior_status *));
46
c5aa993b 47extern void write_inferior_status_register PARAMS ((struct inferior_status * inf_status, int regno, LONGEST val));
c906108c
SS
48
49/* This macro gives the number of registers actually in use by the
50 inferior. This may be less than the total number of registers,
51 perhaps depending on the actual CPU in use or program being run. */
52
53#ifndef ARCH_NUM_REGS
54#define ARCH_NUM_REGS NUM_REGS
55#endif
56
c906108c
SS
57extern void set_sigint_trap PARAMS ((void));
58
59extern void clear_sigint_trap PARAMS ((void));
60
61extern void set_sigio_trap PARAMS ((void));
62
63extern void clear_sigio_trap PARAMS ((void));
64
65/* File name for default use for standard in/out in the inferior. */
66
67extern char *inferior_io_terminal;
68
69/* Pid of our debugged inferior, or 0 if no inferior now. */
70
71extern int inferior_pid;
72
43ff13b4
JM
73/* Is the inferior running right now, as a result of a 'run&',
74 'continue&' etc command? This is used in asycn gdb to determine
75 whether a command that the user enters while the target is running
76 is allowed or not. */
77extern int target_executing;
78
79/* Are we simulating synchronous execution? This is used in async gdb
80 to implement the 'run', 'continue' etc commands, which will not
81 redisplay the prompt until the execution is actually over. */
82extern int sync_execution;
83
c906108c
SS
84/* This is only valid when inferior_pid is non-zero.
85
86 If this is 0, then exec events should be noticed and responded to
87 by the debugger (i.e., be reported to the user).
88
89 If this is > 0, then that many subsequent exec events should be
90 ignored (i.e., not be reported to the user).
c5aa993b 91 */
c906108c
SS
92extern int inferior_ignoring_startup_exec_events;
93
94/* This is only valid when inferior_ignoring_startup_exec_events is
95 zero.
96
97 Some targets (stupidly) report more than one exec event per actual
98 call to an event() system call. If only the last such exec event
99 need actually be noticed and responded to by the debugger (i.e.,
100 be reported to the user), then this is the number of "leading"
101 exec events which should be ignored.
c5aa993b 102 */
c906108c
SS
103extern int inferior_ignoring_leading_exec_events;
104
105/* Inferior environment. */
106
107extern struct environ *inferior_environ;
108
7a292a7a
SS
109/* Character array containing an image of the inferior programs'
110 registers. */
c906108c 111
7a292a7a 112extern char *registers;
c906108c 113
7a292a7a
SS
114/* Character array containing the current state of each register
115 (unavailable<0, valid=0, invalid>0). */
c906108c 116
7a292a7a 117extern signed char *register_valid;
c906108c
SS
118
119extern void clear_proceed_status PARAMS ((void));
120
121extern void proceed PARAMS ((CORE_ADDR, enum target_signal, int));
122
123extern void kill_inferior PARAMS ((void));
124
125extern void generic_mourn_inferior PARAMS ((void));
126
127extern void terminal_ours PARAMS ((void));
128
c5aa993b 129extern int run_stack_dummy PARAMS ((CORE_ADDR, char *));
c906108c
SS
130
131extern CORE_ADDR read_pc PARAMS ((void));
132
133extern CORE_ADDR read_pc_pid PARAMS ((int));
134
0f71a2f6
JM
135extern CORE_ADDR generic_target_read_pc PARAMS ((int));
136
c906108c
SS
137extern void write_pc PARAMS ((CORE_ADDR));
138
139extern void write_pc_pid PARAMS ((CORE_ADDR, int));
140
0f71a2f6
JM
141extern void generic_target_write_pc PARAMS ((CORE_ADDR, int));
142
c906108c
SS
143extern CORE_ADDR read_sp PARAMS ((void));
144
0f71a2f6
JM
145extern CORE_ADDR generic_target_read_sp PARAMS ((void));
146
c906108c
SS
147extern void write_sp PARAMS ((CORE_ADDR));
148
0f71a2f6
JM
149extern void generic_target_write_sp PARAMS ((CORE_ADDR));
150
c906108c
SS
151extern CORE_ADDR read_fp PARAMS ((void));
152
0f71a2f6
JM
153extern CORE_ADDR generic_target_read_fp PARAMS ((void));
154
c906108c
SS
155extern void write_fp PARAMS ((CORE_ADDR));
156
0f71a2f6
JM
157extern void generic_target_write_fp PARAMS ((CORE_ADDR));
158
4478b372
JB
159extern CORE_ADDR generic_pointer_to_address (struct type *type, char *buf);
160
161extern void generic_address_to_pointer (struct type *type, char *buf,
162 CORE_ADDR addr);
163
c906108c
SS
164extern void wait_for_inferior PARAMS ((void));
165
c2c6d25f 166extern void fetch_inferior_event PARAMS ((void *));
43ff13b4 167
c906108c
SS
168extern void init_wait_for_inferior PARAMS ((void));
169
170extern void close_exec_file PARAMS ((void));
171
172extern void reopen_exec_file PARAMS ((void));
173
174/* The `resume' routine should only be called in special circumstances.
175 Normally, use `proceed', which handles a lot of bookkeeping. */
176
177extern void resume PARAMS ((int, enum target_signal));
178
179/* From misc files */
180
181extern void store_inferior_registers PARAMS ((int));
182
183extern void fetch_inferior_registers PARAMS ((int));
184
185extern void solib_create_inferior_hook PARAMS ((void));
186
187extern void child_terminal_info PARAMS ((char *, int));
188
189extern void term_info PARAMS ((char *, int));
190
191extern void terminal_ours_for_output PARAMS ((void));
192
193extern void terminal_inferior PARAMS ((void));
194
195extern void terminal_init_inferior PARAMS ((void));
196
197extern void terminal_init_inferior_with_pgrp PARAMS ((int pgrp));
198
199/* From infptrace.c or infttrace.c */
200
201extern int attach PARAMS ((int));
202
203#if !defined(REQUIRE_ATTACH)
204#define REQUIRE_ATTACH attach
205#endif
206
207#if !defined(REQUIRE_DETACH)
208#define REQUIRE_DETACH(pid,siggnal) detach (siggnal)
209#endif
210
211extern void detach PARAMS ((int));
212
7a292a7a 213/* PTRACE method of waiting for inferior process. */
c906108c
SS
214int ptrace_wait PARAMS ((int, int *));
215
216extern void child_resume PARAMS ((int, int, enum target_signal));
217
218#ifndef PTRACE_ARG3_TYPE
219#define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
220#endif
221
222extern int call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int));
223
224extern void pre_fork_inferior PARAMS ((void));
225
226/* From procfs.c */
227
228extern int proc_iterate_over_mappings PARAMS ((int (*)(int, CORE_ADDR)));
229
230extern int procfs_first_available PARAMS ((void));
231
c906108c
SS
232/* From fork-child.c */
233
234extern void fork_inferior PARAMS ((char *, char *, char **,
235 void (*)(void),
236 void (*)(int),
237 void (*)(void),
238 char *));
239
240
241extern void
242clone_and_follow_inferior PARAMS ((int, int *));
243
244extern void startup_inferior PARAMS ((int));
245
246/* From inflow.c */
247
248extern void new_tty_prefork PARAMS ((char *));
249
250extern int gdb_has_a_terminal PARAMS ((void));
251
252/* From infrun.c */
253
254extern void start_remote PARAMS ((void));
255
256extern void normal_stop PARAMS ((void));
257
258extern int signal_stop_state PARAMS ((int));
259
260extern int signal_print_state PARAMS ((int));
261
262extern int signal_pass_state PARAMS ((int));
263
d4f3574e
SS
264extern int signal_stop_update PARAMS ((int, int));
265
266extern int signal_print_update PARAMS ((int, int));
267
268extern int signal_pass_update PARAMS ((int, int));
269
c906108c
SS
270/* From infcmd.c */
271
272extern void tty_command PARAMS ((char *, int));
273
274extern void attach_command PARAMS ((char *, int));
275
276/* Last signal that the inferior received (why it stopped). */
277
278extern enum target_signal stop_signal;
279
280/* Address at which inferior stopped. */
281
282extern CORE_ADDR stop_pc;
283
284/* Chain containing status of breakpoint(s) that we have stopped at. */
285
286extern bpstat stop_bpstat;
287
288/* Flag indicating that a command has proceeded the inferior past the
289 current breakpoint. */
290
291extern int breakpoint_proceeded;
292
293/* Nonzero if stopped due to a step command. */
294
295extern int stop_step;
296
297/* Nonzero if stopped due to completion of a stack dummy routine. */
298
299extern int stop_stack_dummy;
300
301/* Nonzero if program stopped due to a random (unexpected) signal in
302 inferior process. */
303
304extern int stopped_by_random_signal;
305
306/* Range to single step within.
307 If this is nonzero, respond to a single-step signal
308 by continuing to step if the pc is in this range.
309
310 If step_range_start and step_range_end are both 1, it means to step for
311 a single instruction (FIXME: it might clean up wait_for_inferior in a
312 minor way if this were changed to the address of the instruction and
313 that address plus one. But maybe not.). */
314
315extern CORE_ADDR step_range_start; /* Inclusive */
c5aa993b 316extern CORE_ADDR step_range_end; /* Exclusive */
c906108c
SS
317
318/* Stack frame address as of when stepping command was issued.
319 This is how we know when we step into a subroutine call,
320 and how to set the frame for the breakpoint used to step out. */
321
322extern CORE_ADDR step_frame_address;
323
324/* Our notion of the current stack pointer. */
325
326extern CORE_ADDR step_sp;
327
328/* 1 means step over all subroutine calls.
329 -1 means step over calls to undebuggable functions. */
330
331extern int step_over_calls;
332
333/* If stepping, nonzero means step count is > 1
334 so don't print frame next time inferior stops
335 if it stops due to stepping. */
336
337extern int step_multi;
338
339/* Nonzero means expecting a trap and caller will handle it themselves.
340 It is used after attach, due to attaching to a process;
341 when running in the shell before the child program has been exec'd;
342 and when running some kinds of remote stuff (FIXME?). */
343
344extern int stop_soon_quietly;
345
346/* Nonzero if proceed is being used for a "finish" command or a similar
347 situation when stop_registers should be saved. */
348
349extern int proceed_to_finish;
350
351/* Save register contents here when about to pop a stack dummy frame,
352 if-and-only-if proceed_to_finish is set.
353 Thus this contains the return value from the called function (assuming
354 values are returned in a register). */
355
7a292a7a 356extern char *stop_registers;
c906108c
SS
357
358/* Nonzero if the child process in inferior_pid was attached rather
359 than forked. */
360
361extern int attach_flag;
362\f
363/* Sigtramp is a routine that the kernel calls (which then calls the
364 signal handler). On most machines it is a library routine that
365 is linked into the executable.
366
367 This macro, given a program counter value and the name of the
368 function in which that PC resides (which can be null if the
369 name is not known), returns nonzero if the PC and name show
370 that we are in sigtramp.
371
372 On most machines just see if the name is sigtramp (and if we have
373 no name, assume we are not in sigtramp). */
374#if !defined (IN_SIGTRAMP)
375#if defined (SIGTRAMP_START)
376#define IN_SIGTRAMP(pc, name) \
377 ((pc) >= SIGTRAMP_START(pc) \
378 && (pc) < SIGTRAMP_END(pc) \
379 )
380#else
381#define IN_SIGTRAMP(pc, name) \
382 (name && STREQ ("_sigtramp", name))
383#endif
384#endif
385\f
386/* Possible values for CALL_DUMMY_LOCATION. */
387#define ON_STACK 1
388#define BEFORE_TEXT_END 2
389#define AFTER_TEXT_END 3
390#define AT_ENTRY_POINT 4
391
7a292a7a
SS
392#if !defined (USE_GENERIC_DUMMY_FRAMES)
393#define USE_GENERIC_DUMMY_FRAMES 0
394#endif
395
c906108c
SS
396#if !defined (CALL_DUMMY_LOCATION)
397#define CALL_DUMMY_LOCATION ON_STACK
398#endif /* No CALL_DUMMY_LOCATION. */
399
7a292a7a 400#if !defined (CALL_DUMMY_ADDRESS)
11cf8741 401#define CALL_DUMMY_ADDRESS() (internal_error ("CALL_DUMMY_ADDRESS"), 0)
7a292a7a
SS
402#endif
403#if !defined (CALL_DUMMY_START_OFFSET)
11cf8741 404#define CALL_DUMMY_START_OFFSET (internal_error ("CALL_DUMMY_START_OFFSET"), 0)
7a292a7a
SS
405#endif
406#if !defined (CALL_DUMMY_BREAKPOINT_OFFSET)
407#define CALL_DUMMY_BREAKPOINT_OFFSET_P (0)
11cf8741 408#define CALL_DUMMY_BREAKPOINT_OFFSET (internal_error ("CALL_DUMMY_BREAKPOINT_OFFSET"), 0)
7a292a7a
SS
409#endif
410#if !defined CALL_DUMMY_BREAKPOINT_OFFSET_P
411#define CALL_DUMMY_BREAKPOINT_OFFSET_P (1)
412#endif
413#if !defined (CALL_DUMMY_LENGTH)
11cf8741 414#define CALL_DUMMY_LENGTH (internal_error ("CALL_DUMMY_LENGTH"), 0)
7a292a7a
SS
415#endif
416
417#if defined (CALL_DUMMY_STACK_ADJUST)
418#if !defined (CALL_DUMMY_STACK_ADJUST_P)
419#define CALL_DUMMY_STACK_ADJUST_P (1)
420#endif
421#endif
422#if !defined (CALL_DUMMY_STACK_ADJUST)
11cf8741 423#define CALL_DUMMY_STACK_ADJUST (internal_error ("CALL_DUMMY_STACK_ADJUST"), 0)
7a292a7a
SS
424#endif
425#if !defined (CALL_DUMMY_STACK_ADJUST_P)
426#define CALL_DUMMY_STACK_ADJUST_P (0)
427#endif
428
ba886e9d
AC
429/* FIXME: cagney/2000-04-17: gdbarch should manage this. The default
430 shouldn't be necessary. */
431
7a292a7a
SS
432#if !defined (CALL_DUMMY_P)
433#if defined (CALL_DUMMY)
434#define CALL_DUMMY_P 1
435#else
436#define CALL_DUMMY_P 0
437#endif
438#endif
439
7a292a7a 440#if !defined PUSH_DUMMY_FRAME
11cf8741 441#define PUSH_DUMMY_FRAME (internal_error ("PUSH_DUMMY_FRAME"), 0)
7a292a7a
SS
442#endif
443
444#if !defined FIX_CALL_DUMMY
11cf8741 445#define FIX_CALL_DUMMY(a1,a2,a3,a4,a5,a6,a7) (internal_error ("FIX_CALL_DUMMY"), 0)
7a292a7a
SS
446#endif
447
448#if !defined STORE_STRUCT_RETURN
11cf8741 449#define STORE_STRUCT_RETURN(a1,a2) (internal_error ("STORE_STRUCT_RETURN"), 0)
7a292a7a
SS
450#endif
451
452
453/* Are we in a call dummy? */
454
455extern int pc_in_call_dummy_before_text_end PARAMS ((CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address));
0f71a2f6 456#if !GDB_MULTI_ARCH
7a292a7a
SS
457#if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == BEFORE_TEXT_END
458#define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_before_text_end (pc, sp, frame_address)
c906108c 459#endif /* Before text_end. */
0f71a2f6 460#endif
c906108c 461
7a292a7a 462extern int pc_in_call_dummy_after_text_end PARAMS ((CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address));
0f71a2f6 463#if !GDB_MULTI_ARCH
7a292a7a 464#if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == AFTER_TEXT_END
c5aa993b 465#define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_after_text_end (pc, sp, frame_address)
7a292a7a 466#endif
0f71a2f6 467#endif
7a292a7a
SS
468
469extern int pc_in_call_dummy_on_stack PARAMS ((CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address));
0f71a2f6 470#if !GDB_MULTI_ARCH
7a292a7a
SS
471#if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == ON_STACK
472#define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_on_stack (pc, sp, frame_address)
473#endif
0f71a2f6 474#endif
7a292a7a
SS
475
476extern int pc_in_call_dummy_at_entry_point PARAMS ((CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address));
0f71a2f6 477#if !GDB_MULTI_ARCH
7a292a7a
SS
478#if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == AT_ENTRY_POINT
479#define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_at_entry_point (pc, sp, frame_address)
480#endif
0f71a2f6 481#endif
c906108c
SS
482
483/* It's often not enough for our clients to know whether the PC is merely
484 somewhere within the call dummy. They may need to know whether the
485 call dummy has actually completed. (For example, wait_for_inferior
486 wants to know when it should truly stop because the call dummy has
487 completed. If we're single-stepping because of slow watchpoints,
488 then we may find ourselves stopped at the entry of the call dummy,
489 and want to continue stepping until we reach the end.)
490
491 Note that this macro is intended for targets (like HP-UX) which
492 require more than a single breakpoint in their call dummies, and
493 therefore cannot use the CALL_DUMMY_BREAKPOINT_OFFSET mechanism.
494
495 If a target does define CALL_DUMMY_BREAKPOINT_OFFSET, then this
496 default implementation of CALL_DUMMY_HAS_COMPLETED is sufficient.
497 Else, a target may wish to supply an implementation that works in
498 the presense of multiple breakpoints in its call dummy.
c5aa993b 499 */
c906108c
SS
500#if !defined(CALL_DUMMY_HAS_COMPLETED)
501#define CALL_DUMMY_HAS_COMPLETED(pc, sp, frame_address) \
502 PC_IN_CALL_DUMMY((pc), (sp), (frame_address))
503#endif
504
505/* If STARTUP_WITH_SHELL is set, GDB's "run"
506 will attempts to start up the debugee under a shell.
507 This is in order for argument-expansion to occur. E.g.,
508 (gdb) run *
509 The "*" gets expanded by the shell into a list of files.
510 While this is a nice feature, it turns out to interact badly
511 with some of the catch-fork/catch-exec features we have added.
512 In particular, if the shell does any fork/exec's before
513 the exec of the target program, that can confuse GDB.
514 To disable this feature, set STARTUP_WITH_SHELL to 0.
515 To enable this feature, set STARTUP_WITH_SHELL to 1.
516 The catch-exec traps expected during start-up will
517 be 1 if target is not started up with a shell, 2 if it is.
518 - RT
519 If you disable this, you need to decrement
520 START_INFERIOR_TRAPS_EXPECTED in tm.h. */
521#define STARTUP_WITH_SHELL 1
522#if !defined(START_INFERIOR_TRAPS_EXPECTED)
523#define START_INFERIOR_TRAPS_EXPECTED 2
524#endif
525#endif /* !defined (INFERIOR_H) */
This page took 0.100832 seconds and 4 git commands to generate.