X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Finferior.h;h=2d1bb97a283474bbb5c591dbb991f3510fa00595;hb=0747795c085d3b2a35da6bb474f32c58ce1b70c8;hp=bfad91d9f3e0d76fe9474fdfbae8b97636078133;hpb=75cbc781e371279f4403045be93b07fd8fe7fde5;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/inferior.h b/gdb/inferior.h index bfad91d9f3..2d1bb97a28 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -1,7 +1,7 @@ /* Variables that describe the inferior process running under GDB: Where it is, why it stopped, and how to step it. - Copyright (C) 1986-2018 Free Software Foundation, Inc. + Copyright (C) 1986-2019 Free Software Foundation, Inc. This file is part of GDB. @@ -44,29 +44,55 @@ struct thread_info; #include "frame.h" /* For gdb_environ. */ -#include "environ.h" +#include "common/environ.h" #include "progspace.h" #include "registry.h" #include "symfile-add-flags.h" #include "common/refcounted-object.h" +#include "common/forward-scope-exit.h" -#include "common-inferior.h" +#include "common/common-inferior.h" +#include "gdbthread.h" struct infcall_suspend_state; struct infcall_control_state; -extern struct infcall_suspend_state *save_infcall_suspend_state (void); -extern struct infcall_control_state *save_infcall_control_state (void); - extern void restore_infcall_suspend_state (struct infcall_suspend_state *); extern void restore_infcall_control_state (struct infcall_control_state *); -extern struct cleanup *make_cleanup_restore_infcall_suspend_state - (struct infcall_suspend_state *); -extern struct cleanup *make_cleanup_restore_infcall_control_state - (struct infcall_control_state *); +/* A deleter for infcall_suspend_state that calls + restore_infcall_suspend_state. */ +struct infcall_suspend_state_deleter +{ + void operator() (struct infcall_suspend_state *state) const + { + restore_infcall_suspend_state (state); + } +}; + +/* A unique_ptr specialization for infcall_suspend_state. */ +typedef std::unique_ptr + infcall_suspend_state_up; + +extern infcall_suspend_state_up save_infcall_suspend_state (); + +/* A deleter for infcall_control_state that calls + restore_infcall_control_state. */ +struct infcall_control_state_deleter +{ + void operator() (struct infcall_control_state *state) const + { + restore_infcall_control_state (state); + } +}; + +/* A unique_ptr specialization for infcall_control_state. */ +typedef std::unique_ptr + infcall_control_state_up; + +extern infcall_control_state_up save_infcall_control_state (); extern void discard_infcall_suspend_state (struct infcall_suspend_state *); extern void discard_infcall_control_state (struct infcall_control_state *); @@ -84,7 +110,7 @@ extern void set_inferior_io_terminal (const char *terminal_name); extern const char *get_inferior_io_terminal (void); /* Collected pid, tid, etc. of the debugged inferior. When there's - no inferior, ptid_get_pid (inferior_ptid) will be 0. */ + no inferior, inferior_ptid.pid () will be 0. */ extern ptid_t inferior_ptid; @@ -161,7 +187,7 @@ extern void post_create_inferior (struct target_ops *, int); extern void attach_command (const char *, int); -extern char *get_inferior_args (void); +extern const char *get_inferior_args (void); extern void set_inferior_args (const char *); @@ -173,7 +199,8 @@ extern void continue_1 (int all_threads); extern void interrupt_target_1 (int all_threads); -extern void delete_longjmp_breakpoint_cleanup (void *arg); +using delete_longjmp_breakpoint_cleanup + = FORWARD_SCOPE_EXIT (delete_longjmp_breakpoint); extern void detach_command (const char *, int); @@ -208,10 +235,6 @@ extern void prepare_execution_command (struct target_ops *target, the target is started up with a shell. */ extern int startup_with_shell; -/* Address at which inferior stopped. */ - -extern CORE_ADDR stop_pc; - /* Nonzero if stopped due to completion of a stack dummy routine. */ extern enum stop_stack_kind stop_stack_dummy; @@ -225,17 +248,6 @@ extern int stopped_by_random_signal; `set print inferior-events'. */ extern int print_inferior_events; -/* STEP_OVER_ALL means step over all subroutine calls. - STEP_OVER_UNDEBUGGABLE means step over calls to undebuggable functions. - STEP_OVER_NONE means don't step over any subroutine calls. */ - -enum step_over_calls_kind - { - STEP_OVER_NONE, - STEP_OVER_ALL, - STEP_OVER_UNDEBUGGABLE - }; - /* Anything but NO_STOP_QUIETLY means we expect a trap and the caller will handle it themselves. STOP_QUIETLY is used when running in the shell before the child program has been exec'd and when running @@ -287,6 +299,16 @@ struct private_inferior struct inferior_control_state { + inferior_control_state () + : stop_soon (NO_STOP_QUIETLY) + { + } + + explicit inferior_control_state (enum stop_kind when) + : stop_soon (when) + { + } + /* See the definition of stop_kind above. */ enum stop_kind stop_soon; }; @@ -330,6 +352,38 @@ public: /* Pointer to next inferior in singly-linked list of inferiors. */ struct inferior *next = NULL; + /* This inferior's thread list. */ + thread_info *thread_list = nullptr; + + /* Returns a range adapter covering the inferior's threads, + including exited threads. Used like this: + + for (thread_info *thr : inf->threads ()) + { .... } + */ + inf_threads_range threads () + { return inf_threads_range (this->thread_list); } + + /* Returns a range adapter covering the inferior's non-exited + threads. Used like this: + + for (thread_info *thr : inf->non_exited_threads ()) + { .... } + */ + inf_non_exited_threads_range non_exited_threads () + { return inf_non_exited_threads_range (this->thread_list); } + + /* Like inferior::threads(), but returns a range adapter that can be + used with range-for, safely. I.e., it is safe to delete the + currently-iterated thread, like this: + + for (thread_info *t : inf->threads_safe ()) + if (some_condition ()) + delete f; + */ + inline safe_inf_threads_range threads_safe () + { return safe_inf_threads_range (this->thread_list); } + /* Convenient handle (GDB inferior id). Unique across all inferiors. */ int num = 0; @@ -345,7 +399,7 @@ public: /* State of GDB control of inferior process execution. See `struct inferior_control_state'. */ - inferior_control_state control {NO_STOP_QUIETLY}; + inferior_control_state control; /* True if this was an auto-created inferior, e.g. created from following a fork; false, if this inferior was manually added by @@ -451,6 +505,9 @@ public: this gdbarch. */ struct gdbarch *gdbarch = NULL; + /* Data related to displaced stepping. */ + displaced_step_inferior_state displaced_step_state; + /* Per inferior data-pointers required by other GDB modules. */ REGISTRY_FIELDS; }; @@ -545,16 +602,49 @@ private: /* Traverse all inferiors. */ -#define ALL_INFERIORS(I) \ - for ((I) = inferior_list; (I); (I) = (I)->next) +extern struct inferior *inferior_list; + +/* Pull in the internals of the inferiors ranges and iterators. Must + be done after struct inferior is defined. */ +#include "inferior-iter.h" -/* Traverse all non-exited inferiors. */ +/* Return a range that can be used to walk over all inferiors + inferiors, with range-for, safely. I.e., it is safe to delete the + currently-iterated inferior. When combined with range-for, this + allow convenient patterns like this: -#define ALL_NON_EXITED_INFERIORS(I) \ - ALL_INFERIORS (I) \ - if ((I)->pid != 0) + for (inferior *inf : all_inferiors_safe ()) + if (some_condition ()) + delete inf; +*/ -extern struct inferior *inferior_list; +inline all_inferiors_safe_range +all_inferiors_safe () +{ + return {}; +} + +/* Returns a range representing all inferiors, suitable to use with + range-for, like this: + + for (inferior *inf : all_inferiors ()) + [...] +*/ + +inline all_inferiors_range +all_inferiors () +{ + return {}; +} + +/* Return a range that can be used to walk over all inferiors with PID + not zero, with range-for. */ + +inline all_non_exited_inferiors_range +all_non_exited_inferiors () +{ + return {}; +} /* Prune away automatically added inferiors that aren't required anymore. */