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.
5 This file is part of GDB.
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.
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.
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. */
22 #if !defined (INFERIOR_H)
26 #include "breakpoint.h"
28 /* For enum target_signal. */
31 /* Structure in which to save the status of the inferior. Create/Save
32 through "save_inferior_status", restore through
33 "restore_inferior_status".
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
39 struct inferior_status;
41 extern struct inferior_status *save_inferior_status (int);
43 extern void restore_inferior_status (struct inferior_status *);
45 extern struct cleanup *make_cleanup_restore_inferior_status (struct inferior_status *);
47 extern void discard_inferior_status (struct inferior_status *);
49 extern void write_inferior_status_register (struct inferior_status
50 *inf_status, int regno,
53 /* This macro gives the number of registers actually in use by the
54 inferior. This may be less than the total number of registers,
55 perhaps depending on the actual CPU in use or program being run.
56 FIXME: This could be replaced by the new MULTI_ARCH capability. */
59 #define ARCH_NUM_REGS NUM_REGS
62 /* This function is called when the value of a pseudo-register needs
63 to be updated. Typically it will be defined on a per-architecture
64 basis. FIXME: move into gdbarch.[ch]. */
65 #ifndef ARCH_FETCH_PSEUDO_REGISTERS
66 #define ARCH_FETCH_PSEUDO_REGISTERS(REGNUM) /* no-op */
69 /* This function is called when the value of a pseudo-register needs
70 to be set or stored. Typically it will be defined on a per-architecture
71 basis. FIXME: move into gdbarch.[ch]. */
72 #ifndef ARCH_STORE_PSEUDO_REGISTERS
73 #define ARCH_STORE_PSEUDO_REGISTERS(REGNUM) /* no-op */
76 extern void set_sigint_trap (void);
78 extern void clear_sigint_trap (void);
80 extern void set_sigio_trap (void);
82 extern void clear_sigio_trap (void);
84 /* File name for default use for standard in/out in the inferior. */
86 extern char *inferior_io_terminal;
88 /* Pid of our debugged inferior, or 0 if no inferior now. */
90 extern int inferior_pid;
92 /* Is the inferior running right now, as a result of a 'run&',
93 'continue&' etc command? This is used in asycn gdb to determine
94 whether a command that the user enters while the target is running
96 extern int target_executing;
98 /* Are we simulating synchronous execution? This is used in async gdb
99 to implement the 'run', 'continue' etc commands, which will not
100 redisplay the prompt until the execution is actually over. */
101 extern int sync_execution;
103 /* This is only valid when inferior_pid is non-zero.
105 If this is 0, then exec events should be noticed and responded to
106 by the debugger (i.e., be reported to the user).
108 If this is > 0, then that many subsequent exec events should be
109 ignored (i.e., not be reported to the user).
111 extern int inferior_ignoring_startup_exec_events;
113 /* This is only valid when inferior_ignoring_startup_exec_events is
116 Some targets (stupidly) report more than one exec event per actual
117 call to an event() system call. If only the last such exec event
118 need actually be noticed and responded to by the debugger (i.e.,
119 be reported to the user), then this is the number of "leading"
120 exec events which should be ignored.
122 extern int inferior_ignoring_leading_exec_events;
124 /* Inferior environment. */
126 extern struct environ *inferior_environ;
128 /* Character array containing an image of the inferior programs'
131 extern char *registers;
133 /* Character array containing the current state of each register
134 (unavailable<0, valid=0, invalid>0). */
136 extern signed char *register_valid;
138 extern void clear_proceed_status (void);
140 extern void proceed (CORE_ADDR, enum target_signal, int);
142 extern void kill_inferior (void);
144 extern void generic_mourn_inferior (void);
146 extern void terminal_ours (void);
148 extern int run_stack_dummy (CORE_ADDR, char *);
150 extern CORE_ADDR read_pc (void);
152 extern CORE_ADDR read_pc_pid (int);
154 extern CORE_ADDR generic_target_read_pc (int);
156 extern void write_pc (CORE_ADDR);
158 extern void write_pc_pid (CORE_ADDR, int);
160 extern void generic_target_write_pc (CORE_ADDR, int);
162 extern CORE_ADDR read_sp (void);
164 extern CORE_ADDR generic_target_read_sp (void);
166 extern void write_sp (CORE_ADDR);
168 extern void generic_target_write_sp (CORE_ADDR);
170 extern CORE_ADDR read_fp (void);
172 extern CORE_ADDR generic_target_read_fp (void);
174 extern void write_fp (CORE_ADDR);
176 extern void generic_target_write_fp (CORE_ADDR);
178 extern CORE_ADDR unsigned_pointer_to_address (struct type *type, void *buf);
180 extern void unsigned_address_to_pointer (struct type *type, void *buf,
182 extern CORE_ADDR signed_pointer_to_address (struct type *type, void *buf);
183 extern void address_to_signed_pointer (struct type *type, void *buf,
186 extern void wait_for_inferior (void);
188 extern void fetch_inferior_event (void *);
190 extern void init_wait_for_inferior (void);
192 extern void close_exec_file (void);
194 extern void reopen_exec_file (void);
196 /* The `resume' routine should only be called in special circumstances.
197 Normally, use `proceed', which handles a lot of bookkeeping. */
199 extern void resume (int, enum target_signal);
201 /* From misc files */
203 extern void store_inferior_registers (int);
205 extern void fetch_inferior_registers (int);
207 extern void solib_create_inferior_hook (void);
209 extern void child_terminal_info (char *, int);
211 extern void term_info (char *, int);
213 extern void terminal_ours_for_output (void);
215 extern void terminal_inferior (void);
217 extern void terminal_init_inferior (void);
219 extern void terminal_init_inferior_with_pgrp (int pgrp);
221 /* From infptrace.c or infttrace.c */
223 extern int attach (int);
225 #if !defined(REQUIRE_ATTACH)
226 #define REQUIRE_ATTACH attach
229 #if !defined(REQUIRE_DETACH)
230 #define REQUIRE_DETACH(pid,siggnal) detach (siggnal)
233 extern void detach (int);
235 /* PTRACE method of waiting for inferior process. */
236 int ptrace_wait (int, int *);
238 extern void child_resume (int, int, enum target_signal);
240 #ifndef PTRACE_ARG3_TYPE
241 #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
244 extern int call_ptrace (int, int, PTRACE_ARG3_TYPE, int);
246 extern void pre_fork_inferior (void);
250 extern int proc_iterate_over_mappings (int (*)(int, CORE_ADDR));
252 extern int procfs_first_available (void);
254 /* From fork-child.c */
256 extern void fork_inferior (char *, char *, char **,
258 void (*)(int), void (*)(void), char *);
261 extern void clone_and_follow_inferior (int, int *);
263 extern void startup_inferior (int);
267 extern void new_tty_prefork (char *);
269 extern int gdb_has_a_terminal (void);
273 extern void start_remote (void);
275 extern void normal_stop (void);
277 extern int signal_stop_state (int);
279 extern int signal_print_state (int);
281 extern int signal_pass_state (int);
283 extern int signal_stop_update (int, int);
285 extern int signal_print_update (int, int);
287 extern int signal_pass_update (int, int);
291 extern void tty_command (char *, int);
293 extern void attach_command (char *, int);
295 /* Last signal that the inferior received (why it stopped). */
297 extern enum target_signal stop_signal;
299 /* Address at which inferior stopped. */
301 extern CORE_ADDR stop_pc;
303 /* Chain containing status of breakpoint(s) that we have stopped at. */
305 extern bpstat stop_bpstat;
307 /* Flag indicating that a command has proceeded the inferior past the
308 current breakpoint. */
310 extern int breakpoint_proceeded;
312 /* Nonzero if stopped due to a step command. */
314 extern int stop_step;
316 /* Nonzero if stopped due to completion of a stack dummy routine. */
318 extern int stop_stack_dummy;
320 /* Nonzero if program stopped due to a random (unexpected) signal in
323 extern int stopped_by_random_signal;
325 /* Range to single step within.
326 If this is nonzero, respond to a single-step signal
327 by continuing to step if the pc is in this range.
329 If step_range_start and step_range_end are both 1, it means to step for
330 a single instruction (FIXME: it might clean up wait_for_inferior in a
331 minor way if this were changed to the address of the instruction and
332 that address plus one. But maybe not.). */
334 extern CORE_ADDR step_range_start; /* Inclusive */
335 extern CORE_ADDR step_range_end; /* Exclusive */
337 /* Stack frame address as of when stepping command was issued.
338 This is how we know when we step into a subroutine call,
339 and how to set the frame for the breakpoint used to step out. */
341 extern CORE_ADDR step_frame_address;
343 /* Our notion of the current stack pointer. */
345 extern CORE_ADDR step_sp;
347 /* 1 means step over all subroutine calls.
348 -1 means step over calls to undebuggable functions. */
350 extern int step_over_calls;
352 /* If stepping, nonzero means step count is > 1
353 so don't print frame next time inferior stops
354 if it stops due to stepping. */
356 extern int step_multi;
358 /* Nonzero means expecting a trap and caller will handle it themselves.
359 It is used after attach, due to attaching to a process;
360 when running in the shell before the child program has been exec'd;
361 and when running some kinds of remote stuff (FIXME?). */
363 extern int stop_soon_quietly;
365 /* Nonzero if proceed is being used for a "finish" command or a similar
366 situation when stop_registers should be saved. */
368 extern int proceed_to_finish;
370 /* Save register contents here when about to pop a stack dummy frame,
371 if-and-only-if proceed_to_finish is set.
372 Thus this contains the return value from the called function (assuming
373 values are returned in a register). */
375 extern char *stop_registers;
377 /* Nonzero if the child process in inferior_pid was attached rather
380 extern int attach_flag;
382 /* Sigtramp is a routine that the kernel calls (which then calls the
383 signal handler). On most machines it is a library routine that
384 is linked into the executable.
386 This macro, given a program counter value and the name of the
387 function in which that PC resides (which can be null if the
388 name is not known), returns nonzero if the PC and name show
389 that we are in sigtramp.
391 On most machines just see if the name is sigtramp (and if we have
392 no name, assume we are not in sigtramp). */
393 #if !defined (IN_SIGTRAMP)
394 #if defined (SIGTRAMP_START)
395 #define IN_SIGTRAMP(pc, name) \
396 ((pc) >= SIGTRAMP_START(pc) \
397 && (pc) < SIGTRAMP_END(pc) \
400 #define IN_SIGTRAMP(pc, name) \
401 (name && STREQ ("_sigtramp", name))
405 /* Possible values for CALL_DUMMY_LOCATION. */
407 #define BEFORE_TEXT_END 2
408 #define AFTER_TEXT_END 3
409 #define AT_ENTRY_POINT 4
411 #if !defined (USE_GENERIC_DUMMY_FRAMES)
412 #define USE_GENERIC_DUMMY_FRAMES 0
415 #if !defined (CALL_DUMMY_LOCATION)
416 #define CALL_DUMMY_LOCATION ON_STACK
417 #endif /* No CALL_DUMMY_LOCATION. */
419 #if !defined (CALL_DUMMY_ADDRESS)
420 #define CALL_DUMMY_ADDRESS() (internal_error ("CALL_DUMMY_ADDRESS"), 0)
422 #if !defined (CALL_DUMMY_START_OFFSET)
423 #define CALL_DUMMY_START_OFFSET (internal_error ("CALL_DUMMY_START_OFFSET"), 0)
425 #if !defined (CALL_DUMMY_BREAKPOINT_OFFSET)
426 #define CALL_DUMMY_BREAKPOINT_OFFSET_P (0)
427 #define CALL_DUMMY_BREAKPOINT_OFFSET (internal_error ("CALL_DUMMY_BREAKPOINT_OFFSET"), 0)
429 #if !defined CALL_DUMMY_BREAKPOINT_OFFSET_P
430 #define CALL_DUMMY_BREAKPOINT_OFFSET_P (1)
432 #if !defined (CALL_DUMMY_LENGTH)
433 #define CALL_DUMMY_LENGTH (internal_error ("CALL_DUMMY_LENGTH"), 0)
436 #if defined (CALL_DUMMY_STACK_ADJUST)
437 #if !defined (CALL_DUMMY_STACK_ADJUST_P)
438 #define CALL_DUMMY_STACK_ADJUST_P (1)
441 #if !defined (CALL_DUMMY_STACK_ADJUST)
442 #define CALL_DUMMY_STACK_ADJUST (internal_error ("CALL_DUMMY_STACK_ADJUST"), 0)
444 #if !defined (CALL_DUMMY_STACK_ADJUST_P)
445 #define CALL_DUMMY_STACK_ADJUST_P (0)
448 /* FIXME: cagney/2000-04-17: gdbarch should manage this. The default
449 shouldn't be necessary. */
451 #if !defined (CALL_DUMMY_P)
452 #if defined (CALL_DUMMY)
453 #define CALL_DUMMY_P 1
455 #define CALL_DUMMY_P 0
459 #if !defined PUSH_DUMMY_FRAME
460 #define PUSH_DUMMY_FRAME (internal_error ("PUSH_DUMMY_FRAME"), 0)
463 #if !defined FIX_CALL_DUMMY
464 #define FIX_CALL_DUMMY(a1,a2,a3,a4,a5,a6,a7) (internal_error ("FIX_CALL_DUMMY"), 0)
467 #if !defined STORE_STRUCT_RETURN
468 #define STORE_STRUCT_RETURN(a1,a2) (internal_error ("STORE_STRUCT_RETURN"), 0)
472 /* Are we in a call dummy? */
474 extern int pc_in_call_dummy_before_text_end (CORE_ADDR pc, CORE_ADDR sp,
475 CORE_ADDR frame_address);
477 #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == BEFORE_TEXT_END
478 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_before_text_end (pc, sp, frame_address)
479 #endif /* Before text_end. */
482 extern int pc_in_call_dummy_after_text_end (CORE_ADDR pc, CORE_ADDR sp,
483 CORE_ADDR frame_address);
485 #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == AFTER_TEXT_END
486 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_after_text_end (pc, sp, frame_address)
490 extern int pc_in_call_dummy_on_stack (CORE_ADDR pc, CORE_ADDR sp,
491 CORE_ADDR frame_address);
493 #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == ON_STACK
494 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_on_stack (pc, sp, frame_address)
498 extern int pc_in_call_dummy_at_entry_point (CORE_ADDR pc, CORE_ADDR sp,
499 CORE_ADDR frame_address);
501 #if !defined (PC_IN_CALL_DUMMY) && CALL_DUMMY_LOCATION == AT_ENTRY_POINT
502 #define PC_IN_CALL_DUMMY(pc, sp, frame_address) pc_in_call_dummy_at_entry_point (pc, sp, frame_address)
506 /* It's often not enough for our clients to know whether the PC is merely
507 somewhere within the call dummy. They may need to know whether the
508 call dummy has actually completed. (For example, wait_for_inferior
509 wants to know when it should truly stop because the call dummy has
510 completed. If we're single-stepping because of slow watchpoints,
511 then we may find ourselves stopped at the entry of the call dummy,
512 and want to continue stepping until we reach the end.)
514 Note that this macro is intended for targets (like HP-UX) which
515 require more than a single breakpoint in their call dummies, and
516 therefore cannot use the CALL_DUMMY_BREAKPOINT_OFFSET mechanism.
518 If a target does define CALL_DUMMY_BREAKPOINT_OFFSET, then this
519 default implementation of CALL_DUMMY_HAS_COMPLETED is sufficient.
520 Else, a target may wish to supply an implementation that works in
521 the presense of multiple breakpoints in its call dummy.
523 #if !defined(CALL_DUMMY_HAS_COMPLETED)
524 #define CALL_DUMMY_HAS_COMPLETED(pc, sp, frame_address) \
525 PC_IN_CALL_DUMMY((pc), (sp), (frame_address))
528 /* If STARTUP_WITH_SHELL is set, GDB's "run"
529 will attempts to start up the debugee under a shell.
530 This is in order for argument-expansion to occur. E.g.,
532 The "*" gets expanded by the shell into a list of files.
533 While this is a nice feature, it turns out to interact badly
534 with some of the catch-fork/catch-exec features we have added.
535 In particular, if the shell does any fork/exec's before
536 the exec of the target program, that can confuse GDB.
537 To disable this feature, set STARTUP_WITH_SHELL to 0.
538 To enable this feature, set STARTUP_WITH_SHELL to 1.
539 The catch-exec traps expected during start-up will
540 be 1 if target is not started up with a shell, 2 if it is.
542 If you disable this, you need to decrement
543 START_INFERIOR_TRAPS_EXPECTED in tm.h. */
544 #define STARTUP_WITH_SHELL 1
545 #if !defined(START_INFERIOR_TRAPS_EXPECTED)
546 #define START_INFERIOR_TRAPS_EXPECTED 2
548 #endif /* !defined (INFERIOR_H) */