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