Make open_fds an std::vector
[deliverable/binutils-gdb.git] / gdb / gdbserver / inferiors.h
CommitLineData
270c6aea 1/* Inferior process information for the remote server for GDB.
61baf725 2 Copyright (C) 1993-2017 Free Software Foundation, Inc.
270c6aea
PA
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
82075af2 22#include "gdb_vecs.h"
9179355e 23#include <list>
82075af2 24
270c6aea 25struct thread_info;
a44892be 26struct regcache;
270c6aea
PA
27struct target_desc;
28struct sym_cache;
29struct breakpoint;
30struct raw_breakpoint;
31struct fast_tracepoint_jump;
32struct process_info_private;
33
34struct process_info
35{
9179355e
SM
36 /* This process' pid. */
37 int pid;
270c6aea
PA
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
82075af2
JS
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
270c6aea
PA
63 const struct target_desc *tdesc;
64
65 /* Private target data. */
fe978cb0 66 struct process_info_private *priv;
270c6aea
PA
67};
68
9179355e
SM
69/* Get the pid of PROC. */
70
71static inline int
72pid_of (const process_info *proc)
73{
74 return proc->pid;
75}
d86d4aaf 76
270c6aea 77/* Return a pointer to the process that corresponds to the current
0bfdf32f 78 thread (current_thread). It is an error to call this if there is
270c6aea
PA
79 no current thread selected. */
80
81struct process_info *current_process (void);
63c40ec7 82struct process_info *get_thread_process (const struct thread_info *);
270c6aea 83
9179355e 84extern std::list<process_info *> all_processes;
270c6aea 85
9179355e
SM
86/* Invoke FUNC for each process. */
87
88template <typename Func>
89static void
90for_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
106template <typename Func>
107static process_info *
108find_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}
fa96cb38 125
0bfdf32f 126extern struct thread_info *current_thread;
649ebbca 127
3d40fbb5
PA
128/* Return the first process in the processes list. */
129struct process_info *get_first_process (void);
130
270c6aea
PA
131struct process_info *add_process (int pid, int attached);
132void remove_process (struct process_info *process);
133struct process_info *find_process_pid (int pid);
134int have_started_inferiors_p (void);
135int have_attached_inferiors_p (void);
136
270c6aea 137void clear_inferiors (void);
9c80ecd6
SM
138
139thread_info *find_inferior (std::list<thread_info *> *thread_list,
140 int (*func) (thread_info *, void *), void *arg);
141thread_info *find_inferior_id (std::list<thread_info *> *thread_list,
142 ptid_t id);
143thread_info *find_inferior_in_random (std::list<thread_info *> *thread_list,
144 int (*func) (thread_info *, void *),
145 void *arg);
146void for_each_inferior (std::list<thread_info *> *thread_list,
147 void (*action) (thread_info *));
148void for_each_inferior_with_data (std::list<thread_info *> *thread_list,
149 void (*action) (thread_info *, void *),
150 void *data);
80894984 151
6afd337d
SM
152void *thread_target_data (struct thread_info *);
153struct regcache *thread_regcache_data (struct thread_info *);
154void set_thread_regcache_data (struct thread_info *, struct regcache *);
270c6aea
PA
155
156#endif /* INFERIORS_H */
This page took 0.338209 seconds and 4 git commands to generate.