xref: /dflybsd-src/contrib/gdb-7/gdb/inferior.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* Variables that describe the inferior process running under GDB:
25796c8dcSSimon Schubert    Where it is, why it stopped, and how to step it.
35796c8dcSSimon Schubert 
4*ef5ccd6cSJohn Marino    Copyright (C) 1986-2013 Free Software Foundation, Inc.
55796c8dcSSimon Schubert 
65796c8dcSSimon Schubert    This file is part of GDB.
75796c8dcSSimon Schubert 
85796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
95796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
105796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
115796c8dcSSimon Schubert    (at your option) any later version.
125796c8dcSSimon Schubert 
135796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
145796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
155796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
165796c8dcSSimon Schubert    GNU General Public License for more details.
175796c8dcSSimon Schubert 
185796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
195796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
205796c8dcSSimon Schubert 
215796c8dcSSimon Schubert #if !defined (INFERIOR_H)
225796c8dcSSimon Schubert #define INFERIOR_H 1
235796c8dcSSimon Schubert 
245796c8dcSSimon Schubert struct target_waitstatus;
255796c8dcSSimon Schubert struct frame_info;
265796c8dcSSimon Schubert struct ui_file;
275796c8dcSSimon Schubert struct type;
285796c8dcSSimon Schubert struct gdbarch;
295796c8dcSSimon Schubert struct regcache;
305796c8dcSSimon Schubert struct ui_out;
315796c8dcSSimon Schubert struct terminal_info;
32*ef5ccd6cSJohn Marino struct target_desc_info;
335796c8dcSSimon Schubert 
34a45ae5f8SJohn Marino #include "ptid.h"
35a45ae5f8SJohn Marino 
365796c8dcSSimon Schubert /* For bpstat.  */
375796c8dcSSimon Schubert #include "breakpoint.h"
385796c8dcSSimon Schubert 
39*ef5ccd6cSJohn Marino /* For enum gdb_signal.  */
405796c8dcSSimon Schubert #include "target.h"
415796c8dcSSimon Schubert 
425796c8dcSSimon Schubert /* For struct frame_id.  */
435796c8dcSSimon Schubert #include "frame.h"
445796c8dcSSimon Schubert 
45cf7f2e2dSJohn Marino #include "progspace.h"
46*ef5ccd6cSJohn Marino #include "registry.h"
47cf7f2e2dSJohn Marino 
48c50c785cSJohn Marino struct infcall_suspend_state;
49c50c785cSJohn Marino struct infcall_control_state;
505796c8dcSSimon Schubert 
51c50c785cSJohn Marino extern struct infcall_suspend_state *save_infcall_suspend_state (void);
52c50c785cSJohn Marino extern struct infcall_control_state *save_infcall_control_state (void);
535796c8dcSSimon Schubert 
54c50c785cSJohn Marino extern void restore_infcall_suspend_state (struct infcall_suspend_state *);
55c50c785cSJohn Marino extern void restore_infcall_control_state (struct infcall_control_state *);
565796c8dcSSimon Schubert 
57c50c785cSJohn Marino extern struct cleanup *make_cleanup_restore_infcall_suspend_state
58c50c785cSJohn Marino 					    (struct infcall_suspend_state *);
59c50c785cSJohn Marino extern struct cleanup *make_cleanup_restore_infcall_control_state
60c50c785cSJohn Marino 					    (struct infcall_control_state *);
615796c8dcSSimon Schubert 
62c50c785cSJohn Marino extern void discard_infcall_suspend_state (struct infcall_suspend_state *);
63c50c785cSJohn Marino extern void discard_infcall_control_state (struct infcall_control_state *);
645796c8dcSSimon Schubert 
65c50c785cSJohn Marino extern struct regcache *
66c50c785cSJohn Marino   get_infcall_suspend_state_regcache (struct infcall_suspend_state *);
675796c8dcSSimon Schubert 
68cf7f2e2dSJohn Marino /* Returns true if PTID matches filter FILTER.  FILTER can be the wild
69cf7f2e2dSJohn Marino    card MINUS_ONE_PTID (all ptid match it); can be a ptid representing
70cf7f2e2dSJohn Marino    a process (ptid_is_pid returns true), in which case, all lwps and
71cf7f2e2dSJohn Marino    threads of that given process match, lwps and threads of other
72cf7f2e2dSJohn Marino    processes do not; or, it can represent a specific thread, in which
73cf7f2e2dSJohn Marino    case, only that thread will match true.  PTID must represent a
74cf7f2e2dSJohn Marino    specific LWP or THREAD, it can never be a wild card.  */
75cf7f2e2dSJohn Marino 
76cf7f2e2dSJohn Marino extern int ptid_match (ptid_t ptid, ptid_t filter);
77cf7f2e2dSJohn Marino 
785796c8dcSSimon Schubert /* Save value of inferior_ptid so that it may be restored by
795796c8dcSSimon Schubert    a later call to do_cleanups().  Returns the struct cleanup
805796c8dcSSimon Schubert    pointer needed for later doing the cleanup.  */
815796c8dcSSimon Schubert extern struct cleanup * save_inferior_ptid (void);
825796c8dcSSimon Schubert 
835796c8dcSSimon Schubert extern void set_sigint_trap (void);
845796c8dcSSimon Schubert 
855796c8dcSSimon Schubert extern void clear_sigint_trap (void);
865796c8dcSSimon Schubert 
875796c8dcSSimon Schubert /* Set/get file name for default use for standard in/out in the inferior.  */
885796c8dcSSimon Schubert 
895796c8dcSSimon Schubert extern void set_inferior_io_terminal (const char *terminal_name);
905796c8dcSSimon Schubert extern const char *get_inferior_io_terminal (void);
915796c8dcSSimon Schubert 
925796c8dcSSimon Schubert /* Collected pid, tid, etc. of the debugged inferior.  When there's
935796c8dcSSimon Schubert    no inferior, PIDGET (inferior_ptid) will be 0.  */
945796c8dcSSimon Schubert 
955796c8dcSSimon Schubert extern ptid_t inferior_ptid;
965796c8dcSSimon Schubert 
975796c8dcSSimon Schubert /* Are we simulating synchronous execution? This is used in async gdb
985796c8dcSSimon Schubert    to implement the 'run', 'continue' etc commands, which will not
995796c8dcSSimon Schubert    redisplay the prompt until the execution is actually over.  */
1005796c8dcSSimon Schubert extern int sync_execution;
1015796c8dcSSimon Schubert 
1025796c8dcSSimon Schubert /* Inferior environment.  */
1035796c8dcSSimon Schubert 
1045796c8dcSSimon Schubert extern void clear_proceed_status (void);
1055796c8dcSSimon Schubert 
106*ef5ccd6cSJohn Marino extern void proceed (CORE_ADDR, enum gdb_signal, int);
1075796c8dcSSimon Schubert 
1085796c8dcSSimon Schubert extern int sched_multi;
1095796c8dcSSimon Schubert 
1105796c8dcSSimon Schubert /* When set, stop the 'step' command if we enter a function which has
1115796c8dcSSimon Schubert    no line number information.  The normal behavior is that we step
1125796c8dcSSimon Schubert    over such function.  */
1135796c8dcSSimon Schubert extern int step_stop_if_no_debug;
1145796c8dcSSimon Schubert 
1155796c8dcSSimon Schubert /* If set, the inferior should be controlled in non-stop mode.  In
1165796c8dcSSimon Schubert    this mode, each thread is controlled independently.  Execution
117c50c785cSJohn Marino    commands apply only to the selected thread by default, and stop
1185796c8dcSSimon Schubert    events stop only the thread that had the event -- the other threads
1195796c8dcSSimon Schubert    are kept running freely.  */
1205796c8dcSSimon Schubert extern int non_stop;
1215796c8dcSSimon Schubert 
122cf7f2e2dSJohn Marino /* If set (default), when following a fork, GDB will detach from one
123cf7f2e2dSJohn Marino    the fork branches, child or parent.  Exactly which branch is
124cf7f2e2dSJohn Marino    detached depends on 'set follow-fork-mode' setting.  */
125cf7f2e2dSJohn Marino extern int detach_fork;
126cf7f2e2dSJohn Marino 
127a45ae5f8SJohn Marino /* When set (default), the target should attempt to disable the operating
128a45ae5f8SJohn Marino    system's address space randomization feature when starting an inferior.  */
129a45ae5f8SJohn Marino extern int disable_randomization;
130a45ae5f8SJohn Marino 
1315796c8dcSSimon Schubert extern void generic_mourn_inferior (void);
1325796c8dcSSimon Schubert 
1335796c8dcSSimon Schubert extern void terminal_save_ours (void);
1345796c8dcSSimon Schubert 
1355796c8dcSSimon Schubert extern void terminal_ours (void);
1365796c8dcSSimon Schubert 
1375796c8dcSSimon Schubert extern CORE_ADDR unsigned_pointer_to_address (struct gdbarch *gdbarch,
1385796c8dcSSimon Schubert 					      struct type *type,
1395796c8dcSSimon Schubert 					      const gdb_byte *buf);
1405796c8dcSSimon Schubert extern void unsigned_address_to_pointer (struct gdbarch *gdbarch,
1415796c8dcSSimon Schubert 					 struct type *type, gdb_byte *buf,
1425796c8dcSSimon Schubert 					 CORE_ADDR addr);
1435796c8dcSSimon Schubert extern CORE_ADDR signed_pointer_to_address (struct gdbarch *gdbarch,
1445796c8dcSSimon Schubert 					    struct type *type,
1455796c8dcSSimon Schubert 					    const gdb_byte *buf);
1465796c8dcSSimon Schubert extern void address_to_signed_pointer (struct gdbarch *gdbarch,
1475796c8dcSSimon Schubert 				       struct type *type, gdb_byte *buf,
1485796c8dcSSimon Schubert 				       CORE_ADDR addr);
1495796c8dcSSimon Schubert 
150a45ae5f8SJohn Marino extern void wait_for_inferior (void);
1515796c8dcSSimon Schubert 
152cf7f2e2dSJohn Marino extern void prepare_for_detach (void);
153cf7f2e2dSJohn Marino 
1545796c8dcSSimon Schubert extern void fetch_inferior_event (void *);
1555796c8dcSSimon Schubert 
1565796c8dcSSimon Schubert extern void init_wait_for_inferior (void);
1575796c8dcSSimon Schubert 
1585796c8dcSSimon Schubert extern void reopen_exec_file (void);
1595796c8dcSSimon Schubert 
1605796c8dcSSimon Schubert /* The `resume' routine should only be called in special circumstances.
1615796c8dcSSimon Schubert    Normally, use `proceed', which handles a lot of bookkeeping.  */
1625796c8dcSSimon Schubert 
163*ef5ccd6cSJohn Marino extern void resume (int, enum gdb_signal);
1645796c8dcSSimon Schubert 
165a45ae5f8SJohn Marino extern ptid_t user_visible_resume_ptid (int step);
166a45ae5f8SJohn Marino 
167a45ae5f8SJohn Marino extern void insert_step_resume_breakpoint_at_sal (struct gdbarch *,
168a45ae5f8SJohn Marino 						  struct symtab_and_line ,
169a45ae5f8SJohn Marino 						  struct frame_id);
170a45ae5f8SJohn Marino 
1715796c8dcSSimon Schubert /* From misc files */
1725796c8dcSSimon Schubert 
1735796c8dcSSimon Schubert extern void default_print_registers_info (struct gdbarch *gdbarch,
1745796c8dcSSimon Schubert 					  struct ui_file *file,
1755796c8dcSSimon Schubert 					  struct frame_info *frame,
1765796c8dcSSimon Schubert 					  int regnum, int all);
1775796c8dcSSimon Schubert 
1785796c8dcSSimon Schubert extern void child_terminal_info (char *, int);
1795796c8dcSSimon Schubert 
1805796c8dcSSimon Schubert extern void term_info (char *, int);
1815796c8dcSSimon Schubert 
1825796c8dcSSimon Schubert extern void terminal_ours_for_output (void);
1835796c8dcSSimon Schubert 
1845796c8dcSSimon Schubert extern void terminal_inferior (void);
1855796c8dcSSimon Schubert 
1865796c8dcSSimon Schubert extern void terminal_init_inferior (void);
1875796c8dcSSimon Schubert 
1885796c8dcSSimon Schubert extern void terminal_init_inferior_with_pgrp (int pgrp);
1895796c8dcSSimon Schubert 
1905796c8dcSSimon Schubert /* From fork-child.c */
1915796c8dcSSimon Schubert 
1925796c8dcSSimon Schubert extern int fork_inferior (char *, char *, char **,
1935796c8dcSSimon Schubert 			  void (*)(void),
194a45ae5f8SJohn Marino 			  void (*)(int), void (*)(void), char *,
195a45ae5f8SJohn Marino                           void (*)(const char *,
196a45ae5f8SJohn Marino                                    char * const *, char * const *));
1975796c8dcSSimon Schubert 
1985796c8dcSSimon Schubert 
1995796c8dcSSimon Schubert extern void startup_inferior (int);
2005796c8dcSSimon Schubert 
2015796c8dcSSimon Schubert extern char *construct_inferior_arguments (int, char **);
2025796c8dcSSimon Schubert 
2035796c8dcSSimon Schubert /* From infrun.c */
2045796c8dcSSimon Schubert 
205*ef5ccd6cSJohn Marino extern unsigned int debug_infrun;
206cf7f2e2dSJohn Marino 
207cf7f2e2dSJohn Marino extern int stop_on_solib_events;
208cf7f2e2dSJohn Marino 
2095796c8dcSSimon Schubert extern void start_remote (int from_tty);
2105796c8dcSSimon Schubert 
2115796c8dcSSimon Schubert extern void normal_stop (void);
2125796c8dcSSimon Schubert 
2135796c8dcSSimon Schubert extern int signal_stop_state (int);
2145796c8dcSSimon Schubert 
2155796c8dcSSimon Schubert extern int signal_print_state (int);
2165796c8dcSSimon Schubert 
2175796c8dcSSimon Schubert extern int signal_pass_state (int);
2185796c8dcSSimon Schubert 
2195796c8dcSSimon Schubert extern int signal_stop_update (int, int);
2205796c8dcSSimon Schubert 
2215796c8dcSSimon Schubert extern int signal_print_update (int, int);
2225796c8dcSSimon Schubert 
2235796c8dcSSimon Schubert extern int signal_pass_update (int, int);
2245796c8dcSSimon Schubert 
2255796c8dcSSimon Schubert extern void get_last_target_status(ptid_t *ptid,
2265796c8dcSSimon Schubert                                    struct target_waitstatus *status);
2275796c8dcSSimon Schubert 
2285796c8dcSSimon Schubert extern void follow_inferior_reset_breakpoints (void);
2295796c8dcSSimon Schubert 
2305796c8dcSSimon Schubert void set_step_info (struct frame_info *frame, struct symtab_and_line sal);
2315796c8dcSSimon Schubert 
2325796c8dcSSimon Schubert /* From infcmd.c */
2335796c8dcSSimon Schubert 
2345796c8dcSSimon Schubert extern void post_create_inferior (struct target_ops *, int);
2355796c8dcSSimon Schubert 
2365796c8dcSSimon Schubert extern void attach_command (char *, int);
2375796c8dcSSimon Schubert 
2385796c8dcSSimon Schubert extern char *get_inferior_args (void);
2395796c8dcSSimon Schubert 
240cf7f2e2dSJohn Marino extern void set_inferior_args (char *);
2415796c8dcSSimon Schubert 
2425796c8dcSSimon Schubert extern void set_inferior_args_vector (int, char **);
2435796c8dcSSimon Schubert 
2445796c8dcSSimon Schubert extern void registers_info (char *, int);
2455796c8dcSSimon Schubert 
2465796c8dcSSimon Schubert extern void continue_1 (int all_threads);
2475796c8dcSSimon Schubert 
2485796c8dcSSimon Schubert extern void interrupt_target_1 (int all_threads);
2495796c8dcSSimon Schubert 
250c50c785cSJohn Marino extern void delete_longjmp_breakpoint_cleanup (void *arg);
251c50c785cSJohn Marino 
2525796c8dcSSimon Schubert extern void detach_command (char *, int);
2535796c8dcSSimon Schubert 
2545796c8dcSSimon Schubert extern void notice_new_inferior (ptid_t, int, int);
2555796c8dcSSimon Schubert 
256*ef5ccd6cSJohn Marino extern struct value *get_return_value (struct value *function,
257a45ae5f8SJohn Marino                                        struct type *value_type);
258a45ae5f8SJohn Marino 
2595796c8dcSSimon Schubert /* Address at which inferior stopped.  */
2605796c8dcSSimon Schubert 
2615796c8dcSSimon Schubert extern CORE_ADDR stop_pc;
2625796c8dcSSimon Schubert 
2635796c8dcSSimon Schubert /* Nonzero if stopped due to completion of a stack dummy routine.  */
2645796c8dcSSimon Schubert 
265cf7f2e2dSJohn Marino extern enum stop_stack_kind stop_stack_dummy;
2665796c8dcSSimon Schubert 
2675796c8dcSSimon Schubert /* Nonzero if program stopped due to a random (unexpected) signal in
2685796c8dcSSimon Schubert    inferior process.  */
2695796c8dcSSimon Schubert 
2705796c8dcSSimon Schubert extern int stopped_by_random_signal;
2715796c8dcSSimon Schubert 
2725796c8dcSSimon Schubert /* STEP_OVER_ALL means step over all subroutine calls.
2735796c8dcSSimon Schubert    STEP_OVER_UNDEBUGGABLE means step over calls to undebuggable functions.
2745796c8dcSSimon Schubert    STEP_OVER_NONE means don't step over any subroutine calls.  */
2755796c8dcSSimon Schubert 
2765796c8dcSSimon Schubert enum step_over_calls_kind
2775796c8dcSSimon Schubert   {
2785796c8dcSSimon Schubert     STEP_OVER_NONE,
2795796c8dcSSimon Schubert     STEP_OVER_ALL,
2805796c8dcSSimon Schubert     STEP_OVER_UNDEBUGGABLE
2815796c8dcSSimon Schubert   };
2825796c8dcSSimon Schubert 
2835796c8dcSSimon Schubert /* Anything but NO_STOP_QUIETLY means we expect a trap and the caller
2845796c8dcSSimon Schubert    will handle it themselves.  STOP_QUIETLY is used when running in
2855796c8dcSSimon Schubert    the shell before the child program has been exec'd and when running
2865796c8dcSSimon Schubert    through shared library loading.  STOP_QUIETLY_REMOTE is used when
2875796c8dcSSimon Schubert    setting up a remote connection; it is like STOP_QUIETLY_NO_SIGSTOP
2885796c8dcSSimon Schubert    except that there is no need to hide a signal.  */
2895796c8dcSSimon Schubert 
2905796c8dcSSimon Schubert /* It is also used after attach, due to attaching to a process.  This
2915796c8dcSSimon Schubert    is a bit trickier.  When doing an attach, the kernel stops the
2925796c8dcSSimon Schubert    debuggee with a SIGSTOP.  On newer GNU/Linux kernels (>= 2.5.61)
2935796c8dcSSimon Schubert    the handling of SIGSTOP for a ptraced process has changed.  Earlier
2945796c8dcSSimon Schubert    versions of the kernel would ignore these SIGSTOPs, while now
2955796c8dcSSimon Schubert    SIGSTOP is treated like any other signal, i.e. it is not muffled.
2965796c8dcSSimon Schubert 
2975796c8dcSSimon Schubert    If the gdb user does a 'continue' after the 'attach', gdb passes
2985796c8dcSSimon Schubert    the global variable stop_signal (which stores the signal from the
2995796c8dcSSimon Schubert    attach, SIGSTOP) to the ptrace(PTRACE_CONT,...)  call.  This is
3005796c8dcSSimon Schubert    problematic, because the kernel doesn't ignore such SIGSTOP
3015796c8dcSSimon Schubert    now.  I.e. it is reported back to gdb, which in turn presents it
3025796c8dcSSimon Schubert    back to the user.
3035796c8dcSSimon Schubert 
3045796c8dcSSimon Schubert    To avoid the problem, we use STOP_QUIETLY_NO_SIGSTOP, which allows
3055796c8dcSSimon Schubert    gdb to clear the value of stop_signal after the attach, so that it
3065796c8dcSSimon Schubert    is not passed back down to the kernel.  */
3075796c8dcSSimon Schubert 
3085796c8dcSSimon Schubert enum stop_kind
3095796c8dcSSimon Schubert   {
3105796c8dcSSimon Schubert     NO_STOP_QUIETLY = 0,
3115796c8dcSSimon Schubert     STOP_QUIETLY,
3125796c8dcSSimon Schubert     STOP_QUIETLY_REMOTE,
3135796c8dcSSimon Schubert     STOP_QUIETLY_NO_SIGSTOP
3145796c8dcSSimon Schubert   };
3155796c8dcSSimon Schubert 
3165796c8dcSSimon Schubert /* Reverse execution.  */
3175796c8dcSSimon Schubert enum exec_direction_kind
3185796c8dcSSimon Schubert   {
3195796c8dcSSimon Schubert     EXEC_FORWARD,
320a45ae5f8SJohn Marino     EXEC_REVERSE
3215796c8dcSSimon Schubert   };
3225796c8dcSSimon Schubert 
323a45ae5f8SJohn Marino /* The current execution direction.  This should only be set to enum
324a45ae5f8SJohn Marino    exec_direction_kind values.  It is only an int to make it
325a45ae5f8SJohn Marino    compatible with make_cleanup_restore_integer.  */
326a45ae5f8SJohn Marino extern int execution_direction;
3275796c8dcSSimon Schubert 
3285796c8dcSSimon Schubert /* Save register contents here when executing a "finish" command or are
3295796c8dcSSimon Schubert    about to pop a stack dummy frame, if-and-only-if proceed_to_finish is set.
3305796c8dcSSimon Schubert    Thus this contains the return value from the called function (assuming
3315796c8dcSSimon Schubert    values are returned in a register).  */
3325796c8dcSSimon Schubert 
3335796c8dcSSimon Schubert extern struct regcache *stop_registers;
3345796c8dcSSimon Schubert 
3355796c8dcSSimon Schubert /* True if we are debugging displaced stepping.  */
3365796c8dcSSimon Schubert extern int debug_displaced;
3375796c8dcSSimon Schubert 
3385796c8dcSSimon Schubert /* Dump LEN bytes at BUF in hex to FILE, followed by a newline.  */
3395796c8dcSSimon Schubert void displaced_step_dump_bytes (struct ui_file *file,
3405796c8dcSSimon Schubert                                 const gdb_byte *buf, size_t len);
3415796c8dcSSimon Schubert 
342c50c785cSJohn Marino struct displaced_step_closure *get_displaced_step_closure_by_addr (CORE_ADDR addr);
3435796c8dcSSimon Schubert 
3445796c8dcSSimon Schubert /* Possible values for gdbarch_call_dummy_location.  */
3455796c8dcSSimon Schubert #define ON_STACK 1
3465796c8dcSSimon Schubert #define AT_ENTRY_POINT 4
3475796c8dcSSimon Schubert 
3485796c8dcSSimon Schubert /* If STARTUP_WITH_SHELL is set, GDB's "run"
3495796c8dcSSimon Schubert    will attempts to start up the debugee under a shell.
3505796c8dcSSimon Schubert    This is in order for argument-expansion to occur.  E.g.,
3515796c8dcSSimon Schubert    (gdb) run *
3525796c8dcSSimon Schubert    The "*" gets expanded by the shell into a list of files.
3535796c8dcSSimon Schubert    While this is a nice feature, it turns out to interact badly
3545796c8dcSSimon Schubert    with some of the catch-fork/catch-exec features we have added.
3555796c8dcSSimon Schubert    In particular, if the shell does any fork/exec's before
3565796c8dcSSimon Schubert    the exec of the target program, that can confuse GDB.
3575796c8dcSSimon Schubert    To disable this feature, set STARTUP_WITH_SHELL to 0.
3585796c8dcSSimon Schubert    To enable this feature, set STARTUP_WITH_SHELL to 1.
3595796c8dcSSimon Schubert    The catch-exec traps expected during start-up will
3605796c8dcSSimon Schubert    be 1 if target is not started up with a shell, 2 if it is.
3615796c8dcSSimon Schubert    - RT
3625796c8dcSSimon Schubert    If you disable this, you need to decrement
3635796c8dcSSimon Schubert    START_INFERIOR_TRAPS_EXPECTED in tm.h.  */
3645796c8dcSSimon Schubert #define STARTUP_WITH_SHELL 1
3655796c8dcSSimon Schubert #if !defined(START_INFERIOR_TRAPS_EXPECTED)
3665796c8dcSSimon Schubert #define START_INFERIOR_TRAPS_EXPECTED	2
3675796c8dcSSimon Schubert #endif
3685796c8dcSSimon Schubert 
3695796c8dcSSimon Schubert struct private_inferior;
3705796c8dcSSimon Schubert 
371c50c785cSJohn Marino /* Inferior process specific part of `struct infcall_control_state'.
372c50c785cSJohn Marino 
373c50c785cSJohn Marino    Inferior thread counterpart is `struct thread_control_state'.  */
374c50c785cSJohn Marino 
375c50c785cSJohn Marino struct inferior_control_state
376c50c785cSJohn Marino {
377c50c785cSJohn Marino   /* See the definition of stop_kind above.  */
378c50c785cSJohn Marino   enum stop_kind stop_soon;
379c50c785cSJohn Marino };
380c50c785cSJohn Marino 
381c50c785cSJohn Marino /* Inferior process specific part of `struct infcall_suspend_state'.
382c50c785cSJohn Marino 
383c50c785cSJohn Marino    Inferior thread counterpart is `struct thread_suspend_state'.  */
384c50c785cSJohn Marino 
385*ef5ccd6cSJohn Marino #if 0 /* Currently unused and empty structures are not valid C.  */
386c50c785cSJohn Marino struct inferior_suspend_state
387c50c785cSJohn Marino {
388c50c785cSJohn Marino };
389*ef5ccd6cSJohn Marino #endif
390c50c785cSJohn Marino 
3915796c8dcSSimon Schubert /* GDB represents the state of each program execution with an object
3925796c8dcSSimon Schubert    called an inferior.  An inferior typically corresponds to a process
3935796c8dcSSimon Schubert    but is more general and applies also to targets that do not have a
3945796c8dcSSimon Schubert    notion of processes.  Each run of an executable creates a new
3955796c8dcSSimon Schubert    inferior, as does each attachment to an existing process.
3965796c8dcSSimon Schubert    Inferiors have unique internal identifiers that are different from
3975796c8dcSSimon Schubert    target process ids.  Each inferior may in turn have multiple
3985796c8dcSSimon Schubert    threads running in it.  */
3995796c8dcSSimon Schubert 
4005796c8dcSSimon Schubert struct inferior
4015796c8dcSSimon Schubert {
4025796c8dcSSimon Schubert   /* Pointer to next inferior in singly-linked list of inferiors.  */
4035796c8dcSSimon Schubert   struct inferior *next;
4045796c8dcSSimon Schubert 
4055796c8dcSSimon Schubert   /* Convenient handle (GDB inferior id).  Unique across all
4065796c8dcSSimon Schubert      inferiors.  */
4075796c8dcSSimon Schubert   int num;
4085796c8dcSSimon Schubert 
4095796c8dcSSimon Schubert   /* Actual target inferior id, usually, a process id.  This matches
4105796c8dcSSimon Schubert      the ptid_t.pid member of threads of this inferior.  */
4115796c8dcSSimon Schubert   int pid;
412*ef5ccd6cSJohn Marino   /* True if the PID was actually faked by GDB.  */
413*ef5ccd6cSJohn Marino   int fake_pid_p;
4145796c8dcSSimon Schubert 
415c50c785cSJohn Marino   /* State of GDB control of inferior process execution.
416c50c785cSJohn Marino      See `struct inferior_control_state'.  */
417c50c785cSJohn Marino   struct inferior_control_state control;
418c50c785cSJohn Marino 
419c50c785cSJohn Marino   /* State of inferior process to restore after GDB is done with an inferior
420c50c785cSJohn Marino      call.  See `struct inferior_suspend_state'.  */
421*ef5ccd6cSJohn Marino #if 0 /* Currently unused and empty structures are not valid C.  */
422c50c785cSJohn Marino   struct inferior_suspend_state suspend;
423*ef5ccd6cSJohn Marino #endif
424c50c785cSJohn Marino 
425cf7f2e2dSJohn Marino   /* True if this was an auto-created inferior, e.g. created from
426cf7f2e2dSJohn Marino      following a fork; false, if this inferior was manually added by
427cf7f2e2dSJohn Marino      the user, and we should not attempt to prune it
428cf7f2e2dSJohn Marino      automatically.  */
429cf7f2e2dSJohn Marino   int removable;
430cf7f2e2dSJohn Marino 
431cf7f2e2dSJohn Marino   /* The address space bound to this inferior.  */
432cf7f2e2dSJohn Marino   struct address_space *aspace;
433cf7f2e2dSJohn Marino 
434cf7f2e2dSJohn Marino   /* The program space bound to this inferior.  */
435cf7f2e2dSJohn Marino   struct program_space *pspace;
436cf7f2e2dSJohn Marino 
437cf7f2e2dSJohn Marino   /* The arguments string to use when running.  */
438cf7f2e2dSJohn Marino   char *args;
439cf7f2e2dSJohn Marino 
440cf7f2e2dSJohn Marino   /* The size of elements in argv.  */
441cf7f2e2dSJohn Marino   int argc;
442cf7f2e2dSJohn Marino 
443cf7f2e2dSJohn Marino   /* The vector version of arguments.  If ARGC is nonzero,
444cf7f2e2dSJohn Marino      then we must compute ARGS from this (via the target).
445cf7f2e2dSJohn Marino      This is always coming from main's argv and therefore
446cf7f2e2dSJohn Marino      should never be freed.  */
447cf7f2e2dSJohn Marino   char **argv;
448cf7f2e2dSJohn Marino 
449cf7f2e2dSJohn Marino   /* The name of terminal device to use for I/O.  */
450cf7f2e2dSJohn Marino   char *terminal;
451cf7f2e2dSJohn Marino 
452cf7f2e2dSJohn Marino   /* Environment to use for running inferior,
453cf7f2e2dSJohn Marino      in format described in environ.h.  */
454cf7f2e2dSJohn Marino   struct gdb_environ *environment;
455cf7f2e2dSJohn Marino 
4565796c8dcSSimon Schubert   /* Nonzero if this child process was attached rather than
4575796c8dcSSimon Schubert      forked.  */
4585796c8dcSSimon Schubert   int attach_flag;
4595796c8dcSSimon Schubert 
460cf7f2e2dSJohn Marino   /* If this inferior is a vfork child, then this is the pointer to
461cf7f2e2dSJohn Marino      its vfork parent, if GDB is still attached to it.  */
462cf7f2e2dSJohn Marino   struct inferior *vfork_parent;
463cf7f2e2dSJohn Marino 
464cf7f2e2dSJohn Marino   /* If this process is a vfork parent, this is the pointer to the
465cf7f2e2dSJohn Marino      child.  Since a vfork parent is left frozen by the kernel until
466cf7f2e2dSJohn Marino      the child execs or exits, a process can only have one vfork child
467cf7f2e2dSJohn Marino      at a given time.  */
468cf7f2e2dSJohn Marino   struct inferior *vfork_child;
469cf7f2e2dSJohn Marino 
470cf7f2e2dSJohn Marino   /* True if this inferior should be detached when it's vfork sibling
471cf7f2e2dSJohn Marino      exits or execs.  */
472cf7f2e2dSJohn Marino   int pending_detach;
473cf7f2e2dSJohn Marino 
474cf7f2e2dSJohn Marino   /* True if this inferior is a vfork parent waiting for a vfork child
475cf7f2e2dSJohn Marino      not under our control to be done with the shared memory region,
476cf7f2e2dSJohn Marino      either by exiting or execing.  */
477cf7f2e2dSJohn Marino   int waiting_for_vfork_done;
478cf7f2e2dSJohn Marino 
479cf7f2e2dSJohn Marino   /* True if we're in the process of detaching from this inferior.  */
480cf7f2e2dSJohn Marino   int detaching;
481cf7f2e2dSJohn Marino 
4825796c8dcSSimon Schubert   /* What is left to do for an execution command after any thread of
4835796c8dcSSimon Schubert      this inferior stops.  For continuations associated with a
4845796c8dcSSimon Schubert      specific thread, see `struct thread_info'.  */
4855796c8dcSSimon Schubert   struct continuation *continuations;
4865796c8dcSSimon Schubert 
4875796c8dcSSimon Schubert   /* Private data used by the target vector implementation.  */
4885796c8dcSSimon Schubert   struct private_inferior *private;
4895796c8dcSSimon Schubert 
490c50c785cSJohn Marino   /* HAS_EXIT_CODE is true if the inferior exited with an exit code.
491c50c785cSJohn Marino      In this case, the EXIT_CODE field is also valid.  */
492c50c785cSJohn Marino   int has_exit_code;
493c50c785cSJohn Marino   LONGEST exit_code;
494c50c785cSJohn Marino 
495*ef5ccd6cSJohn Marino   /* Default flags to pass to the symbol reading functions.  These are
496*ef5ccd6cSJohn Marino      used whenever a new objfile is created.  The valid values come
497*ef5ccd6cSJohn Marino      from enum symfile_add_flags.  */
498*ef5ccd6cSJohn Marino   int symfile_flags;
4995796c8dcSSimon Schubert 
500*ef5ccd6cSJohn Marino   /* Info about an inferior's target description (if it's fetched; the
501*ef5ccd6cSJohn Marino      user supplied description's filename, if any; etc.).  */
502*ef5ccd6cSJohn Marino   struct target_desc_info *tdesc_info;
5035796c8dcSSimon Schubert 
504*ef5ccd6cSJohn Marino   /* The architecture associated with the inferior through the
505*ef5ccd6cSJohn Marino      connection to the target.
5065796c8dcSSimon Schubert 
507*ef5ccd6cSJohn Marino      The architecture vector provides some information that is really
508*ef5ccd6cSJohn Marino      a property of the inferior, accessed through a particular target:
509*ef5ccd6cSJohn Marino      ptrace operations; the layout of certain RSP packets; the
510*ef5ccd6cSJohn Marino      solib_ops vector; etc.  To differentiate architecture accesses to
511*ef5ccd6cSJohn Marino      per-inferior/target properties from
512*ef5ccd6cSJohn Marino      per-thread/per-frame/per-objfile properties, accesses to
513*ef5ccd6cSJohn Marino      per-inferior/target properties should be made through
514*ef5ccd6cSJohn Marino      this gdbarch.  */
515*ef5ccd6cSJohn Marino   struct gdbarch *gdbarch;
516cf7f2e2dSJohn Marino 
517cf7f2e2dSJohn Marino   /* Per inferior data-pointers required by other GDB modules.  */
518*ef5ccd6cSJohn Marino   REGISTRY_FIELDS;
5195796c8dcSSimon Schubert };
5205796c8dcSSimon Schubert 
521cf7f2e2dSJohn Marino /* Keep a registry of per-inferior data-pointers required by other GDB
522cf7f2e2dSJohn Marino    modules.  */
523cf7f2e2dSJohn Marino 
524*ef5ccd6cSJohn Marino DECLARE_REGISTRY (inferior);
525cf7f2e2dSJohn Marino 
5265796c8dcSSimon Schubert /* Create an empty inferior list, or empty the existing one.  */
5275796c8dcSSimon Schubert extern void init_inferior_list (void);
5285796c8dcSSimon Schubert 
5295796c8dcSSimon Schubert /* Add an inferior to the inferior list, print a message that a new
5305796c8dcSSimon Schubert    inferior is found, and return the pointer to the new inferior.
5315796c8dcSSimon Schubert    Caller may use this pointer to initialize the private inferior
5325796c8dcSSimon Schubert    data.  */
5335796c8dcSSimon Schubert extern struct inferior *add_inferior (int pid);
5345796c8dcSSimon Schubert 
5355796c8dcSSimon Schubert /* Same as add_inferior, but don't print new inferior notifications to
5365796c8dcSSimon Schubert    the CLI.  */
5375796c8dcSSimon Schubert extern struct inferior *add_inferior_silent (int pid);
5385796c8dcSSimon Schubert 
5395796c8dcSSimon Schubert /* Delete an existing inferior list entry, due to inferior exit.  */
5405796c8dcSSimon Schubert extern void delete_inferior (int pid);
5415796c8dcSSimon Schubert 
542cf7f2e2dSJohn Marino extern void delete_inferior_1 (struct inferior *todel, int silent);
543cf7f2e2dSJohn Marino 
5445796c8dcSSimon Schubert /* Same as delete_inferior, but don't print new inferior notifications
5455796c8dcSSimon Schubert    to the CLI.  */
5465796c8dcSSimon Schubert extern void delete_inferior_silent (int pid);
5475796c8dcSSimon Schubert 
5485796c8dcSSimon Schubert /* Delete an existing inferior list entry, due to inferior detaching.  */
5495796c8dcSSimon Schubert extern void detach_inferior (int pid);
5505796c8dcSSimon Schubert 
551cf7f2e2dSJohn Marino extern void exit_inferior (int pid);
552cf7f2e2dSJohn Marino 
553cf7f2e2dSJohn Marino extern void exit_inferior_silent (int pid);
554cf7f2e2dSJohn Marino 
555cf7f2e2dSJohn Marino extern void exit_inferior_num_silent (int num);
556cf7f2e2dSJohn Marino 
557cf7f2e2dSJohn Marino extern void inferior_appeared (struct inferior *inf, int pid);
558cf7f2e2dSJohn Marino 
5595796c8dcSSimon Schubert /* Get rid of all inferiors.  */
5605796c8dcSSimon Schubert extern void discard_all_inferiors (void);
5615796c8dcSSimon Schubert 
5625796c8dcSSimon Schubert /* Translate the integer inferior id (GDB's homegrown id, not the system's)
5635796c8dcSSimon Schubert    into a "pid" (which may be overloaded with extra inferior information).  */
5645796c8dcSSimon Schubert extern int gdb_inferior_id_to_pid (int);
5655796c8dcSSimon Schubert 
5665796c8dcSSimon Schubert /* Translate a target 'pid' into the integer inferior id (GDB's
5675796c8dcSSimon Schubert    homegrown id, not the system's).  */
5685796c8dcSSimon Schubert extern int pid_to_gdb_inferior_id (int pid);
5695796c8dcSSimon Schubert 
5705796c8dcSSimon Schubert /* Boolean test for an already-known pid.  */
5715796c8dcSSimon Schubert extern int in_inferior_list (int pid);
5725796c8dcSSimon Schubert 
5735796c8dcSSimon Schubert /* Boolean test for an already-known inferior id (GDB's homegrown id,
5745796c8dcSSimon Schubert    not the system's).  */
5755796c8dcSSimon Schubert extern int valid_gdb_inferior_id (int num);
5765796c8dcSSimon Schubert 
577cf7f2e2dSJohn Marino /* Search function to lookup an inferior by target 'pid'.  */
5785796c8dcSSimon Schubert extern struct inferior *find_inferior_pid (int pid);
5795796c8dcSSimon Schubert 
580cf7f2e2dSJohn Marino /* Search function to lookup an inferior by GDB 'num'.  */
581cf7f2e2dSJohn Marino extern struct inferior *find_inferior_id (int num);
582cf7f2e2dSJohn Marino 
583cf7f2e2dSJohn Marino /* Find an inferior bound to PSPACE.  */
584cf7f2e2dSJohn Marino extern struct inferior *
585cf7f2e2dSJohn Marino   find_inferior_for_program_space (struct program_space *pspace);
586cf7f2e2dSJohn Marino 
5875796c8dcSSimon Schubert /* Inferior iterator function.
5885796c8dcSSimon Schubert 
5895796c8dcSSimon Schubert    Calls a callback function once for each inferior, so long as the
5905796c8dcSSimon Schubert    callback function returns false.  If the callback function returns
5915796c8dcSSimon Schubert    true, the iteration will end and the current inferior will be
5925796c8dcSSimon Schubert    returned.  This can be useful for implementing a search for a
5935796c8dcSSimon Schubert    inferior with arbitrary attributes, or for applying some operation
5945796c8dcSSimon Schubert    to every inferior.
5955796c8dcSSimon Schubert 
5965796c8dcSSimon Schubert    It is safe to delete the iterated inferior from the callback.  */
5975796c8dcSSimon Schubert extern struct inferior *iterate_over_inferiors (int (*) (struct inferior *,
5985796c8dcSSimon Schubert 							 void *),
5995796c8dcSSimon Schubert 						void *);
6005796c8dcSSimon Schubert 
6015796c8dcSSimon Schubert /* Returns true if the inferior list is not empty.  */
6025796c8dcSSimon Schubert extern int have_inferiors (void);
6035796c8dcSSimon Schubert 
6045796c8dcSSimon Schubert /* Returns true if there are any live inferiors in the inferior list
6055796c8dcSSimon Schubert    (not cores, not executables, real live processes).  */
6065796c8dcSSimon Schubert extern int have_live_inferiors (void);
6075796c8dcSSimon Schubert 
6085796c8dcSSimon Schubert /* Return a pointer to the current inferior.  It is an error to call
6095796c8dcSSimon Schubert    this if there is no current inferior.  */
6105796c8dcSSimon Schubert extern struct inferior *current_inferior (void);
6115796c8dcSSimon Schubert 
612cf7f2e2dSJohn Marino extern void set_current_inferior (struct inferior *);
613cf7f2e2dSJohn Marino 
614cf7f2e2dSJohn Marino extern struct cleanup *save_current_inferior (void);
615cf7f2e2dSJohn Marino 
616a45ae5f8SJohn Marino /* Traverse all inferiors.  */
617a45ae5f8SJohn Marino 
618a45ae5f8SJohn Marino #define ALL_INFERIORS(I) \
619a45ae5f8SJohn Marino   for ((I) = inferior_list; (I); (I) = (I)->next)
620a45ae5f8SJohn Marino 
621cf7f2e2dSJohn Marino extern struct inferior *inferior_list;
622cf7f2e2dSJohn Marino 
623cf7f2e2dSJohn Marino /* Prune away automatically added inferiors that aren't required
624cf7f2e2dSJohn Marino    anymore.  */
625cf7f2e2dSJohn Marino extern void prune_inferiors (void);
626cf7f2e2dSJohn Marino 
627cf7f2e2dSJohn Marino extern int number_of_inferiors (void);
628cf7f2e2dSJohn Marino 
629cf7f2e2dSJohn Marino extern struct inferior *add_inferior_with_spaces (void);
630cf7f2e2dSJohn Marino 
631cf7f2e2dSJohn Marino extern void update_observer_mode (void);
632cf7f2e2dSJohn Marino 
633*ef5ccd6cSJohn Marino extern void update_signals_program_target (void);
634*ef5ccd6cSJohn Marino 
635*ef5ccd6cSJohn Marino extern void signal_catch_update (const unsigned int *);
636*ef5ccd6cSJohn Marino 
637*ef5ccd6cSJohn Marino /* In some circumstances we allow a command to specify a numeric
638*ef5ccd6cSJohn Marino    signal.  The idea is to keep these circumstances limited so that
639*ef5ccd6cSJohn Marino    users (and scripts) develop portable habits.  For comparison,
640*ef5ccd6cSJohn Marino    POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
641*ef5ccd6cSJohn Marino    numeric signal at all is obsolescent.  We are slightly more lenient
642*ef5ccd6cSJohn Marino    and allow 1-15 which should match host signal numbers on most
643*ef5ccd6cSJohn Marino    systems.  Use of symbolic signal names is strongly encouraged.  */
644*ef5ccd6cSJohn Marino 
645*ef5ccd6cSJohn Marino enum gdb_signal gdb_signal_from_command (int num);
646*ef5ccd6cSJohn Marino 
6475796c8dcSSimon Schubert #endif /* !defined (INFERIOR_H) */
648