GDBserver

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