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