1 /* Inferior process information for the remote server for GDB.
2 Copyright (C) 1993-2024 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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/>. */
19 #ifndef GDBSERVER_INFERIORS_H
20 #define GDBSERVER_INFERIORS_H
22 #include "gdbsupport/gdb_vecs.h"
23 #include "gdbsupport/owning_intrusive_list.h"
27 #include <unordered_map>
34 struct raw_breakpoint
;
35 struct fast_tracepoint_jump
;
36 struct process_info_private
;
39 extern owning_intrusive_list
<process_info
> all_processes
;
41 struct process_info
: public intrusive_list_node
<process_info
>
43 process_info (int pid_
, int attached_
)
44 : pid (pid_
), attached (attached_
)
47 /* This process' pid. */
50 /* Nonzero if this child process was attached rather than
54 /* True if GDB asked us to detach from this process, but we remained
58 /* The symbol cache. */
59 struct sym_cache
*symbol_cache
= NULL
;
61 /* The list of memory breakpoints. */
62 struct breakpoint
*breakpoints
= NULL
;
64 /* The list of raw memory breakpoints. */
65 struct raw_breakpoint
*raw_breakpoints
= NULL
;
67 /* The list of installed fast tracepoints. */
68 struct fast_tracepoint_jump
*fast_tracepoint_jumps
= NULL
;
70 /* The list of syscalls to report, or just a single element, ANY_SYSCALL,
71 for unfiltered syscall reporting. */
72 std::vector
<int> syscalls_to_catch
;
74 const struct target_desc
*tdesc
= NULL
;
76 /* Private target data. */
77 struct process_info_private
*priv
= NULL
;
79 /* DLLs that are loaded for this proc. */
80 std::list
<dll_info
> all_dlls
;
82 /* Flag to mark that the DLL list has changed. */
83 bool dlls_changed
= false;
85 /* True if the inferior is starting up (inside startup_inferior),
86 and we're nursing it along (through the shell) until it is ready
87 to execute its first instruction. Until that is done, we must
88 not access inferior memory or registers, as we haven't determined
89 the target architecture/description. */
90 bool starting_up
= false;
92 /* Return a reference to the private thread list. */
93 owning_intrusive_list
<thread_info
> &thread_list ()
94 { return m_thread_list
; }
96 /* Return a reference to the private thread map. */
97 std::unordered_map
<ptid_t
, thread_info
*> &thread_map ()
98 { return m_ptid_thread_map
; }
100 /* Find the first thread for which FUNC returns true. Return nullptr if no
101 such thread is found. */
102 thread_info
*find_thread (gdb::function_view
<bool (thread_info
*)> func
);
104 /* Invoke FUNC for each thread. */
105 void for_each_thread (gdb::function_view
<void (thread_info
*)> func
);
107 /* Add a thread with id ID to this process. */
108 thread_info
*add_thread (ptid_t id
, void *target_data
);
110 /* Remove thread THREAD.
112 THREAD must be part of this process' thread list. */
113 void remove_thread (thread_info
*thread
);
116 /* This processes' thread list, sorted by creation order. */
117 owning_intrusive_list
<thread_info
> m_thread_list
;
119 /* A map of ptid_t to thread_info*, for average O(1) ptid_t lookup.
120 Exited threads do not appear in the map. */
121 std::unordered_map
<ptid_t
, thread_info
*> m_ptid_thread_map
;
124 /* Return a pointer to the current process. Note that the current
125 process may be non-null while the current thread (current_thread)
128 struct process_info
*current_process (void);
130 extern owning_intrusive_list
<process_info
> all_processes
;
132 /* Invoke FUNC for each process. */
134 void for_each_process (gdb::function_view
<void (process_info
*)> func
);
136 /* Find the first process for which FUNC returns true. Return NULL if no
137 process satisfying FUNC is found. */
139 process_info
*find_process (gdb::function_view
<bool (process_info
*)> func
);
141 extern struct thread_info
*current_thread
;
143 /* Return the first process in the processes list. */
144 struct process_info
*get_first_process (void);
146 struct process_info
*add_process (int pid
, int attached
);
147 void remove_process (struct process_info
*process
);
148 struct process_info
*find_process_pid (int pid
);
149 int have_started_inferiors_p (void);
150 int have_attached_inferiors_p (void);
152 /* Switch to a thread of PROC. */
153 void switch_to_process (process_info
*proc
);
155 void clear_inferiors (void);
157 void *thread_target_data (struct thread_info
*);
158 struct regcache
*thread_regcache_data (struct thread_info
*);
159 void set_thread_regcache_data (struct thread_info
*, struct regcache
*);
161 /* Set the inferior current working directory. If CWD is empty, unset
163 void set_inferior_cwd (std::string cwd
);
165 #endif /* GDBSERVER_INFERIORS_H */