Make open_fds an std::vector
[deliverable/binutils-gdb.git] / gdb / gdbserver / inferiors.h
1 /* Inferior process information for the remote server for GDB.
2 Copyright (C) 1993-2017 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 #include <list>
24
25 struct thread_info;
26 struct regcache;
27 struct target_desc;
28 struct sym_cache;
29 struct breakpoint;
30 struct raw_breakpoint;
31 struct fast_tracepoint_jump;
32 struct process_info_private;
33
34 struct process_info
35 {
36 /* This process' pid. */
37 int pid;
38
39 /* Nonzero if this child process was attached rather than
40 spawned. */
41 int attached;
42
43 /* True if GDB asked us to detach from this process, but we remained
44 attached anyway. */
45 int gdb_detached;
46
47 /* The symbol cache. */
48 struct sym_cache *symbol_cache;
49
50 /* The list of memory breakpoints. */
51 struct breakpoint *breakpoints;
52
53 /* The list of raw memory breakpoints. */
54 struct raw_breakpoint *raw_breakpoints;
55
56 /* The list of installed fast tracepoints. */
57 struct fast_tracepoint_jump *fast_tracepoint_jumps;
58
59 /* The list of syscalls to report, or just a single element, ANY_SYSCALL,
60 for unfiltered syscall reporting. */
61 VEC (int) *syscalls_to_catch;
62
63 const struct target_desc *tdesc;
64
65 /* Private target data. */
66 struct process_info_private *priv;
67 };
68
69 /* Get the pid of PROC. */
70
71 static inline int
72 pid_of (const process_info *proc)
73 {
74 return proc->pid;
75 }
76
77 /* Return a pointer to the process that corresponds to the current
78 thread (current_thread). It is an error to call this if there is
79 no current thread selected. */
80
81 struct process_info *current_process (void);
82 struct process_info *get_thread_process (const struct thread_info *);
83
84 extern std::list<process_info *> all_processes;
85
86 /* Invoke FUNC for each process. */
87
88 template <typename Func>
89 static void
90 for_each_process (Func func)
91 {
92 std::list<process_info *>::iterator next, cur = all_processes.begin ();
93
94 while (cur != all_processes.end ())
95 {
96 next = cur;
97 next++;
98 func (*cur);
99 cur = next;
100 }
101 }
102
103 /* Find the first process for which FUNC returns true. Return NULL if no
104 process satisfying FUNC is found. */
105
106 template <typename Func>
107 static process_info *
108 find_process (Func func)
109 {
110 std::list<process_info *>::iterator next, cur = all_processes.begin ();
111
112 while (cur != all_processes.end ())
113 {
114 next = cur;
115 next++;
116
117 if (func (*cur))
118 return *cur;
119
120 cur = next;
121 }
122
123 return NULL;
124 }
125
126 extern struct thread_info *current_thread;
127
128 /* Return the first process in the processes list. */
129 struct process_info *get_first_process (void);
130
131 struct process_info *add_process (int pid, int attached);
132 void remove_process (struct process_info *process);
133 struct process_info *find_process_pid (int pid);
134 int have_started_inferiors_p (void);
135 int have_attached_inferiors_p (void);
136
137 void clear_inferiors (void);
138
139 thread_info *find_inferior (std::list<thread_info *> *thread_list,
140 int (*func) (thread_info *, void *), void *arg);
141 thread_info *find_inferior_id (std::list<thread_info *> *thread_list,
142 ptid_t id);
143 thread_info *find_inferior_in_random (std::list<thread_info *> *thread_list,
144 int (*func) (thread_info *, void *),
145 void *arg);
146 void for_each_inferior (std::list<thread_info *> *thread_list,
147 void (*action) (thread_info *));
148 void for_each_inferior_with_data (std::list<thread_info *> *thread_list,
149 void (*action) (thread_info *, void *),
150 void *data);
151
152 void *thread_target_data (struct thread_info *);
153 struct regcache *thread_regcache_data (struct thread_info *);
154 void set_thread_regcache_data (struct thread_info *, struct regcache *);
155
156 #endif /* INFERIORS_H */
This page took 0.035744 seconds and 4 git commands to generate.