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