]>
Commit | Line | Data |
---|---|---|
270c6aea | 1 | /* Inferior process information for the remote server for GDB. |
4a94e368 | 2 | Copyright (C) 1993-2022 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 | ||
1a5c2598 TT |
19 | #ifndef GDBSERVER_INFERIORS_H |
20 | #define GDBSERVER_INFERIORS_H | |
270c6aea | 21 | |
268a13a5 | 22 | #include "gdbsupport/gdb_vecs.h" |
d171632f | 23 | #include "dll.h" |
9179355e | 24 | #include <list> |
82075af2 | 25 | |
270c6aea | 26 | struct thread_info; |
a44892be | 27 | struct regcache; |
270c6aea PA |
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 | { | |
f27866ba SM |
37 | process_info (int pid_, int attached_) |
38 | : pid (pid_), attached (attached_) | |
39 | {} | |
40 | ||
9179355e SM |
41 | /* This process' pid. */ |
42 | int pid; | |
270c6aea PA |
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. */ | |
f27866ba | 50 | int gdb_detached = 0; |
270c6aea PA |
51 | |
52 | /* The symbol cache. */ | |
f27866ba | 53 | struct sym_cache *symbol_cache = NULL; |
270c6aea PA |
54 | |
55 | /* The list of memory breakpoints. */ | |
f27866ba | 56 | struct breakpoint *breakpoints = NULL; |
270c6aea PA |
57 | |
58 | /* The list of raw memory breakpoints. */ | |
f27866ba | 59 | struct raw_breakpoint *raw_breakpoints = NULL; |
270c6aea PA |
60 | |
61 | /* The list of installed fast tracepoints. */ | |
f27866ba | 62 | struct fast_tracepoint_jump *fast_tracepoint_jumps = NULL; |
270c6aea | 63 | |
82075af2 JS |
64 | /* The list of syscalls to report, or just a single element, ANY_SYSCALL, |
65 | for unfiltered syscall reporting. */ | |
f27866ba | 66 | std::vector<int> syscalls_to_catch; |
82075af2 | 67 | |
f27866ba | 68 | const struct target_desc *tdesc = NULL; |
270c6aea PA |
69 | |
70 | /* Private target data. */ | |
f27866ba | 71 | struct process_info_private *priv = NULL; |
d171632f TBA |
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; | |
a9deee17 PA |
78 | |
79 | /* True if the inferior is starting up (inside startup_inferior), | |
80 | and we're nursing it along (through the shell) until it is ready | |
81 | to execute its first instruction. Until that is done, we must | |
82 | not access inferior memory or registers, as we haven't determined | |
83 | the target architecture/description. */ | |
84 | bool starting_up = false; | |
270c6aea PA |
85 | }; |
86 | ||
9179355e SM |
87 | /* Get the pid of PROC. */ |
88 | ||
89 | static inline int | |
90 | pid_of (const process_info *proc) | |
91 | { | |
92 | return proc->pid; | |
93 | } | |
d86d4aaf | 94 | |
270c6aea | 95 | /* Return a pointer to the process that corresponds to the current |
0bfdf32f | 96 | thread (current_thread). It is an error to call this if there is |
270c6aea PA |
97 | no current thread selected. */ |
98 | ||
99 | struct process_info *current_process (void); | |
63c40ec7 | 100 | struct process_info *get_thread_process (const struct thread_info *); |
270c6aea | 101 | |
9179355e | 102 | extern std::list<process_info *> all_processes; |
270c6aea | 103 | |
9179355e SM |
104 | /* Invoke FUNC for each process. */ |
105 | ||
106 | template <typename Func> | |
107 | static void | |
108 | for_each_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 | func (*cur); | |
117 | cur = next; | |
118 | } | |
119 | } | |
120 | ||
121 | /* Find the first process for which FUNC returns true. Return NULL if no | |
122 | process satisfying FUNC is found. */ | |
123 | ||
124 | template <typename Func> | |
125 | static process_info * | |
126 | find_process (Func func) | |
127 | { | |
128 | std::list<process_info *>::iterator next, cur = all_processes.begin (); | |
129 | ||
130 | while (cur != all_processes.end ()) | |
131 | { | |
132 | next = cur; | |
133 | next++; | |
134 | ||
135 | if (func (*cur)) | |
dda83cd7 | 136 | return *cur; |
9179355e SM |
137 | |
138 | cur = next; | |
139 | } | |
140 | ||
141 | return NULL; | |
142 | } | |
fa96cb38 | 143 | |
0bfdf32f | 144 | extern struct thread_info *current_thread; |
649ebbca | 145 | |
3d40fbb5 PA |
146 | /* Return the first process in the processes list. */ |
147 | struct process_info *get_first_process (void); | |
148 | ||
270c6aea PA |
149 | struct process_info *add_process (int pid, int attached); |
150 | void remove_process (struct process_info *process); | |
151 | struct process_info *find_process_pid (int pid); | |
152 | int have_started_inferiors_p (void); | |
153 | int have_attached_inferiors_p (void); | |
154 | ||
028a4603 PA |
155 | /* Switch to a thread of PROC. */ |
156 | void switch_to_process (process_info *proc); | |
157 | ||
270c6aea | 158 | void clear_inferiors (void); |
9c80ecd6 | 159 | |
6afd337d SM |
160 | void *thread_target_data (struct thread_info *); |
161 | struct regcache *thread_regcache_data (struct thread_info *); | |
162 | void set_thread_regcache_data (struct thread_info *, struct regcache *); | |
270c6aea | 163 | |
11bd012e | 164 | /* Set the inferior current working directory. If CWD is empty, unset |
5b8bf2e7 | 165 | the directory. */ |
11bd012e | 166 | void set_inferior_cwd (std::string cwd); |
5b8bf2e7 | 167 | |
1a5c2598 | 168 | #endif /* GDBSERVER_INFERIORS_H */ |