| 1 | /* Inferior process information for the remote server for GDB. |
| 2 | Copyright (C) 1993-2016 Free Software Foundation, Inc. |
| 3 | |
| 4 | This file is part of GDB. |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 3 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | #ifndef INFERIORS_H |
| 20 | #define INFERIORS_H |
| 21 | |
| 22 | #include "gdb_vecs.h" |
| 23 | |
| 24 | /* Generic information for tracking a list of ``inferiors'' - threads, |
| 25 | processes, etc. */ |
| 26 | struct inferior_list |
| 27 | { |
| 28 | struct inferior_list_entry *head; |
| 29 | struct inferior_list_entry *tail; |
| 30 | }; |
| 31 | struct inferior_list_entry |
| 32 | { |
| 33 | ptid_t id; |
| 34 | struct inferior_list_entry *next; |
| 35 | }; |
| 36 | |
| 37 | struct thread_info; |
| 38 | struct regcache; |
| 39 | struct target_desc; |
| 40 | struct sym_cache; |
| 41 | struct breakpoint; |
| 42 | struct raw_breakpoint; |
| 43 | struct fast_tracepoint_jump; |
| 44 | struct process_info_private; |
| 45 | |
| 46 | struct process_info |
| 47 | { |
| 48 | /* This must appear first. |
| 49 | The list iterator functions assume it. */ |
| 50 | struct inferior_list_entry entry; |
| 51 | |
| 52 | /* Nonzero if this child process was attached rather than |
| 53 | spawned. */ |
| 54 | int attached; |
| 55 | |
| 56 | /* True if GDB asked us to detach from this process, but we remained |
| 57 | attached anyway. */ |
| 58 | int gdb_detached; |
| 59 | |
| 60 | /* The symbol cache. */ |
| 61 | struct sym_cache *symbol_cache; |
| 62 | |
| 63 | /* The list of memory breakpoints. */ |
| 64 | struct breakpoint *breakpoints; |
| 65 | |
| 66 | /* The list of raw memory breakpoints. */ |
| 67 | struct raw_breakpoint *raw_breakpoints; |
| 68 | |
| 69 | /* The list of installed fast tracepoints. */ |
| 70 | struct fast_tracepoint_jump *fast_tracepoint_jumps; |
| 71 | |
| 72 | /* The list of syscalls to report, or just a single element, ANY_SYSCALL, |
| 73 | for unfiltered syscall reporting. */ |
| 74 | VEC (int) *syscalls_to_catch; |
| 75 | |
| 76 | const struct target_desc *tdesc; |
| 77 | |
| 78 | /* Private target data. */ |
| 79 | struct process_info_private *priv; |
| 80 | }; |
| 81 | |
| 82 | #define ptid_of(inf) ((inf)->entry.id) |
| 83 | #define pid_of(inf) ptid_get_pid ((inf)->entry.id) |
| 84 | #define lwpid_of(inf) ptid_get_lwp ((inf)->entry.id) |
| 85 | |
| 86 | /* Return a pointer to the process that corresponds to the current |
| 87 | thread (current_thread). It is an error to call this if there is |
| 88 | no current thread selected. */ |
| 89 | |
| 90 | struct process_info *current_process (void); |
| 91 | struct process_info *get_thread_process (struct thread_info *); |
| 92 | |
| 93 | extern struct inferior_list all_processes; |
| 94 | |
| 95 | void add_inferior_to_list (struct inferior_list *list, |
| 96 | struct inferior_list_entry *new_inferior); |
| 97 | void for_each_inferior (struct inferior_list *list, |
| 98 | void (*action) (struct inferior_list_entry *)); |
| 99 | |
| 100 | void for_each_inferior_with_data |
| 101 | (struct inferior_list *list, |
| 102 | void (*action) (struct inferior_list_entry *, void *), |
| 103 | void *data); |
| 104 | |
| 105 | void clear_inferior_list (struct inferior_list *list); |
| 106 | |
| 107 | int one_inferior_p (struct inferior_list *list); |
| 108 | |
| 109 | /* Helper for ALL_INFERIORS_TYPE. Gets the next element starting at |
| 110 | CUR, if CUR is not NULL. */ |
| 111 | #define A_I_NEXT(type, list, cur) \ |
| 112 | ((cur) != NULL \ |
| 113 | ? (type *) ((struct inferior_list_entry *) cur)->next \ |
| 114 | : NULL) |
| 115 | |
| 116 | /* Iterate over all inferiors of type TYPE in LIST, open loop |
| 117 | style. */ |
| 118 | #define ALL_INFERIORS_TYPE(type, list, cur, tmp) \ |
| 119 | for ((cur) = (type *) (list)->head, (tmp) = A_I_NEXT (type, list, cur); \ |
| 120 | (cur) != NULL; \ |
| 121 | (cur) = (tmp), (tmp) = A_I_NEXT (type, list, cur)) |
| 122 | |
| 123 | /* Iterate over all inferiors in LIST, open loop style. */ |
| 124 | #define ALL_INFERIORS(list, cur, tmp) \ |
| 125 | ALL_INFERIORS_TYPE (struct inferior_list_entry, list, cur, tmp) |
| 126 | |
| 127 | /* Iterate over all processes, open loop style. */ |
| 128 | #define ALL_PROCESSES(cur, tmp) \ |
| 129 | ALL_INFERIORS_TYPE (struct process_info, &all_processes, cur, tmp) |
| 130 | |
| 131 | extern struct thread_info *current_thread; |
| 132 | void remove_inferior (struct inferior_list *list, |
| 133 | struct inferior_list_entry *entry); |
| 134 | |
| 135 | struct inferior_list_entry *get_first_inferior (struct inferior_list *list); |
| 136 | |
| 137 | /* Return the first process in the processes list. */ |
| 138 | struct process_info *get_first_process (void); |
| 139 | |
| 140 | struct process_info *add_process (int pid, int attached); |
| 141 | void remove_process (struct process_info *process); |
| 142 | struct process_info *find_process_pid (int pid); |
| 143 | int have_started_inferiors_p (void); |
| 144 | int have_attached_inferiors_p (void); |
| 145 | |
| 146 | ptid_t thread_to_gdb_id (struct thread_info *); |
| 147 | ptid_t gdb_id_to_thread_id (ptid_t); |
| 148 | |
| 149 | void clear_inferiors (void); |
| 150 | struct inferior_list_entry *find_inferior |
| 151 | (struct inferior_list *, |
| 152 | int (*func) (struct inferior_list_entry *, |
| 153 | void *), |
| 154 | void *arg); |
| 155 | struct inferior_list_entry *find_inferior_id (struct inferior_list *list, |
| 156 | ptid_t id); |
| 157 | |
| 158 | void *inferior_target_data (struct thread_info *); |
| 159 | void set_inferior_target_data (struct thread_info *, void *); |
| 160 | struct regcache *inferior_regcache_data (struct thread_info *); |
| 161 | void set_inferior_regcache_data (struct thread_info *, struct regcache *); |
| 162 | |
| 163 | #endif /* INFERIORS_H */ |