Updated Malay translation for the bfd sub-directory
[binutils-gdb.git] / gdbserver / inferiors.h
blobc3fea8d89746c36b6b570fd1059647510eb52191
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/owning_intrusive_list.h"
24 #include "dll.h"
26 #include <unordered_map>
28 struct thread_info;
29 struct regcache;
30 struct target_desc;
31 struct sym_cache;
32 struct breakpoint;
33 struct raw_breakpoint;
34 struct fast_tracepoint_jump;
35 struct process_info_private;
36 struct process_info;
38 extern owning_intrusive_list<process_info> all_processes;
40 struct process_info : public intrusive_list_node<process_info>
42 process_info (int pid_, int attached_)
43 : pid (pid_), attached (attached_)
46 /* This process' pid. */
47 int pid;
49 /* Nonzero if this child process was attached rather than
50 spawned. */
51 int attached;
53 /* True if GDB asked us to detach from this process, but we remained
54 attached anyway. */
55 int gdb_detached = 0;
57 /* The symbol cache. */
58 struct sym_cache *symbol_cache = NULL;
60 /* The list of memory breakpoints. */
61 struct breakpoint *breakpoints = NULL;
63 /* The list of raw memory breakpoints. */
64 struct raw_breakpoint *raw_breakpoints = NULL;
66 /* The list of installed fast tracepoints. */
67 struct fast_tracepoint_jump *fast_tracepoint_jumps = NULL;
69 /* The list of syscalls to report, or just a single element, ANY_SYSCALL,
70 for unfiltered syscall reporting. */
71 std::vector<int> syscalls_to_catch;
73 const struct target_desc *tdesc = NULL;
75 /* Private target data. */
76 struct process_info_private *priv = NULL;
78 /* DLLs that are loaded for this proc. */
79 std::list<dll_info> all_dlls;
81 /* Flag to mark that the DLL list has changed. */
82 bool dlls_changed = false;
84 /* True if the inferior is starting up (inside startup_inferior),
85 and we're nursing it along (through the shell) until it is ready
86 to execute its first instruction. Until that is done, we must
87 not access inferior memory or registers, as we haven't determined
88 the target architecture/description. */
89 bool starting_up = false;
91 /* Return a reference to the private thread list. */
92 owning_intrusive_list<thread_info> &thread_list ()
93 { return m_thread_list; }
95 /* Return the number of threads in this process. */
96 unsigned int thread_count () const
97 { return m_ptid_thread_map.size (); }
99 /* Return the thread with ptid PTID, or nullptr if no such thread is
100 found. */
101 thread_info *find_thread (ptid_t ptid);
103 /* Find the first thread for which FUNC returns true. Return nullptr if no
104 such thread is found. */
105 thread_info *find_thread (gdb::function_view<bool (thread_info *)> func);
107 /* Invoke FUNC for each thread. */
108 void for_each_thread (gdb::function_view<void (thread_info *)> func);
110 /* Add a thread with id ID to this process. */
111 thread_info *add_thread (ptid_t id, void *target_data);
113 /* Remove thread THREAD.
115 THREAD must be part of this process' thread list. */
116 void remove_thread (thread_info *thread);
118 private:
119 /* This processes' thread list, sorted by creation order. */
120 owning_intrusive_list<thread_info> m_thread_list;
122 /* A map of ptid_t to thread_info*, for average O(1) ptid_t lookup.
123 Exited threads do not appear in the map. */
124 std::unordered_map<ptid_t, thread_info *> m_ptid_thread_map;
127 /* Return a pointer to the current process. Note that the current
128 process may be non-null while the current thread (current_thread)
129 is null. */
131 struct process_info *current_process (void);
133 extern owning_intrusive_list<process_info> all_processes;
135 /* Invoke FUNC for each process. */
137 void for_each_process (gdb::function_view<void (process_info *)> func);
139 /* Find the first process for which FUNC returns true. Return NULL if no
140 process satisfying FUNC is found. */
142 process_info *find_process (gdb::function_view<bool (process_info *)> func);
144 extern thread_info *current_thread;
146 /* Return the first process in the processes list. */
147 struct process_info *get_first_process (void);
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);
155 /* Switch to a thread of PROC. */
156 void switch_to_process (process_info *proc);
158 /* Set the inferior current working directory. If CWD is empty, unset
159 the directory. */
160 void set_inferior_cwd (std::string cwd);
162 #endif /* GDBSERVER_INFERIORS_H */