Remove "noisy" parameter from clear_complaints
[deliverable/binutils-gdb.git] / gdb / progspace.h
CommitLineData
6c95b8df
PA
1/* Program and address space management, for GDB, the GNU debugger.
2
e2882c85 3 Copyright (C) 2009-2018 Free Software Foundation, Inc.
6c95b8df
PA
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20
21#ifndef PROGSPACE_H
22#define PROGSPACE_H
23
24#include "target.h"
25#include "vec.h"
06333fea 26#include "gdb_bfd.h"
edcc5120 27#include "gdb_vecs.h"
8e260fc0 28#include "registry.h"
6c95b8df
PA
29
30struct target_ops;
31struct bfd;
32struct objfile;
33struct inferior;
34struct exec;
35struct address_space;
36struct program_space_data;
b26dfc9a 37struct address_space_data;
6c95b8df 38
edcc5120
TT
39typedef struct so_list *so_list_ptr;
40DEF_VEC_P (so_list_ptr);
41
6c95b8df
PA
42/* A program space represents a symbolic view of an address space.
43 Roughly speaking, it holds all the data associated with a
44 non-running-yet program (main executable, main symbols), and when
45 an inferior is running and is bound to it, includes the list of its
46 mapped in shared libraries.
47
48 In the traditional debugging scenario, there's a 1-1 correspondence
49 among program spaces, inferiors and address spaces, like so:
50
51 pspace1 (prog1) <--> inf1(pid1) <--> aspace1
52
53 In the case of debugging more than one traditional unix process or
54 program, we still have:
55
56 |-----------------+------------+---------|
57 | pspace1 (prog1) | inf1(pid1) | aspace1 |
58 |----------------------------------------|
59 | pspace2 (prog1) | no inf yet | aspace2 |
60 |-----------------+------------+---------|
61 | pspace3 (prog2) | inf2(pid2) | aspace3 |
62 |-----------------+------------+---------|
63
64 In the former example, if inf1 forks (and GDB stays attached to
65 both processes), the new child will have its own program and
66 address spaces. Like so:
67
68 |-----------------+------------+---------|
69 | pspace1 (prog1) | inf1(pid1) | aspace1 |
70 |-----------------+------------+---------|
71 | pspace2 (prog1) | inf2(pid2) | aspace2 |
72 |-----------------+------------+---------|
73
74 However, had inf1 from the latter case vforked instead, it would
75 share the program and address spaces with its parent, until it
76 execs or exits, like so:
77
78 |-----------------+------------+---------|
79 | pspace1 (prog1) | inf1(pid1) | aspace1 |
80 | | inf2(pid2) | |
81 |-----------------+------------+---------|
82
83 When the vfork child execs, it is finally given new program and
84 address spaces.
85
86 |-----------------+------------+---------|
87 | pspace1 (prog1) | inf1(pid1) | aspace1 |
88 |-----------------+------------+---------|
89 | pspace2 (prog1) | inf2(pid2) | aspace2 |
90 |-----------------+------------+---------|
91
92 There are targets where the OS (if any) doesn't provide memory
93 management or VM protection, where all inferiors share the same
94 address space --- e.g. uClinux. GDB models this by having all
95 inferiors share the same address space, but, giving each its own
96 program space, like so:
97
98 |-----------------+------------+---------|
99 | pspace1 (prog1) | inf1(pid1) | |
100 |-----------------+------------+ |
101 | pspace2 (prog1) | inf2(pid2) | aspace1 |
102 |-----------------+------------+ |
103 | pspace3 (prog2) | inf3(pid3) | |
104 |-----------------+------------+---------|
105
106 The address space sharing matters for run control and breakpoints
107 management. E.g., did we just hit a known breakpoint that we need
108 to step over? Is this breakpoint a duplicate of this other one, or
109 do I need to insert a trap?
110
111 Then, there are targets where all symbols look the same for all
112 inferiors, although each has its own address space, as e.g.,
113 Ericsson DICOS. In such case, the model is:
114
115 |---------+------------+---------|
116 | | inf1(pid1) | aspace1 |
117 | +------------+---------|
118 | pspace | inf2(pid2) | aspace2 |
119 | +------------+---------|
120 | | inf3(pid3) | aspace3 |
121 |---------+------------+---------|
122
123 Note however, that the DICOS debug API takes care of making GDB
124 believe that breakpoints are "global". That is, although each
125 process does have its own private copy of data symbols (just like a
126 bunch of forks), to the breakpoints module, all processes share a
127 single address space, so all breakpoints set at the same address
128 are duplicates of each other, even breakpoints set in the data
129 space (e.g., call dummy breakpoints placed on stack). This allows
130 a simplification in the spaces implementation: we avoid caring for
131 a many-many links between address and program spaces. Either
132 there's a single address space bound to the program space
133 (traditional unix/uClinux), or, in the DICOS case, the address
134 space bound to the program space is mostly ignored. */
135
136/* The program space structure. */
137
138struct program_space
564b1e3f
SM
139{
140 program_space (address_space *aspace_);
141 ~program_space ();
142
143 /* Pointer to next in linked list. */
144 struct program_space *next = NULL;
145
146 /* Unique ID number. */
147 int num = 0;
148
149 /* The main executable loaded into this program space. This is
150 managed by the exec target. */
151
152 /* The BFD handle for the main executable. */
153 bfd *ebfd = NULL;
154 /* The last-modified time, from when the exec was brought in. */
155 long ebfd_mtime = 0;
156 /* Similar to bfd_get_filename (exec_bfd) but in original form given
157 by user, without symbolic links and pathname resolved.
158 It needs to be freed by xfree. It is not NULL iff EBFD is not NULL. */
159 char *pspace_exec_filename = NULL;
160
e540a5a2 161 /* Binary file diddling handle for the core file. */
06333fea 162 gdb_bfd_ref_ptr cbfd;
e540a5a2 163
564b1e3f
SM
164 /* The address space attached to this program space. More than one
165 program space may be bound to the same address space. In the
166 traditional unix-like debugging scenario, this will usually
167 match the address space bound to the inferior, and is mostly
168 used by the breakpoints module for address matches. If the
169 target shares a program space for all inferiors and breakpoints
170 are global, then this field is ignored (we don't currently
171 support inferiors sharing a program space if the target doesn't
172 make breakpoints global). */
173 struct address_space *aspace = NULL;
174
175 /* True if this program space's section offsets don't yet represent
176 the final offsets of the "live" address space (that is, the
177 section addresses still require the relocation offsets to be
178 applied, and hence we can't trust the section addresses for
179 anything that pokes at live memory). E.g., for qOffsets
180 targets, or for PIE executables, until we connect and ask the
181 target for the final relocation offsets, the symbols we've used
182 to set breakpoints point at the wrong addresses. */
183 int executing_startup = 0;
184
185 /* True if no breakpoints should be inserted in this program
186 space. */
187 int breakpoints_not_allowed = 0;
188
189 /* The object file that the main symbol table was loaded from
190 (e.g. the argument to the "symbol-file" or "file" command). */
191 struct objfile *symfile_object_file = NULL;
192
193 /* All known objfiles are kept in a linked list. This points to
194 the head of this list. */
195 struct objfile *objfiles = NULL;
196
197 /* The set of target sections matching the sections mapped into
198 this program space. Managed by both exec_ops and solib.c. */
199 struct target_section_table target_sections {};
200
201 /* List of shared objects mapped into this space. Managed by
202 solib.c. */
203 struct so_list *so_list = NULL;
204
205 /* Number of calls to solib_add. */
206 unsigned int solib_add_generation = 0;
207
208 /* When an solib is added, it is also added to this vector. This
209 is so we can properly report solib changes to the user. */
210 VEC (so_list_ptr) *added_solibs = NULL;
211
212 /* When an solib is removed, its name is added to this vector.
213 This is so we can properly report solib changes to the user. */
6fb16ce6 214 std::vector<std::string> deleted_solibs;
564b1e3f
SM
215
216 /* Per pspace data-pointers required by other GDB modules. */
217 REGISTRY_FIELDS {};
218};
6c95b8df 219
55b11ddf
PA
220/* An address space. It is used for comparing if
221 pspaces/inferior/threads see the same address space and for
222 associating caches to each address space. */
223struct address_space
224{
225 int num;
226
227 /* Per aspace data-pointers required by other GDB modules. */
228 REGISTRY_FIELDS;
229};
230
6c95b8df
PA
231/* The object file that the main symbol table was loaded from (e.g. the
232 argument to the "symbol-file" or "file" command). */
233
234#define symfile_objfile current_program_space->symfile_object_file
235
236/* All known objfiles are kept in a linked list. This points to the
0df8b418 237 root of this list. */
6c95b8df
PA
238#define object_files current_program_space->objfiles
239
240/* The set of target sections matching the sections mapped into the
241 current program space. */
242#define current_target_sections (&current_program_space->target_sections)
243
244/* The list of all program spaces. There's always at least one. */
245extern struct program_space *program_spaces;
246
247/* The current program space. This is always non-null. */
248extern struct program_space *current_program_space;
249
250#define ALL_PSPACES(pspace) \
251 for ((pspace) = program_spaces; (pspace) != NULL; (pspace) = (pspace)->next)
252
7a41607e
SM
253/* Remove a program space from the program spaces list and release it. It is
254 an error to call this function while PSPACE is the current program space. */
255extern void delete_program_space (struct program_space *pspace);
256
6c95b8df
PA
257/* Returns the number of program spaces listed. */
258extern int number_of_program_spaces (void);
259
7a41607e
SM
260/* Returns true iff there's no inferior bound to PSPACE. */
261extern int program_space_empty_p (struct program_space *pspace);
262
6c95b8df
PA
263/* Copies program space SRC to DEST. Copies the main executable file,
264 and the main symbol file. Returns DEST. */
265extern struct program_space *clone_program_space (struct program_space *dest,
266 struct program_space *src);
267
6c95b8df
PA
268/* Sets PSPACE as the current program space. This is usually used
269 instead of set_current_space_and_thread when the current
270 thread/inferior is not important for the operations that follow.
271 E.g., when accessing the raw symbol tables. If memory access is
272 required, then you should use switch_to_program_space_and_thread.
273 Otherwise, it is the caller's responsibility to make sure that the
274 currently selected inferior/thread matches the selected program
275 space. */
276extern void set_current_program_space (struct program_space *pspace);
277
5ed8105e
PA
278/* Save/restore the current program space. */
279
280class scoped_restore_current_program_space
281{
282public:
283 scoped_restore_current_program_space ()
284 : m_saved_pspace (current_program_space)
285 {}
286
287 ~scoped_restore_current_program_space ()
288 { set_current_program_space (m_saved_pspace); }
289
d6541620 290 DISABLE_COPY_AND_ASSIGN (scoped_restore_current_program_space);
6c95b8df 291
5ed8105e
PA
292private:
293 program_space *m_saved_pspace;
294};
6c95b8df
PA
295
296/* Create a new address space object, and add it to the list. */
297extern struct address_space *new_address_space (void);
298
299/* Maybe create a new address space object, and add it to the list, or
300 return a pointer to an existing address space, in case inferiors
301 share an address space. */
302extern struct address_space *maybe_new_address_space (void);
303
c0694254
PA
304/* Returns the integer address space id of ASPACE. */
305extern int address_space_num (struct address_space *aspace);
306
6c95b8df
PA
307/* Update all program spaces matching to address spaces. The user may
308 have created several program spaces, and loaded executables into
309 them before connecting to the target interface that will create the
310 inferiors. All that happens before GDB has a chance to know if the
311 inferiors will share an address space or not. Call this after
312 having connected to the target interface and having fetched the
313 target description, to fixup the program/address spaces
314 mappings. */
315extern void update_address_spaces (void);
316
edcc5120
TT
317/* Reset saved solib data at the start of an solib event. This lets
318 us properly collect the data when calling solib_add, so it can then
319 later be printed. */
320extern void clear_program_space_solib_cache (struct program_space *);
321
6c95b8df
PA
322/* Keep a registry of per-pspace data-pointers required by other GDB
323 modules. */
324
8e260fc0 325DECLARE_REGISTRY (program_space);
6c95b8df 326
3a8356ff
YQ
327/* Keep a registry of per-aspace data-pointers required by other GDB
328 modules. */
329
330DECLARE_REGISTRY (address_space);
331
6c95b8df 332#endif
This page took 0.859356 seconds and 4 git commands to generate.