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 45796c8dcSSimon Schubert Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 5*cf7f2e2dSJohn Marino 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 65796c8dcSSimon Schubert Free Software Foundation, Inc. 75796c8dcSSimon Schubert 85796c8dcSSimon Schubert This file is part of GDB. 95796c8dcSSimon Schubert 105796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 115796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 125796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 135796c8dcSSimon Schubert (at your option) any later version. 145796c8dcSSimon Schubert 155796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 165796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 175796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 185796c8dcSSimon Schubert GNU General Public License for more details. 195796c8dcSSimon Schubert 205796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 215796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 225796c8dcSSimon Schubert 235796c8dcSSimon Schubert #if !defined (INFERIOR_H) 245796c8dcSSimon Schubert #define INFERIOR_H 1 255796c8dcSSimon Schubert 265796c8dcSSimon Schubert struct target_waitstatus; 275796c8dcSSimon Schubert struct frame_info; 285796c8dcSSimon Schubert struct ui_file; 295796c8dcSSimon Schubert struct type; 305796c8dcSSimon Schubert struct gdbarch; 315796c8dcSSimon Schubert struct regcache; 325796c8dcSSimon Schubert struct ui_out; 335796c8dcSSimon Schubert struct terminal_info; 345796c8dcSSimon Schubert 355796c8dcSSimon Schubert /* For bpstat. */ 365796c8dcSSimon Schubert #include "breakpoint.h" 375796c8dcSSimon Schubert 385796c8dcSSimon Schubert /* For enum target_signal. */ 395796c8dcSSimon Schubert #include "target.h" 405796c8dcSSimon Schubert 415796c8dcSSimon Schubert /* For struct frame_id. */ 425796c8dcSSimon Schubert #include "frame.h" 435796c8dcSSimon Schubert 44*cf7f2e2dSJohn Marino #include "progspace.h" 45*cf7f2e2dSJohn Marino 465796c8dcSSimon Schubert /* Two structures are used to record inferior state. 475796c8dcSSimon Schubert 485796c8dcSSimon Schubert inferior_thread_state contains state about the program itself like its 495796c8dcSSimon Schubert registers and any signal it received when it last stopped. 505796c8dcSSimon Schubert This state must be restored regardless of how the inferior function call 515796c8dcSSimon Schubert ends (either successfully, or after it hits a breakpoint or signal) 525796c8dcSSimon Schubert if the program is to properly continue where it left off. 535796c8dcSSimon Schubert 545796c8dcSSimon Schubert inferior_status contains state regarding gdb's control of the inferior 555796c8dcSSimon Schubert itself like stepping control. It also contains session state like the 565796c8dcSSimon Schubert user's currently selected frame. 575796c8dcSSimon Schubert 585796c8dcSSimon Schubert Call these routines around hand called functions, including function calls 595796c8dcSSimon Schubert in conditional breakpoints for example. */ 605796c8dcSSimon Schubert 615796c8dcSSimon Schubert struct inferior_thread_state; 625796c8dcSSimon Schubert struct inferior_status; 635796c8dcSSimon Schubert 645796c8dcSSimon Schubert extern struct inferior_thread_state *save_inferior_thread_state (void); 655796c8dcSSimon Schubert extern struct inferior_status *save_inferior_status (void); 665796c8dcSSimon Schubert 675796c8dcSSimon Schubert extern void restore_inferior_thread_state (struct inferior_thread_state *); 685796c8dcSSimon Schubert extern void restore_inferior_status (struct inferior_status *); 695796c8dcSSimon Schubert 705796c8dcSSimon Schubert extern struct cleanup *make_cleanup_restore_inferior_thread_state (struct inferior_thread_state *); 715796c8dcSSimon Schubert extern struct cleanup *make_cleanup_restore_inferior_status (struct inferior_status *); 725796c8dcSSimon Schubert 735796c8dcSSimon Schubert extern void discard_inferior_thread_state (struct inferior_thread_state *); 745796c8dcSSimon Schubert extern void discard_inferior_status (struct inferior_status *); 755796c8dcSSimon Schubert 765796c8dcSSimon Schubert extern struct regcache *get_inferior_thread_state_regcache (struct inferior_thread_state *); 775796c8dcSSimon Schubert 785796c8dcSSimon Schubert /* The -1 ptid, often used to indicate either an error condition 795796c8dcSSimon Schubert or a "don't care" condition, i.e, "run all threads." */ 805796c8dcSSimon Schubert extern ptid_t minus_one_ptid; 815796c8dcSSimon Schubert 825796c8dcSSimon Schubert /* The null or zero ptid, often used to indicate no process. */ 835796c8dcSSimon Schubert extern ptid_t null_ptid; 845796c8dcSSimon Schubert 855796c8dcSSimon Schubert /* Attempt to find and return an existing ptid with the given PID, LWP, 865796c8dcSSimon Schubert and TID components. If none exists, create a new one and return 875796c8dcSSimon Schubert that. */ 885796c8dcSSimon Schubert ptid_t ptid_build (int pid, long lwp, long tid); 895796c8dcSSimon Schubert 905796c8dcSSimon Schubert /* Find/Create a ptid from just a pid. */ 915796c8dcSSimon Schubert ptid_t pid_to_ptid (int pid); 925796c8dcSSimon Schubert 935796c8dcSSimon Schubert /* Fetch the pid (process id) component from a ptid. */ 945796c8dcSSimon Schubert int ptid_get_pid (ptid_t ptid); 955796c8dcSSimon Schubert 965796c8dcSSimon Schubert /* Fetch the lwp (lightweight process) component from a ptid. */ 975796c8dcSSimon Schubert long ptid_get_lwp (ptid_t ptid); 985796c8dcSSimon Schubert 995796c8dcSSimon Schubert /* Fetch the tid (thread id) component from a ptid. */ 1005796c8dcSSimon Schubert long ptid_get_tid (ptid_t ptid); 1015796c8dcSSimon Schubert 1025796c8dcSSimon Schubert /* Compare two ptids to see if they are equal */ 1035796c8dcSSimon Schubert extern int ptid_equal (ptid_t p1, ptid_t p2); 1045796c8dcSSimon Schubert 1055796c8dcSSimon Schubert /* Return true if PTID represents a process id. */ 1065796c8dcSSimon Schubert extern int ptid_is_pid (ptid_t ptid); 1075796c8dcSSimon Schubert 108*cf7f2e2dSJohn Marino /* Returns true if PTID matches filter FILTER. FILTER can be the wild 109*cf7f2e2dSJohn Marino card MINUS_ONE_PTID (all ptid match it); can be a ptid representing 110*cf7f2e2dSJohn Marino a process (ptid_is_pid returns true), in which case, all lwps and 111*cf7f2e2dSJohn Marino threads of that given process match, lwps and threads of other 112*cf7f2e2dSJohn Marino processes do not; or, it can represent a specific thread, in which 113*cf7f2e2dSJohn Marino case, only that thread will match true. PTID must represent a 114*cf7f2e2dSJohn Marino specific LWP or THREAD, it can never be a wild card. */ 115*cf7f2e2dSJohn Marino 116*cf7f2e2dSJohn Marino extern int ptid_match (ptid_t ptid, ptid_t filter); 117*cf7f2e2dSJohn Marino 1185796c8dcSSimon Schubert /* Save value of inferior_ptid so that it may be restored by 1195796c8dcSSimon Schubert a later call to do_cleanups(). Returns the struct cleanup 1205796c8dcSSimon Schubert pointer needed for later doing the cleanup. */ 1215796c8dcSSimon Schubert extern struct cleanup * save_inferior_ptid (void); 1225796c8dcSSimon Schubert 1235796c8dcSSimon Schubert extern void set_sigint_trap (void); 1245796c8dcSSimon Schubert 1255796c8dcSSimon Schubert extern void clear_sigint_trap (void); 1265796c8dcSSimon Schubert 1275796c8dcSSimon Schubert /* Set/get file name for default use for standard in/out in the inferior. */ 1285796c8dcSSimon Schubert 1295796c8dcSSimon Schubert extern void set_inferior_io_terminal (const char *terminal_name); 1305796c8dcSSimon Schubert extern const char *get_inferior_io_terminal (void); 1315796c8dcSSimon Schubert 1325796c8dcSSimon Schubert /* Collected pid, tid, etc. of the debugged inferior. When there's 1335796c8dcSSimon Schubert no inferior, PIDGET (inferior_ptid) will be 0. */ 1345796c8dcSSimon Schubert 1355796c8dcSSimon Schubert extern ptid_t inferior_ptid; 1365796c8dcSSimon Schubert 1375796c8dcSSimon Schubert /* Are we simulating synchronous execution? This is used in async gdb 1385796c8dcSSimon Schubert to implement the 'run', 'continue' etc commands, which will not 1395796c8dcSSimon Schubert redisplay the prompt until the execution is actually over. */ 1405796c8dcSSimon Schubert extern int sync_execution; 1415796c8dcSSimon Schubert 1425796c8dcSSimon Schubert /* Inferior environment. */ 1435796c8dcSSimon Schubert 1445796c8dcSSimon Schubert extern void clear_proceed_status (void); 1455796c8dcSSimon Schubert 1465796c8dcSSimon Schubert extern void proceed (CORE_ADDR, enum target_signal, int); 1475796c8dcSSimon Schubert 1485796c8dcSSimon Schubert extern int sched_multi; 1495796c8dcSSimon Schubert 1505796c8dcSSimon Schubert /* When set, stop the 'step' command if we enter a function which has 1515796c8dcSSimon Schubert no line number information. The normal behavior is that we step 1525796c8dcSSimon Schubert over such function. */ 1535796c8dcSSimon Schubert extern int step_stop_if_no_debug; 1545796c8dcSSimon Schubert 1555796c8dcSSimon Schubert /* If set, the inferior should be controlled in non-stop mode. In 1565796c8dcSSimon Schubert this mode, each thread is controlled independently. Execution 1575796c8dcSSimon Schubert commands apply only to the the selected thread by default, and stop 1585796c8dcSSimon Schubert events stop only the thread that had the event -- the other threads 1595796c8dcSSimon Schubert are kept running freely. */ 1605796c8dcSSimon Schubert extern int non_stop; 1615796c8dcSSimon Schubert 162*cf7f2e2dSJohn Marino /* If set (default), when following a fork, GDB will detach from one 163*cf7f2e2dSJohn Marino the fork branches, child or parent. Exactly which branch is 164*cf7f2e2dSJohn Marino detached depends on 'set follow-fork-mode' setting. */ 165*cf7f2e2dSJohn Marino extern int detach_fork; 166*cf7f2e2dSJohn Marino 1675796c8dcSSimon Schubert extern void generic_mourn_inferior (void); 1685796c8dcSSimon Schubert 1695796c8dcSSimon Schubert extern void terminal_save_ours (void); 1705796c8dcSSimon Schubert 1715796c8dcSSimon Schubert extern void terminal_ours (void); 1725796c8dcSSimon Schubert 1735796c8dcSSimon Schubert extern CORE_ADDR unsigned_pointer_to_address (struct gdbarch *gdbarch, 1745796c8dcSSimon Schubert struct type *type, 1755796c8dcSSimon Schubert const gdb_byte *buf); 1765796c8dcSSimon Schubert extern void unsigned_address_to_pointer (struct gdbarch *gdbarch, 1775796c8dcSSimon Schubert struct type *type, gdb_byte *buf, 1785796c8dcSSimon Schubert CORE_ADDR addr); 1795796c8dcSSimon Schubert extern CORE_ADDR signed_pointer_to_address (struct gdbarch *gdbarch, 1805796c8dcSSimon Schubert struct type *type, 1815796c8dcSSimon Schubert const gdb_byte *buf); 1825796c8dcSSimon Schubert extern void address_to_signed_pointer (struct gdbarch *gdbarch, 1835796c8dcSSimon Schubert struct type *type, gdb_byte *buf, 1845796c8dcSSimon Schubert CORE_ADDR addr); 1855796c8dcSSimon Schubert 1865796c8dcSSimon Schubert extern void wait_for_inferior (int treat_exec_as_sigtrap); 1875796c8dcSSimon Schubert 188*cf7f2e2dSJohn Marino extern void prepare_for_detach (void); 189*cf7f2e2dSJohn Marino 1905796c8dcSSimon Schubert extern void fetch_inferior_event (void *); 1915796c8dcSSimon Schubert 1925796c8dcSSimon Schubert extern void init_wait_for_inferior (void); 1935796c8dcSSimon Schubert 1945796c8dcSSimon Schubert extern void close_exec_file (void); 1955796c8dcSSimon Schubert 1965796c8dcSSimon Schubert extern void reopen_exec_file (void); 1975796c8dcSSimon Schubert 1985796c8dcSSimon Schubert /* The `resume' routine should only be called in special circumstances. 1995796c8dcSSimon Schubert Normally, use `proceed', which handles a lot of bookkeeping. */ 2005796c8dcSSimon Schubert 2015796c8dcSSimon Schubert extern void resume (int, enum target_signal); 2025796c8dcSSimon Schubert 2035796c8dcSSimon Schubert /* From misc files */ 2045796c8dcSSimon Schubert 2055796c8dcSSimon Schubert extern void default_print_registers_info (struct gdbarch *gdbarch, 2065796c8dcSSimon Schubert struct ui_file *file, 2075796c8dcSSimon Schubert struct frame_info *frame, 2085796c8dcSSimon Schubert int regnum, int all); 2095796c8dcSSimon Schubert 2105796c8dcSSimon Schubert extern void child_terminal_info (char *, int); 2115796c8dcSSimon Schubert 2125796c8dcSSimon Schubert extern void term_info (char *, int); 2135796c8dcSSimon Schubert 2145796c8dcSSimon Schubert extern void terminal_ours_for_output (void); 2155796c8dcSSimon Schubert 2165796c8dcSSimon Schubert extern void terminal_inferior (void); 2175796c8dcSSimon Schubert 2185796c8dcSSimon Schubert extern void terminal_init_inferior (void); 2195796c8dcSSimon Schubert 2205796c8dcSSimon Schubert extern void terminal_init_inferior_with_pgrp (int pgrp); 2215796c8dcSSimon Schubert 2225796c8dcSSimon Schubert /* From fork-child.c */ 2235796c8dcSSimon Schubert 2245796c8dcSSimon Schubert extern int fork_inferior (char *, char *, char **, 2255796c8dcSSimon Schubert void (*)(void), 2265796c8dcSSimon Schubert void (*)(int), void (*)(void), char *); 2275796c8dcSSimon Schubert 2285796c8dcSSimon Schubert 2295796c8dcSSimon Schubert extern void startup_inferior (int); 2305796c8dcSSimon Schubert 2315796c8dcSSimon Schubert extern char *construct_inferior_arguments (int, char **); 2325796c8dcSSimon Schubert 2335796c8dcSSimon Schubert /* From infrun.c */ 2345796c8dcSSimon Schubert 235*cf7f2e2dSJohn Marino extern int debug_infrun; 236*cf7f2e2dSJohn Marino 237*cf7f2e2dSJohn Marino extern int stop_on_solib_events; 238*cf7f2e2dSJohn Marino 2395796c8dcSSimon Schubert extern void start_remote (int from_tty); 2405796c8dcSSimon Schubert 2415796c8dcSSimon Schubert extern void normal_stop (void); 2425796c8dcSSimon Schubert 2435796c8dcSSimon Schubert extern int signal_stop_state (int); 2445796c8dcSSimon Schubert 2455796c8dcSSimon Schubert extern int signal_print_state (int); 2465796c8dcSSimon Schubert 2475796c8dcSSimon Schubert extern int signal_pass_state (int); 2485796c8dcSSimon Schubert 2495796c8dcSSimon Schubert extern int signal_stop_update (int, int); 2505796c8dcSSimon Schubert 2515796c8dcSSimon Schubert extern int signal_print_update (int, int); 2525796c8dcSSimon Schubert 2535796c8dcSSimon Schubert extern int signal_pass_update (int, int); 2545796c8dcSSimon Schubert 2555796c8dcSSimon Schubert extern void get_last_target_status(ptid_t *ptid, 2565796c8dcSSimon Schubert struct target_waitstatus *status); 2575796c8dcSSimon Schubert 2585796c8dcSSimon Schubert extern void follow_inferior_reset_breakpoints (void); 2595796c8dcSSimon Schubert 2605796c8dcSSimon Schubert /* Throw an error indicating the current thread is running. */ 2615796c8dcSSimon Schubert extern void error_is_running (void); 2625796c8dcSSimon Schubert 2635796c8dcSSimon Schubert /* Calls error_is_running if the current thread is running. */ 2645796c8dcSSimon Schubert extern void ensure_not_running (void); 2655796c8dcSSimon Schubert 2665796c8dcSSimon Schubert void set_step_info (struct frame_info *frame, struct symtab_and_line sal); 2675796c8dcSSimon Schubert 2685796c8dcSSimon Schubert /* From infcmd.c */ 2695796c8dcSSimon Schubert 2705796c8dcSSimon Schubert extern void post_create_inferior (struct target_ops *, int); 2715796c8dcSSimon Schubert 2725796c8dcSSimon Schubert extern void attach_command (char *, int); 2735796c8dcSSimon Schubert 2745796c8dcSSimon Schubert extern char *get_inferior_args (void); 2755796c8dcSSimon Schubert 276*cf7f2e2dSJohn Marino extern void set_inferior_args (char *); 2775796c8dcSSimon Schubert 2785796c8dcSSimon Schubert extern void set_inferior_args_vector (int, char **); 2795796c8dcSSimon Schubert 2805796c8dcSSimon Schubert extern void registers_info (char *, int); 2815796c8dcSSimon Schubert 2825796c8dcSSimon Schubert extern void nexti_command (char *, int); 2835796c8dcSSimon Schubert 2845796c8dcSSimon Schubert extern void stepi_command (char *, int); 2855796c8dcSSimon Schubert 2865796c8dcSSimon Schubert extern void continue_1 (int all_threads); 2875796c8dcSSimon Schubert 2885796c8dcSSimon Schubert extern void continue_command (char *, int); 2895796c8dcSSimon Schubert 2905796c8dcSSimon Schubert extern void interrupt_target_command (char *args, int from_tty); 2915796c8dcSSimon Schubert 2925796c8dcSSimon Schubert extern void interrupt_target_1 (int all_threads); 2935796c8dcSSimon Schubert 2945796c8dcSSimon Schubert extern void detach_command (char *, int); 2955796c8dcSSimon Schubert 2965796c8dcSSimon Schubert extern void notice_new_inferior (ptid_t, int, int); 2975796c8dcSSimon Schubert 2985796c8dcSSimon Schubert /* Address at which inferior stopped. */ 2995796c8dcSSimon Schubert 3005796c8dcSSimon Schubert extern CORE_ADDR stop_pc; 3015796c8dcSSimon Schubert 3025796c8dcSSimon Schubert /* Nonzero if stopped due to completion of a stack dummy routine. */ 3035796c8dcSSimon Schubert 304*cf7f2e2dSJohn Marino extern enum stop_stack_kind stop_stack_dummy; 3055796c8dcSSimon Schubert 3065796c8dcSSimon Schubert /* Nonzero if program stopped due to a random (unexpected) signal in 3075796c8dcSSimon Schubert inferior process. */ 3085796c8dcSSimon Schubert 3095796c8dcSSimon Schubert extern int stopped_by_random_signal; 3105796c8dcSSimon Schubert 3115796c8dcSSimon Schubert /* STEP_OVER_ALL means step over all subroutine calls. 3125796c8dcSSimon Schubert STEP_OVER_UNDEBUGGABLE means step over calls to undebuggable functions. 3135796c8dcSSimon Schubert STEP_OVER_NONE means don't step over any subroutine calls. */ 3145796c8dcSSimon Schubert 3155796c8dcSSimon Schubert enum step_over_calls_kind 3165796c8dcSSimon Schubert { 3175796c8dcSSimon Schubert STEP_OVER_NONE, 3185796c8dcSSimon Schubert STEP_OVER_ALL, 3195796c8dcSSimon Schubert STEP_OVER_UNDEBUGGABLE 3205796c8dcSSimon Schubert }; 3215796c8dcSSimon Schubert 3225796c8dcSSimon Schubert /* Anything but NO_STOP_QUIETLY means we expect a trap and the caller 3235796c8dcSSimon Schubert will handle it themselves. STOP_QUIETLY is used when running in 3245796c8dcSSimon Schubert the shell before the child program has been exec'd and when running 3255796c8dcSSimon Schubert through shared library loading. STOP_QUIETLY_REMOTE is used when 3265796c8dcSSimon Schubert setting up a remote connection; it is like STOP_QUIETLY_NO_SIGSTOP 3275796c8dcSSimon Schubert except that there is no need to hide a signal. */ 3285796c8dcSSimon Schubert 3295796c8dcSSimon Schubert /* It is also used after attach, due to attaching to a process. This 3305796c8dcSSimon Schubert is a bit trickier. When doing an attach, the kernel stops the 3315796c8dcSSimon Schubert debuggee with a SIGSTOP. On newer GNU/Linux kernels (>= 2.5.61) 3325796c8dcSSimon Schubert the handling of SIGSTOP for a ptraced process has changed. Earlier 3335796c8dcSSimon Schubert versions of the kernel would ignore these SIGSTOPs, while now 3345796c8dcSSimon Schubert SIGSTOP is treated like any other signal, i.e. it is not muffled. 3355796c8dcSSimon Schubert 3365796c8dcSSimon Schubert If the gdb user does a 'continue' after the 'attach', gdb passes 3375796c8dcSSimon Schubert the global variable stop_signal (which stores the signal from the 3385796c8dcSSimon Schubert attach, SIGSTOP) to the ptrace(PTRACE_CONT,...) call. This is 3395796c8dcSSimon Schubert problematic, because the kernel doesn't ignore such SIGSTOP 3405796c8dcSSimon Schubert now. I.e. it is reported back to gdb, which in turn presents it 3415796c8dcSSimon Schubert back to the user. 3425796c8dcSSimon Schubert 3435796c8dcSSimon Schubert To avoid the problem, we use STOP_QUIETLY_NO_SIGSTOP, which allows 3445796c8dcSSimon Schubert gdb to clear the value of stop_signal after the attach, so that it 3455796c8dcSSimon Schubert is not passed back down to the kernel. */ 3465796c8dcSSimon Schubert 3475796c8dcSSimon Schubert enum stop_kind 3485796c8dcSSimon Schubert { 3495796c8dcSSimon Schubert NO_STOP_QUIETLY = 0, 3505796c8dcSSimon Schubert STOP_QUIETLY, 3515796c8dcSSimon Schubert STOP_QUIETLY_REMOTE, 3525796c8dcSSimon Schubert STOP_QUIETLY_NO_SIGSTOP 3535796c8dcSSimon Schubert }; 3545796c8dcSSimon Schubert 3555796c8dcSSimon Schubert /* Reverse execution. */ 3565796c8dcSSimon Schubert enum exec_direction_kind 3575796c8dcSSimon Schubert { 3585796c8dcSSimon Schubert EXEC_FORWARD, 3595796c8dcSSimon Schubert EXEC_REVERSE, 3605796c8dcSSimon Schubert EXEC_ERROR 3615796c8dcSSimon Schubert }; 3625796c8dcSSimon Schubert 3635796c8dcSSimon Schubert extern enum exec_direction_kind execution_direction; 3645796c8dcSSimon Schubert 3655796c8dcSSimon Schubert /* Save register contents here when executing a "finish" command or are 3665796c8dcSSimon Schubert about to pop a stack dummy frame, if-and-only-if proceed_to_finish is set. 3675796c8dcSSimon Schubert Thus this contains the return value from the called function (assuming 3685796c8dcSSimon Schubert values are returned in a register). */ 3695796c8dcSSimon Schubert 3705796c8dcSSimon Schubert extern struct regcache *stop_registers; 3715796c8dcSSimon Schubert 3725796c8dcSSimon Schubert /* True if we are debugging displaced stepping. */ 3735796c8dcSSimon Schubert extern int debug_displaced; 3745796c8dcSSimon Schubert 3755796c8dcSSimon Schubert /* Dump LEN bytes at BUF in hex to FILE, followed by a newline. */ 3765796c8dcSSimon Schubert void displaced_step_dump_bytes (struct ui_file *file, 3775796c8dcSSimon Schubert const gdb_byte *buf, size_t len); 3785796c8dcSSimon Schubert 3795796c8dcSSimon Schubert 3805796c8dcSSimon Schubert /* Possible values for gdbarch_call_dummy_location. */ 3815796c8dcSSimon Schubert #define ON_STACK 1 3825796c8dcSSimon Schubert #define AT_ENTRY_POINT 4 3835796c8dcSSimon Schubert #define AT_SYMBOL 5 3845796c8dcSSimon Schubert 3855796c8dcSSimon Schubert /* If STARTUP_WITH_SHELL is set, GDB's "run" 3865796c8dcSSimon Schubert will attempts to start up the debugee under a shell. 3875796c8dcSSimon Schubert This is in order for argument-expansion to occur. E.g., 3885796c8dcSSimon Schubert (gdb) run * 3895796c8dcSSimon Schubert The "*" gets expanded by the shell into a list of files. 3905796c8dcSSimon Schubert While this is a nice feature, it turns out to interact badly 3915796c8dcSSimon Schubert with some of the catch-fork/catch-exec features we have added. 3925796c8dcSSimon Schubert In particular, if the shell does any fork/exec's before 3935796c8dcSSimon Schubert the exec of the target program, that can confuse GDB. 3945796c8dcSSimon Schubert To disable this feature, set STARTUP_WITH_SHELL to 0. 3955796c8dcSSimon Schubert To enable this feature, set STARTUP_WITH_SHELL to 1. 3965796c8dcSSimon Schubert The catch-exec traps expected during start-up will 3975796c8dcSSimon Schubert be 1 if target is not started up with a shell, 2 if it is. 3985796c8dcSSimon Schubert - RT 3995796c8dcSSimon Schubert If you disable this, you need to decrement 4005796c8dcSSimon Schubert START_INFERIOR_TRAPS_EXPECTED in tm.h. */ 4015796c8dcSSimon Schubert #define STARTUP_WITH_SHELL 1 4025796c8dcSSimon Schubert #if !defined(START_INFERIOR_TRAPS_EXPECTED) 4035796c8dcSSimon Schubert #define START_INFERIOR_TRAPS_EXPECTED 2 4045796c8dcSSimon Schubert #endif 4055796c8dcSSimon Schubert 4065796c8dcSSimon Schubert struct private_inferior; 4075796c8dcSSimon Schubert 4085796c8dcSSimon Schubert /* GDB represents the state of each program execution with an object 4095796c8dcSSimon Schubert called an inferior. An inferior typically corresponds to a process 4105796c8dcSSimon Schubert but is more general and applies also to targets that do not have a 4115796c8dcSSimon Schubert notion of processes. Each run of an executable creates a new 4125796c8dcSSimon Schubert inferior, as does each attachment to an existing process. 4135796c8dcSSimon Schubert Inferiors have unique internal identifiers that are different from 4145796c8dcSSimon Schubert target process ids. Each inferior may in turn have multiple 4155796c8dcSSimon Schubert threads running in it. */ 4165796c8dcSSimon Schubert 4175796c8dcSSimon Schubert struct inferior 4185796c8dcSSimon Schubert { 4195796c8dcSSimon Schubert /* Pointer to next inferior in singly-linked list of inferiors. */ 4205796c8dcSSimon Schubert struct inferior *next; 4215796c8dcSSimon Schubert 4225796c8dcSSimon Schubert /* Convenient handle (GDB inferior id). Unique across all 4235796c8dcSSimon Schubert inferiors. */ 4245796c8dcSSimon Schubert int num; 4255796c8dcSSimon Schubert 4265796c8dcSSimon Schubert /* Actual target inferior id, usually, a process id. This matches 4275796c8dcSSimon Schubert the ptid_t.pid member of threads of this inferior. */ 4285796c8dcSSimon Schubert int pid; 4295796c8dcSSimon Schubert 430*cf7f2e2dSJohn Marino /* True if this was an auto-created inferior, e.g. created from 431*cf7f2e2dSJohn Marino following a fork; false, if this inferior was manually added by 432*cf7f2e2dSJohn Marino the user, and we should not attempt to prune it 433*cf7f2e2dSJohn Marino automatically. */ 434*cf7f2e2dSJohn Marino int removable; 435*cf7f2e2dSJohn Marino 436*cf7f2e2dSJohn Marino /* The address space bound to this inferior. */ 437*cf7f2e2dSJohn Marino struct address_space *aspace; 438*cf7f2e2dSJohn Marino 439*cf7f2e2dSJohn Marino /* The program space bound to this inferior. */ 440*cf7f2e2dSJohn Marino struct program_space *pspace; 441*cf7f2e2dSJohn Marino 442*cf7f2e2dSJohn Marino /* The arguments string to use when running. */ 443*cf7f2e2dSJohn Marino char *args; 444*cf7f2e2dSJohn Marino 445*cf7f2e2dSJohn Marino /* The size of elements in argv. */ 446*cf7f2e2dSJohn Marino int argc; 447*cf7f2e2dSJohn Marino 448*cf7f2e2dSJohn Marino /* The vector version of arguments. If ARGC is nonzero, 449*cf7f2e2dSJohn Marino then we must compute ARGS from this (via the target). 450*cf7f2e2dSJohn Marino This is always coming from main's argv and therefore 451*cf7f2e2dSJohn Marino should never be freed. */ 452*cf7f2e2dSJohn Marino char **argv; 453*cf7f2e2dSJohn Marino 454*cf7f2e2dSJohn Marino /* The name of terminal device to use for I/O. */ 455*cf7f2e2dSJohn Marino char *terminal; 456*cf7f2e2dSJohn Marino 457*cf7f2e2dSJohn Marino /* Environment to use for running inferior, 458*cf7f2e2dSJohn Marino in format described in environ.h. */ 459*cf7f2e2dSJohn Marino struct gdb_environ *environment; 460*cf7f2e2dSJohn Marino 4615796c8dcSSimon Schubert /* See the definition of stop_kind above. */ 4625796c8dcSSimon Schubert enum stop_kind stop_soon; 4635796c8dcSSimon Schubert 4645796c8dcSSimon Schubert /* Nonzero if this child process was attached rather than 4655796c8dcSSimon Schubert forked. */ 4665796c8dcSSimon Schubert int attach_flag; 4675796c8dcSSimon Schubert 468*cf7f2e2dSJohn Marino /* If this inferior is a vfork child, then this is the pointer to 469*cf7f2e2dSJohn Marino its vfork parent, if GDB is still attached to it. */ 470*cf7f2e2dSJohn Marino struct inferior *vfork_parent; 471*cf7f2e2dSJohn Marino 472*cf7f2e2dSJohn Marino /* If this process is a vfork parent, this is the pointer to the 473*cf7f2e2dSJohn Marino child. Since a vfork parent is left frozen by the kernel until 474*cf7f2e2dSJohn Marino the child execs or exits, a process can only have one vfork child 475*cf7f2e2dSJohn Marino at a given time. */ 476*cf7f2e2dSJohn Marino struct inferior *vfork_child; 477*cf7f2e2dSJohn Marino 478*cf7f2e2dSJohn Marino /* True if this inferior should be detached when it's vfork sibling 479*cf7f2e2dSJohn Marino exits or execs. */ 480*cf7f2e2dSJohn Marino int pending_detach; 481*cf7f2e2dSJohn Marino 482*cf7f2e2dSJohn Marino /* True if this inferior is a vfork parent waiting for a vfork child 483*cf7f2e2dSJohn Marino not under our control to be done with the shared memory region, 484*cf7f2e2dSJohn Marino either by exiting or execing. */ 485*cf7f2e2dSJohn Marino int waiting_for_vfork_done; 486*cf7f2e2dSJohn Marino 487*cf7f2e2dSJohn Marino /* True if we're in the process of detaching from this inferior. */ 488*cf7f2e2dSJohn Marino int detaching; 489*cf7f2e2dSJohn Marino 4905796c8dcSSimon Schubert /* What is left to do for an execution command after any thread of 4915796c8dcSSimon Schubert this inferior stops. For continuations associated with a 4925796c8dcSSimon Schubert specific thread, see `struct thread_info'. */ 4935796c8dcSSimon Schubert struct continuation *continuations; 4945796c8dcSSimon Schubert 4955796c8dcSSimon Schubert /* Private data used by the target vector implementation. */ 4965796c8dcSSimon Schubert struct private_inferior *private; 4975796c8dcSSimon Schubert 4985796c8dcSSimon Schubert /* We keep a count of the number of times the user has requested a 4995796c8dcSSimon Schubert particular syscall to be tracked, and pass this information to the 5005796c8dcSSimon Schubert target. This lets capable targets implement filtering directly. */ 5015796c8dcSSimon Schubert 5025796c8dcSSimon Schubert /* Number of times that "any" syscall is requested. */ 5035796c8dcSSimon Schubert int any_syscall_count; 5045796c8dcSSimon Schubert 5055796c8dcSSimon Schubert /* Count of each system call. */ 5065796c8dcSSimon Schubert VEC(int) *syscalls_counts; 5075796c8dcSSimon Schubert 5085796c8dcSSimon Schubert /* This counts all syscall catch requests, so we can readily determine 5095796c8dcSSimon Schubert if any catching is necessary. */ 5105796c8dcSSimon Schubert int total_syscalls_count; 511*cf7f2e2dSJohn Marino 512*cf7f2e2dSJohn Marino /* Per inferior data-pointers required by other GDB modules. */ 513*cf7f2e2dSJohn Marino void **data; 514*cf7f2e2dSJohn Marino unsigned num_data; 5155796c8dcSSimon Schubert }; 5165796c8dcSSimon Schubert 517*cf7f2e2dSJohn Marino /* Keep a registry of per-inferior data-pointers required by other GDB 518*cf7f2e2dSJohn Marino modules. */ 519*cf7f2e2dSJohn Marino 520*cf7f2e2dSJohn Marino extern const struct inferior_data *register_inferior_data (void); 521*cf7f2e2dSJohn Marino extern const struct inferior_data *register_inferior_data_with_cleanup 522*cf7f2e2dSJohn Marino (void (*cleanup) (struct inferior *, void *)); 523*cf7f2e2dSJohn Marino extern void clear_inferior_data (struct inferior *inf); 524*cf7f2e2dSJohn Marino extern void set_inferior_data (struct inferior *inf, 525*cf7f2e2dSJohn Marino const struct inferior_data *data, void *value); 526*cf7f2e2dSJohn Marino extern void *inferior_data (struct inferior *inf, 527*cf7f2e2dSJohn Marino const struct inferior_data *data); 528*cf7f2e2dSJohn Marino 5295796c8dcSSimon Schubert /* Create an empty inferior list, or empty the existing one. */ 5305796c8dcSSimon Schubert extern void init_inferior_list (void); 5315796c8dcSSimon Schubert 5325796c8dcSSimon Schubert /* Add an inferior to the inferior list, print a message that a new 5335796c8dcSSimon Schubert inferior is found, and return the pointer to the new inferior. 5345796c8dcSSimon Schubert Caller may use this pointer to initialize the private inferior 5355796c8dcSSimon Schubert data. */ 5365796c8dcSSimon Schubert extern struct inferior *add_inferior (int pid); 5375796c8dcSSimon Schubert 5385796c8dcSSimon Schubert /* Same as add_inferior, but don't print new inferior notifications to 5395796c8dcSSimon Schubert the CLI. */ 5405796c8dcSSimon Schubert extern struct inferior *add_inferior_silent (int pid); 5415796c8dcSSimon Schubert 5425796c8dcSSimon Schubert /* Delete an existing inferior list entry, due to inferior exit. */ 5435796c8dcSSimon Schubert extern void delete_inferior (int pid); 5445796c8dcSSimon Schubert 545*cf7f2e2dSJohn Marino extern void delete_inferior_1 (struct inferior *todel, int silent); 546*cf7f2e2dSJohn Marino 5475796c8dcSSimon Schubert /* Same as delete_inferior, but don't print new inferior notifications 5485796c8dcSSimon Schubert to the CLI. */ 5495796c8dcSSimon Schubert extern void delete_inferior_silent (int pid); 5505796c8dcSSimon Schubert 5515796c8dcSSimon Schubert /* Delete an existing inferior list entry, due to inferior detaching. */ 5525796c8dcSSimon Schubert extern void detach_inferior (int pid); 5535796c8dcSSimon Schubert 554*cf7f2e2dSJohn Marino extern void exit_inferior (int pid); 555*cf7f2e2dSJohn Marino 556*cf7f2e2dSJohn Marino extern void exit_inferior_silent (int pid); 557*cf7f2e2dSJohn Marino 558*cf7f2e2dSJohn Marino extern void exit_inferior_num_silent (int num); 559*cf7f2e2dSJohn Marino 560*cf7f2e2dSJohn Marino extern void inferior_appeared (struct inferior *inf, int pid); 561*cf7f2e2dSJohn Marino 5625796c8dcSSimon Schubert /* Get rid of all inferiors. */ 5635796c8dcSSimon Schubert extern void discard_all_inferiors (void); 5645796c8dcSSimon Schubert 5655796c8dcSSimon Schubert /* Translate the integer inferior id (GDB's homegrown id, not the system's) 5665796c8dcSSimon Schubert into a "pid" (which may be overloaded with extra inferior information). */ 5675796c8dcSSimon Schubert extern int gdb_inferior_id_to_pid (int); 5685796c8dcSSimon Schubert 5695796c8dcSSimon Schubert /* Translate a target 'pid' into the integer inferior id (GDB's 5705796c8dcSSimon Schubert homegrown id, not the system's). */ 5715796c8dcSSimon Schubert extern int pid_to_gdb_inferior_id (int pid); 5725796c8dcSSimon Schubert 5735796c8dcSSimon Schubert /* Boolean test for an already-known pid. */ 5745796c8dcSSimon Schubert extern int in_inferior_list (int pid); 5755796c8dcSSimon Schubert 5765796c8dcSSimon Schubert /* Boolean test for an already-known inferior id (GDB's homegrown id, 5775796c8dcSSimon Schubert not the system's). */ 5785796c8dcSSimon Schubert extern int valid_gdb_inferior_id (int num); 5795796c8dcSSimon Schubert 580*cf7f2e2dSJohn Marino /* Search function to lookup an inferior by target 'pid'. */ 5815796c8dcSSimon Schubert extern struct inferior *find_inferior_pid (int pid); 5825796c8dcSSimon Schubert 583*cf7f2e2dSJohn Marino /* Search function to lookup an inferior by GDB 'num'. */ 584*cf7f2e2dSJohn Marino extern struct inferior *find_inferior_id (int num); 585*cf7f2e2dSJohn Marino 586*cf7f2e2dSJohn Marino /* Find an inferior bound to PSPACE. */ 587*cf7f2e2dSJohn Marino extern struct inferior * 588*cf7f2e2dSJohn Marino find_inferior_for_program_space (struct program_space *pspace); 589*cf7f2e2dSJohn Marino 5905796c8dcSSimon Schubert /* Inferior iterator function. 5915796c8dcSSimon Schubert 5925796c8dcSSimon Schubert Calls a callback function once for each inferior, so long as the 5935796c8dcSSimon Schubert callback function returns false. If the callback function returns 5945796c8dcSSimon Schubert true, the iteration will end and the current inferior will be 5955796c8dcSSimon Schubert returned. This can be useful for implementing a search for a 5965796c8dcSSimon Schubert inferior with arbitrary attributes, or for applying some operation 5975796c8dcSSimon Schubert to every inferior. 5985796c8dcSSimon Schubert 5995796c8dcSSimon Schubert It is safe to delete the iterated inferior from the callback. */ 6005796c8dcSSimon Schubert extern struct inferior *iterate_over_inferiors (int (*) (struct inferior *, 6015796c8dcSSimon Schubert void *), 6025796c8dcSSimon Schubert void *); 6035796c8dcSSimon Schubert 6045796c8dcSSimon Schubert /* Prints the list of inferiors and their details on UIOUT. 6055796c8dcSSimon Schubert 6065796c8dcSSimon Schubert If REQUESTED_INFERIOR is not -1, it's the GDB id of the inferior 6075796c8dcSSimon Schubert that should be printed. Otherwise, all inferiors are printed. */ 6085796c8dcSSimon Schubert extern void print_inferior (struct ui_out *uiout, int requested_inferior); 6095796c8dcSSimon Schubert 6105796c8dcSSimon Schubert /* Returns true if the inferior list is not empty. */ 6115796c8dcSSimon Schubert extern int have_inferiors (void); 6125796c8dcSSimon Schubert 6135796c8dcSSimon Schubert /* Returns true if there are any live inferiors in the inferior list 6145796c8dcSSimon Schubert (not cores, not executables, real live processes). */ 6155796c8dcSSimon Schubert extern int have_live_inferiors (void); 6165796c8dcSSimon Schubert 6175796c8dcSSimon Schubert /* Return a pointer to the current inferior. It is an error to call 6185796c8dcSSimon Schubert this if there is no current inferior. */ 6195796c8dcSSimon Schubert extern struct inferior *current_inferior (void); 6205796c8dcSSimon Schubert 621*cf7f2e2dSJohn Marino extern void set_current_inferior (struct inferior *); 622*cf7f2e2dSJohn Marino 623*cf7f2e2dSJohn Marino extern struct cleanup *save_current_inferior (void); 624*cf7f2e2dSJohn Marino 625*cf7f2e2dSJohn Marino extern struct inferior *inferior_list; 626*cf7f2e2dSJohn Marino 627*cf7f2e2dSJohn Marino /* Prune away automatically added inferiors that aren't required 628*cf7f2e2dSJohn Marino anymore. */ 629*cf7f2e2dSJohn Marino extern void prune_inferiors (void); 630*cf7f2e2dSJohn Marino 631*cf7f2e2dSJohn Marino extern int number_of_inferiors (void); 632*cf7f2e2dSJohn Marino 633*cf7f2e2dSJohn Marino extern struct inferior *add_inferior_with_spaces (void); 634*cf7f2e2dSJohn Marino 635*cf7f2e2dSJohn Marino extern void update_observer_mode (void); 636*cf7f2e2dSJohn Marino 6375796c8dcSSimon Schubert #endif /* !defined (INFERIOR_H) */ 638