1 /* Variables that describe the inferior process running under GDB:
2 Where it is, why it stopped, and how to step it.
4 Copyright (C) 1986-2014 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #if !defined (INFERIOR_H)
24 struct target_waitstatus
;
32 struct target_desc_info
;
37 #include "breakpoint.h"
39 /* For enum gdb_signal. */
42 /* For struct frame_id. */
45 #include "progspace.h"
48 struct infcall_suspend_state
;
49 struct infcall_control_state
;
51 extern struct infcall_suspend_state
*save_infcall_suspend_state (void);
52 extern struct infcall_control_state
*save_infcall_control_state (void);
54 extern void restore_infcall_suspend_state (struct infcall_suspend_state
*);
55 extern void restore_infcall_control_state (struct infcall_control_state
*);
57 extern struct cleanup
*make_cleanup_restore_infcall_suspend_state
58 (struct infcall_suspend_state
*);
59 extern struct cleanup
*make_cleanup_restore_infcall_control_state
60 (struct infcall_control_state
*);
62 extern void discard_infcall_suspend_state (struct infcall_suspend_state
*);
63 extern void discard_infcall_control_state (struct infcall_control_state
*);
65 extern struct regcache
*
66 get_infcall_suspend_state_regcache (struct infcall_suspend_state
*);
68 /* Save value of inferior_ptid so that it may be restored by
69 a later call to do_cleanups(). Returns the struct cleanup
70 pointer needed for later doing the cleanup. */
71 extern struct cleanup
* save_inferior_ptid (void);
73 extern void set_sigint_trap (void);
75 extern void clear_sigint_trap (void);
77 /* Set/get file name for default use for standard in/out in the inferior. */
79 extern void set_inferior_io_terminal (const char *terminal_name
);
80 extern const char *get_inferior_io_terminal (void);
82 /* Collected pid, tid, etc. of the debugged inferior. When there's
83 no inferior, ptid_get_pid (inferior_ptid) will be 0. */
85 extern ptid_t inferior_ptid
;
87 /* Are we simulating synchronous execution? This is used in async gdb
88 to implement the 'run', 'continue' etc commands, which will not
89 redisplay the prompt until the execution is actually over. */
90 extern int sync_execution
;
92 /* Inferior environment. */
94 extern void clear_proceed_status (void);
96 extern void proceed (CORE_ADDR
, enum gdb_signal
, int);
98 extern int sched_multi
;
100 /* When set, stop the 'step' command if we enter a function which has
101 no line number information. The normal behavior is that we step
102 over such function. */
103 extern int step_stop_if_no_debug
;
105 /* If set, the inferior should be controlled in non-stop mode. In
106 this mode, each thread is controlled independently. Execution
107 commands apply only to the selected thread by default, and stop
108 events stop only the thread that had the event -- the other threads
109 are kept running freely. */
112 /* When set (default), the target should attempt to disable the operating
113 system's address space randomization feature when starting an inferior. */
114 extern int disable_randomization
;
116 extern void generic_mourn_inferior (void);
118 extern void terminal_save_ours (struct target_ops
*self
);
120 extern void terminal_ours (struct target_ops
*self
);
122 extern CORE_ADDR
unsigned_pointer_to_address (struct gdbarch
*gdbarch
,
124 const gdb_byte
*buf
);
125 extern void unsigned_address_to_pointer (struct gdbarch
*gdbarch
,
126 struct type
*type
, gdb_byte
*buf
,
128 extern CORE_ADDR
signed_pointer_to_address (struct gdbarch
*gdbarch
,
130 const gdb_byte
*buf
);
131 extern void address_to_signed_pointer (struct gdbarch
*gdbarch
,
132 struct type
*type
, gdb_byte
*buf
,
135 extern void wait_for_inferior (void);
137 extern void prepare_for_detach (void);
139 extern void fetch_inferior_event (void *);
141 extern void init_wait_for_inferior (void);
143 extern void reopen_exec_file (void);
145 /* The `resume' routine should only be called in special circumstances.
146 Normally, use `proceed', which handles a lot of bookkeeping. */
148 extern void resume (int, enum gdb_signal
);
150 extern ptid_t
user_visible_resume_ptid (int step
);
152 extern void insert_step_resume_breakpoint_at_sal (struct gdbarch
*,
153 struct symtab_and_line
,
156 /* From misc files */
158 extern void default_print_registers_info (struct gdbarch
*gdbarch
,
159 struct ui_file
*file
,
160 struct frame_info
*frame
,
161 int regnum
, int all
);
163 extern void child_terminal_info (struct target_ops
*self
, const char *, int);
165 extern void term_info (char *, int);
167 extern void terminal_ours_for_output (struct target_ops
*self
);
169 extern void terminal_inferior (struct target_ops
*self
);
171 extern void terminal_init_inferior (struct target_ops
*self
);
173 extern void terminal_init_inferior_with_pgrp (int pgrp
);
175 /* From fork-child.c */
177 extern int fork_inferior (char *, char *, char **,
179 void (*)(int), void (*)(void), char *,
180 void (*)(const char *,
181 char * const *, char * const *));
184 extern void startup_inferior (int);
186 extern char *construct_inferior_arguments (int, char **);
190 extern unsigned int debug_infrun
;
192 extern int stop_on_solib_events
;
194 extern void start_remote (int from_tty
);
196 extern void normal_stop (void);
198 extern int signal_stop_state (int);
200 extern int signal_print_state (int);
202 extern int signal_pass_state (int);
204 extern int signal_stop_update (int, int);
206 extern int signal_print_update (int, int);
208 extern int signal_pass_update (int, int);
210 extern void get_last_target_status(ptid_t
*ptid
,
211 struct target_waitstatus
*status
);
213 extern void follow_inferior_reset_breakpoints (void);
215 void set_step_info (struct frame_info
*frame
, struct symtab_and_line sal
);
217 /* Clear the convenience variables associated with the exit of the
218 inferior. Currently, those variables are $_exitcode and
221 extern void clear_exit_convenience_vars (void);
225 extern void post_create_inferior (struct target_ops
*, int);
227 extern void attach_command (char *, int);
229 extern char *get_inferior_args (void);
231 extern void set_inferior_args (char *);
233 extern void set_inferior_args_vector (int, char **);
235 extern void registers_info (char *, int);
237 extern void continue_1 (int all_threads
);
239 extern void interrupt_target_1 (int all_threads
);
241 extern void delete_longjmp_breakpoint_cleanup (void *arg
);
243 extern void detach_command (char *, int);
245 extern void notice_new_inferior (ptid_t
, int, int);
247 extern struct value
*get_return_value (struct value
*function
,
248 struct type
*value_type
);
250 /* Whether to start up the debuggee under a shell.
252 If startup-with-shell is set, GDB's "run" will attempt to start up
253 the debuggee under a shell.
255 This is in order for argument-expansion to occur. E.g.,
259 The "*" gets expanded by the shell into a list of files.
261 While this is a nice feature, it may be handy to bypass the shell
262 in some cases. To disable this feature, do "set startup-with-shell
265 The catch-exec traps expected during start-up will be one more if
266 the target is started up with a shell. */
267 extern int startup_with_shell
;
269 /* Address at which inferior stopped. */
271 extern CORE_ADDR stop_pc
;
273 /* Nonzero if stopped due to completion of a stack dummy routine. */
275 extern enum stop_stack_kind stop_stack_dummy
;
277 /* Nonzero if program stopped due to a random (unexpected) signal in
280 extern int stopped_by_random_signal
;
282 /* STEP_OVER_ALL means step over all subroutine calls.
283 STEP_OVER_UNDEBUGGABLE means step over calls to undebuggable functions.
284 STEP_OVER_NONE means don't step over any subroutine calls. */
286 enum step_over_calls_kind
290 STEP_OVER_UNDEBUGGABLE
293 /* Anything but NO_STOP_QUIETLY means we expect a trap and the caller
294 will handle it themselves. STOP_QUIETLY is used when running in
295 the shell before the child program has been exec'd and when running
296 through shared library loading. STOP_QUIETLY_REMOTE is used when
297 setting up a remote connection; it is like STOP_QUIETLY_NO_SIGSTOP
298 except that there is no need to hide a signal. */
300 /* It is also used after attach, due to attaching to a process. This
301 is a bit trickier. When doing an attach, the kernel stops the
302 debuggee with a SIGSTOP. On newer GNU/Linux kernels (>= 2.5.61)
303 the handling of SIGSTOP for a ptraced process has changed. Earlier
304 versions of the kernel would ignore these SIGSTOPs, while now
305 SIGSTOP is treated like any other signal, i.e. it is not muffled.
307 If the gdb user does a 'continue' after the 'attach', gdb passes
308 the global variable stop_signal (which stores the signal from the
309 attach, SIGSTOP) to the ptrace(PTRACE_CONT,...) call. This is
310 problematic, because the kernel doesn't ignore such SIGSTOP
311 now. I.e. it is reported back to gdb, which in turn presents it
314 To avoid the problem, we use STOP_QUIETLY_NO_SIGSTOP, which allows
315 gdb to clear the value of stop_signal after the attach, so that it
316 is not passed back down to the kernel. */
323 STOP_QUIETLY_NO_SIGSTOP
326 /* Reverse execution. */
327 enum exec_direction_kind
333 /* The current execution direction. This should only be set to enum
334 exec_direction_kind values. It is only an int to make it
335 compatible with make_cleanup_restore_integer. */
336 extern int execution_direction
;
338 /* Save register contents here when executing a "finish" command or are
339 about to pop a stack dummy frame, if-and-only-if proceed_to_finish is set.
340 Thus this contains the return value from the called function (assuming
341 values are returned in a register). */
343 extern struct regcache
*stop_registers
;
345 /* True if we are debugging displaced stepping. */
346 extern int debug_displaced
;
348 /* Dump LEN bytes at BUF in hex to FILE, followed by a newline. */
349 void displaced_step_dump_bytes (struct ui_file
*file
,
350 const gdb_byte
*buf
, size_t len
);
352 struct displaced_step_closure
*get_displaced_step_closure_by_addr (CORE_ADDR addr
);
354 /* Possible values for gdbarch_call_dummy_location. */
356 #define AT_ENTRY_POINT 4
358 /* Number of traps that happen between exec'ing the shell to run an
359 inferior and when we finally get to the inferior code, not counting
360 the exec for the shell. This is 1 on most implementations.
361 Overridden in nm.h files. */
362 #if !defined(START_INFERIOR_TRAPS_EXPECTED)
363 #define START_INFERIOR_TRAPS_EXPECTED 1
366 struct private_inferior
;
368 /* Inferior process specific part of `struct infcall_control_state'.
370 Inferior thread counterpart is `struct thread_control_state'. */
372 struct inferior_control_state
374 /* See the definition of stop_kind above. */
375 enum stop_kind stop_soon
;
378 /* Inferior process specific part of `struct infcall_suspend_state'.
380 Inferior thread counterpart is `struct thread_suspend_state'. */
382 #if 0 /* Currently unused and empty structures are not valid C. */
383 struct inferior_suspend_state
388 /* GDB represents the state of each program execution with an object
389 called an inferior. An inferior typically corresponds to a process
390 but is more general and applies also to targets that do not have a
391 notion of processes. Each run of an executable creates a new
392 inferior, as does each attachment to an existing process.
393 Inferiors have unique internal identifiers that are different from
394 target process ids. Each inferior may in turn have multiple
395 threads running in it. */
399 /* Pointer to next inferior in singly-linked list of inferiors. */
400 struct inferior
*next
;
402 /* Convenient handle (GDB inferior id). Unique across all
406 /* Actual target inferior id, usually, a process id. This matches
407 the ptid_t.pid member of threads of this inferior. */
409 /* True if the PID was actually faked by GDB. */
412 /* State of GDB control of inferior process execution.
413 See `struct inferior_control_state'. */
414 struct inferior_control_state control
;
416 /* State of inferior process to restore after GDB is done with an inferior
417 call. See `struct inferior_suspend_state'. */
418 #if 0 /* Currently unused and empty structures are not valid C. */
419 struct inferior_suspend_state suspend
;
422 /* True if this was an auto-created inferior, e.g. created from
423 following a fork; false, if this inferior was manually added by
424 the user, and we should not attempt to prune it
428 /* The address space bound to this inferior. */
429 struct address_space
*aspace
;
431 /* The program space bound to this inferior. */
432 struct program_space
*pspace
;
434 /* The arguments string to use when running. */
437 /* The size of elements in argv. */
440 /* The vector version of arguments. If ARGC is nonzero,
441 then we must compute ARGS from this (via the target).
442 This is always coming from main's argv and therefore
443 should never be freed. */
446 /* The name of terminal device to use for I/O. */
449 /* Environment to use for running inferior,
450 in format described in environ.h. */
451 struct gdb_environ
*environment
;
453 /* Nonzero if this child process was attached rather than
457 /* If this inferior is a vfork child, then this is the pointer to
458 its vfork parent, if GDB is still attached to it. */
459 struct inferior
*vfork_parent
;
461 /* If this process is a vfork parent, this is the pointer to the
462 child. Since a vfork parent is left frozen by the kernel until
463 the child execs or exits, a process can only have one vfork child
465 struct inferior
*vfork_child
;
467 /* True if this inferior should be detached when it's vfork sibling
471 /* True if this inferior is a vfork parent waiting for a vfork child
472 not under our control to be done with the shared memory region,
473 either by exiting or execing. */
474 int waiting_for_vfork_done
;
476 /* True if we're in the process of detaching from this inferior. */
479 /* What is left to do for an execution command after any thread of
480 this inferior stops. For continuations associated with a
481 specific thread, see `struct thread_info'. */
482 struct continuation
*continuations
;
484 /* Private data used by the target vector implementation. */
485 struct private_inferior
*private;
487 /* HAS_EXIT_CODE is true if the inferior exited with an exit code.
488 In this case, the EXIT_CODE field is also valid. */
492 /* Default flags to pass to the symbol reading functions. These are
493 used whenever a new objfile is created. The valid values come
494 from enum symfile_add_flags. */
497 /* Info about an inferior's target description (if it's fetched; the
498 user supplied description's filename, if any; etc.). */
499 struct target_desc_info
*tdesc_info
;
501 /* The architecture associated with the inferior through the
502 connection to the target.
504 The architecture vector provides some information that is really
505 a property of the inferior, accessed through a particular target:
506 ptrace operations; the layout of certain RSP packets; the
507 solib_ops vector; etc. To differentiate architecture accesses to
508 per-inferior/target properties from
509 per-thread/per-frame/per-objfile properties, accesses to
510 per-inferior/target properties should be made through
512 struct gdbarch
*gdbarch
;
514 /* Per inferior data-pointers required by other GDB modules. */
518 /* Keep a registry of per-inferior data-pointers required by other GDB
521 DECLARE_REGISTRY (inferior
);
523 /* Create an empty inferior list, or empty the existing one. */
524 extern void init_inferior_list (void);
526 /* Add an inferior to the inferior list, print a message that a new
527 inferior is found, and return the pointer to the new inferior.
528 Caller may use this pointer to initialize the private inferior
530 extern struct inferior
*add_inferior (int pid
);
532 /* Same as add_inferior, but don't print new inferior notifications to
534 extern struct inferior
*add_inferior_silent (int pid
);
536 /* Delete an existing inferior list entry, due to inferior exit. */
537 extern void delete_inferior (int pid
);
539 extern void delete_inferior_1 (struct inferior
*todel
, int silent
);
541 /* Same as delete_inferior, but don't print new inferior notifications
543 extern void delete_inferior_silent (int pid
);
545 /* Delete an existing inferior list entry, due to inferior detaching. */
546 extern void detach_inferior (int pid
);
548 extern void exit_inferior (int pid
);
550 extern void exit_inferior_silent (int pid
);
552 extern void exit_inferior_num_silent (int num
);
554 extern void inferior_appeared (struct inferior
*inf
, int pid
);
556 /* Get rid of all inferiors. */
557 extern void discard_all_inferiors (void);
559 /* Translate the integer inferior id (GDB's homegrown id, not the system's)
560 into a "pid" (which may be overloaded with extra inferior information). */
561 extern int gdb_inferior_id_to_pid (int);
563 /* Translate a target 'pid' into the integer inferior id (GDB's
564 homegrown id, not the system's). */
565 extern int pid_to_gdb_inferior_id (int pid
);
567 /* Boolean test for an already-known pid. */
568 extern int in_inferior_list (int pid
);
570 /* Boolean test for an already-known inferior id (GDB's homegrown id,
571 not the system's). */
572 extern int valid_gdb_inferior_id (int num
);
574 /* Search function to lookup an inferior by target 'pid'. */
575 extern struct inferior
*find_inferior_pid (int pid
);
577 /* Search function to lookup an inferior by GDB 'num'. */
578 extern struct inferior
*find_inferior_id (int num
);
580 /* Find an inferior bound to PSPACE. */
581 extern struct inferior
*
582 find_inferior_for_program_space (struct program_space
*pspace
);
584 /* Inferior iterator function.
586 Calls a callback function once for each inferior, so long as the
587 callback function returns false. If the callback function returns
588 true, the iteration will end and the current inferior will be
589 returned. This can be useful for implementing a search for a
590 inferior with arbitrary attributes, or for applying some operation
593 It is safe to delete the iterated inferior from the callback. */
594 extern struct inferior
*iterate_over_inferiors (int (*) (struct inferior
*,
598 /* Returns true if the inferior list is not empty. */
599 extern int have_inferiors (void);
601 /* Returns true if there are any live inferiors in the inferior list
602 (not cores, not executables, real live processes). */
603 extern int have_live_inferiors (void);
605 /* Return a pointer to the current inferior. It is an error to call
606 this if there is no current inferior. */
607 extern struct inferior
*current_inferior (void);
609 extern void set_current_inferior (struct inferior
*);
611 extern struct cleanup
*save_current_inferior (void);
613 /* Traverse all inferiors. */
615 #define ALL_INFERIORS(I) \
616 for ((I) = inferior_list; (I); (I) = (I)->next)
618 extern struct inferior
*inferior_list
;
620 /* Prune away automatically added inferiors that aren't required
622 extern void prune_inferiors (void);
624 extern int number_of_inferiors (void);
626 extern struct inferior
*add_inferior_with_spaces (void);
628 extern void update_observer_mode (void);
630 extern void update_signals_program_target (void);
632 extern void signal_catch_update (const unsigned int *);
634 /* In some circumstances we allow a command to specify a numeric
635 signal. The idea is to keep these circumstances limited so that
636 users (and scripts) develop portable habits. For comparison,
637 POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
638 numeric signal at all is obsolescent. We are slightly more lenient
639 and allow 1-15 which should match host signal numbers on most
640 systems. Use of symbolic signal names is strongly encouraged. */
642 enum gdb_signal
gdb_signal_from_command (int num
);
644 #endif /* !defined (INFERIOR_H) */