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