Commit | Line | Data |
---|---|---|
cd4fb1b2 SM |
1 | /* DWARF 2 debugging format support for GDB. |
2 | ||
b811d2c2 | 3 | Copyright (C) 1994-2020 Free Software Foundation, Inc. |
cd4fb1b2 SM |
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 | #ifndef DWARF2READ_H | |
21 | #define DWARF2READ_H | |
22 | ||
39856def | 23 | #include <queue> |
e4a62c65 | 24 | #include <unordered_map> |
82ca8957 | 25 | #include "dwarf2/index-cache.h" |
2c86cff9 | 26 | #include "dwarf2/section.h" |
cd4fb1b2 SM |
27 | #include "filename-seen-cache.h" |
28 | #include "gdb_obstack.h" | |
268a13a5 | 29 | #include "gdbsupport/hash_enum.h" |
891813be | 30 | #include "psympriv.h" |
cd4fb1b2 | 31 | |
3c3bb058 AB |
32 | /* Hold 'maintenance (set|show) dwarf' commands. */ |
33 | extern struct cmd_list_element *set_dwarf_cmdlist; | |
34 | extern struct cmd_list_element *show_dwarf_cmdlist; | |
35 | ||
cd4fb1b2 SM |
36 | struct tu_stats |
37 | { | |
38 | int nr_uniq_abbrev_tables; | |
39 | int nr_symtabs; | |
40 | int nr_symtab_sharers; | |
41 | int nr_stmt_less_type_units; | |
42 | int nr_all_type_units_reallocs; | |
43 | }; | |
44 | ||
45 | struct dwarf2_debug_sections; | |
39856def | 46 | struct dwarf2_per_cu_data; |
cd4fb1b2 SM |
47 | struct mapped_index; |
48 | struct mapped_debug_names; | |
ff4c9fec | 49 | struct signatured_type; |
cd4fb1b2 | 50 | |
39856def TT |
51 | /* One item on the queue of compilation units to read in full symbols |
52 | for. */ | |
53 | struct dwarf2_queue_item | |
54 | { | |
55 | dwarf2_queue_item (dwarf2_per_cu_data *cu, enum language lang) | |
56 | : per_cu (cu), | |
57 | pretend_language (lang) | |
58 | { | |
59 | } | |
60 | ||
61 | ~dwarf2_queue_item (); | |
62 | ||
63 | DISABLE_COPY_AND_ASSIGN (dwarf2_queue_item); | |
64 | ||
65 | struct dwarf2_per_cu_data *per_cu; | |
66 | enum language pretend_language; | |
67 | }; | |
68 | ||
5989a64e SM |
69 | /* Some DWARF data can be shared across objfiles who share the same BFD, |
70 | this data is stored in this object. | |
cd4fb1b2 | 71 | |
5989a64e SM |
72 | Two dwarf2_per_objfile objects representing objfiles sharing the same BFD |
73 | will point to the same instance of dwarf2_per_bfd, unless the BFD requires | |
74 | relocation. */ | |
75 | ||
76 | struct dwarf2_per_bfd | |
cd4fb1b2 | 77 | { |
5989a64e | 78 | /* Construct a dwarf2_per_bfd for OBFD. NAMES points to the |
cd4fb1b2 | 79 | dwarf2 section names, or is NULL if the standard ELF names are |
4b610737 TT |
80 | used. CAN_COPY is true for formats where symbol |
81 | interposition is possible and so symbol values must follow copy | |
82 | relocation rules. */ | |
5989a64e | 83 | dwarf2_per_bfd (bfd *obfd, const dwarf2_debug_sections *names, bool can_copy); |
cd4fb1b2 | 84 | |
5989a64e | 85 | ~dwarf2_per_bfd (); |
cd4fb1b2 | 86 | |
5989a64e | 87 | DISABLE_COPY_AND_ASSIGN (dwarf2_per_bfd); |
cd4fb1b2 | 88 | |
ff4c9fec SM |
89 | /* Return the CU/TU given its index. |
90 | ||
91 | This is intended for loops like: | |
92 | ||
5989a64e SM |
93 | for (i = 0; i < (dwarf2_per_bfd->n_comp_units |
94 | + dwarf2_per_bfd->n_type_units); ++i) | |
ff4c9fec | 95 | { |
5989a64e | 96 | dwarf2_per_cu_data *per_cu = dwarf2_per_bfd->get_cutu (i); |
ff4c9fec SM |
97 | |
98 | ...; | |
99 | } | |
100 | */ | |
101 | dwarf2_per_cu_data *get_cutu (int index); | |
102 | ||
103 | /* Return the CU given its index. | |
104 | This differs from get_cutu in that it's for when you know INDEX refers to a | |
105 | CU. */ | |
106 | dwarf2_per_cu_data *get_cu (int index); | |
107 | ||
108 | /* Return the TU given its index. | |
109 | This differs from get_cutu in that it's for when you know INDEX refers to a | |
110 | TU. */ | |
111 | signatured_type *get_tu (int index); | |
112 | ||
cd4fb1b2 SM |
113 | /* Free all cached compilation units. */ |
114 | void free_cached_comp_units (); | |
86c0bb4c | 115 | |
d3473f0c TT |
116 | /* A convenience function to allocate a dwarf2_per_cu_data. The |
117 | returned object has its "index" field set properly. The object | |
5989a64e | 118 | is allocated on the dwarf2_per_bfd obstack. */ |
d3473f0c TT |
119 | dwarf2_per_cu_data *allocate_per_cu (); |
120 | ||
121 | /* A convenience function to allocate a signatured_type. The | |
122 | returned object has its "index" field set properly. The object | |
5989a64e | 123 | is allocated on the dwarf2_per_bfd obstack. */ |
d3473f0c TT |
124 | signatured_type *allocate_signatured_type (); |
125 | ||
af758d11 SM |
126 | /* Return the number of partial symtabs allocated with allocate_per_cu |
127 | and allocate_signatured_type so far. */ | |
128 | int num_psymtabs () const | |
129 | { return m_num_psymtabs; } | |
130 | ||
cd4fb1b2 SM |
131 | private: |
132 | /* This function is mapped across the sections and remembers the | |
133 | offset and size of each of the debugging sections we are | |
134 | interested in. */ | |
135 | void locate_sections (bfd *abfd, asection *sectp, | |
136 | const dwarf2_debug_sections &names); | |
137 | ||
138 | public: | |
c3699833 SM |
139 | /* The corresponding BFD. */ |
140 | bfd *obfd; | |
141 | ||
45940949 TT |
142 | /* Objects that can be shared across objfiles are stored in this |
143 | obstack or on the psymtab obstack, while objects that are | |
144 | objfile-specific are stored on the objfile obstack. */ | |
145 | auto_obstack obstack; | |
146 | ||
cd4fb1b2 SM |
147 | dwarf2_section_info info {}; |
148 | dwarf2_section_info abbrev {}; | |
149 | dwarf2_section_info line {}; | |
150 | dwarf2_section_info loc {}; | |
151 | dwarf2_section_info loclists {}; | |
152 | dwarf2_section_info macinfo {}; | |
153 | dwarf2_section_info macro {}; | |
154 | dwarf2_section_info str {}; | |
18a8505e | 155 | dwarf2_section_info str_offsets {}; |
cd4fb1b2 SM |
156 | dwarf2_section_info line_str {}; |
157 | dwarf2_section_info ranges {}; | |
158 | dwarf2_section_info rnglists {}; | |
159 | dwarf2_section_info addr {}; | |
160 | dwarf2_section_info frame {}; | |
161 | dwarf2_section_info eh_frame {}; | |
162 | dwarf2_section_info gdb_index {}; | |
163 | dwarf2_section_info debug_names {}; | |
164 | dwarf2_section_info debug_aranges {}; | |
165 | ||
fd5866f6 | 166 | std::vector<dwarf2_section_info> types; |
cd4fb1b2 | 167 | |
cd4fb1b2 SM |
168 | /* Table of all the compilation units. This is used to locate |
169 | the target compilation unit of a particular reference. */ | |
b76e467d | 170 | std::vector<dwarf2_per_cu_data *> all_comp_units; |
cd4fb1b2 | 171 | |
b2bdb8cf SM |
172 | /* The .debug_types-related CUs (TUs). */ |
173 | std::vector<signatured_type *> all_type_units; | |
cd4fb1b2 SM |
174 | |
175 | /* Table of struct type_unit_group objects. | |
176 | The hash key is the DW_AT_stmt_list value. */ | |
eaa5fa8b | 177 | htab_up type_unit_groups; |
cd4fb1b2 SM |
178 | |
179 | /* A table mapping .debug_types signatures to its signatured_type entry. | |
180 | This is NULL if the .debug_types section hasn't been read in yet. */ | |
b0b6a987 | 181 | htab_up signatured_types; |
cd4fb1b2 SM |
182 | |
183 | /* Type unit statistics, to see how well the scaling improvements | |
184 | are doing. */ | |
185 | struct tu_stats tu_stats {}; | |
186 | ||
187 | /* A chain of compilation units that are currently read in, so that | |
188 | they can be freed later. */ | |
189 | dwarf2_per_cu_data *read_in_chain = NULL; | |
190 | ||
191 | /* A table mapping DW_AT_dwo_name values to struct dwo_file objects. | |
192 | This is NULL if the table hasn't been allocated yet. */ | |
51ac9db5 | 193 | htab_up dwo_files; |
cd4fb1b2 SM |
194 | |
195 | /* True if we've checked for whether there is a DWP file. */ | |
196 | bool dwp_checked = false; | |
197 | ||
198 | /* The DWP file if there is one, or NULL. */ | |
400174b1 | 199 | std::unique_ptr<struct dwp_file> dwp_file; |
cd4fb1b2 SM |
200 | |
201 | /* The shared '.dwz' file, if one exists. This is used when the | |
202 | original data was compressed using 'dwz -m'. */ | |
7ff8cb8c | 203 | std::unique_ptr<struct dwz_file> dwz_file; |
cd4fb1b2 | 204 | |
4b610737 TT |
205 | /* Whether copy relocations are supported by this object format. */ |
206 | bool can_copy; | |
207 | ||
cd4fb1b2 SM |
208 | /* A flag indicating whether this objfile has a section loaded at a |
209 | VMA of 0. */ | |
210 | bool has_section_at_zero = false; | |
211 | ||
212 | /* True if we are using the mapped index, | |
213 | or we are faking it for OBJF_READNOW's sake. */ | |
214 | bool using_index = false; | |
215 | ||
216 | /* The mapped index, or NULL if .gdb_index is missing or not being used. */ | |
3063847f | 217 | std::unique_ptr<mapped_index> index_table; |
cd4fb1b2 SM |
218 | |
219 | /* The mapped index, or NULL if .debug_names is missing or not being used. */ | |
220 | std::unique_ptr<mapped_debug_names> debug_names_table; | |
221 | ||
222 | /* When using index_table, this keeps track of all quick_file_names entries. | |
223 | TUs typically share line table entries with a CU, so we maintain a | |
224 | separate table of all line table entries to support the sharing. | |
225 | Note that while there can be way more TUs than CUs, we've already | |
226 | sorted all the TUs into "type unit groups", grouped by their | |
227 | DW_AT_stmt_list value. Therefore the only sharing done here is with a | |
228 | CU and its associated TU group if there is one. */ | |
5895093f | 229 | htab_up quick_file_names_table; |
cd4fb1b2 SM |
230 | |
231 | /* Set during partial symbol reading, to prevent queueing of full | |
232 | symbols. */ | |
233 | bool reading_partial_symbols = false; | |
234 | ||
cd4fb1b2 | 235 | /* The CUs we recently read. */ |
c5d0225d | 236 | std::vector<dwarf2_per_cu_data *> just_read_cus; |
cd4fb1b2 SM |
237 | |
238 | /* Table containing line_header indexed by offset and offset_in_dwz. */ | |
d15acc42 | 239 | htab_up line_header_hash; |
cd4fb1b2 SM |
240 | |
241 | /* Table containing all filenames. This is an optional because the | |
242 | table is lazily constructed on first access. */ | |
243 | gdb::optional<filename_seen_cache> filenames_cache; | |
87d6a7aa SM |
244 | |
245 | /* If we loaded the index from an external file, this contains the | |
246 | resources associated to the open file, memory mapping, etc. */ | |
247 | std::unique_ptr<index_cache_resource> index_cache_res; | |
e4a62c65 TV |
248 | |
249 | /* Mapping from abstract origin DIE to concrete DIEs that reference it as | |
250 | DW_AT_abstract_origin. */ | |
fad03f6e TT |
251 | std::unordered_map<sect_offset, std::vector<sect_offset>, |
252 | gdb::hash_enum<sect_offset>> | |
e4a62c65 | 253 | abstract_to_concrete; |
39856def TT |
254 | |
255 | /* CUs that are queued to be read. */ | |
256 | std::queue<dwarf2_queue_item> queue; | |
d3473f0c TT |
257 | |
258 | private: | |
259 | ||
260 | /* The total number of per_cu and signatured_type objects that have | |
261 | been created so far for this reader. */ | |
262 | size_t m_num_psymtabs = 0; | |
cd4fb1b2 SM |
263 | }; |
264 | ||
5989a64e SM |
265 | /* Collection of data recorded per objfile. |
266 | This hangs off of dwarf2_objfile_data_key. | |
267 | ||
268 | Some DWARF data cannot (currently) be shared across objfiles. Such | |
269 | data is stored in this object. */ | |
270 | ||
271 | struct dwarf2_per_objfile | |
272 | { | |
273 | dwarf2_per_objfile (struct objfile *objfile, dwarf2_per_bfd *per_bfd) | |
274 | : objfile (objfile), per_bfd (per_bfd) | |
275 | {} | |
276 | ||
277 | /* Return pointer to string at .debug_line_str offset as read from BUF. | |
278 | BUF is assumed to be in a compilation unit described by CU_HEADER. | |
279 | Return *BYTES_READ_PTR count of bytes read from BUF. */ | |
280 | const char *read_line_string (const gdb_byte *buf, | |
281 | const struct comp_unit_head *cu_header, | |
282 | unsigned int *bytes_read_ptr); | |
283 | ||
af758d11 SM |
284 | /* Resize the M_SYMTABS vector to the needed size (the number of partial |
285 | symtabs allocated by the per-bfd). */ | |
286 | void resize_symtabs () | |
287 | { | |
288 | /* The symtabs vector should only grow, not shrink. */ | |
289 | gdb_assert (per_bfd->num_psymtabs () >= m_symtabs.size ()); | |
290 | ||
291 | m_symtabs.resize (per_bfd->num_psymtabs ()); | |
292 | } | |
293 | ||
294 | /* Return true if the symtab corresponding to PER_CU has been set, | |
295 | false otherwise. */ | |
296 | bool symtab_set_p (const dwarf2_per_cu_data *per_cu) const; | |
297 | ||
298 | /* Return the compunit_symtab associated to PER_CU, if it has been created. */ | |
299 | compunit_symtab *get_symtab (const dwarf2_per_cu_data *per_cu) const; | |
300 | ||
301 | /* Set the compunit_symtab associated to PER_CU. */ | |
302 | void set_symtab (const dwarf2_per_cu_data *per_cu, compunit_symtab *symtab); | |
303 | ||
293e7e51 SM |
304 | /* Find an integer type SIZE_IN_BYTES bytes in size and return it. |
305 | UNSIGNED_P controls if the integer is unsigned or not. */ | |
306 | struct type *int_type (int size_in_bytes, bool unsigned_p) const; | |
307 | ||
5989a64e SM |
308 | /* Back link. */ |
309 | struct objfile *objfile; | |
310 | ||
311 | /* Pointer to the data that is (possibly) shared between this objfile and | |
312 | other objfiles backed by the same BFD. */ | |
313 | struct dwarf2_per_bfd *per_bfd; | |
af758d11 | 314 | |
ae090bdb SM |
315 | /* Table mapping type DIEs to their struct type *. |
316 | This is nullptr if not allocated yet. | |
317 | The mapping is done via (CU/TU + DIE offset) -> type. */ | |
318 | htab_up die_type_hash; | |
319 | ||
af758d11 SM |
320 | private: |
321 | /* Hold the corresponding compunit_symtab for each CU or TU. This | |
322 | is indexed by dwarf2_per_cu_data::index. A NULL value means | |
323 | that the CU/TU has not been expanded yet. */ | |
324 | std::vector<compunit_symtab *> m_symtabs; | |
5989a64e SM |
325 | }; |
326 | ||
cd4fb1b2 SM |
327 | /* Get the dwarf2_per_objfile associated to OBJFILE. */ |
328 | ||
329 | dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile); | |
330 | ||
891813be | 331 | /* A partial symtab specialized for DWARF. */ |
af758d11 | 332 | struct dwarf2_psymtab : public partial_symtab |
891813be | 333 | { |
891813be | 334 | dwarf2_psymtab (const char *filename, struct objfile *objfile, |
9f4e76a4 | 335 | dwarf2_per_cu_data *per_cu) |
af758d11 | 336 | : partial_symtab (filename, objfile, 0), |
9f4e76a4 | 337 | per_cu_data (per_cu) |
891813be TT |
338 | { |
339 | } | |
340 | ||
341 | void read_symtab (struct objfile *) override; | |
8566b89b | 342 | void expand_psymtab (struct objfile *) override; |
af758d11 SM |
343 | bool readin_p (struct objfile *) const override; |
344 | compunit_symtab *get_compunit_symtab (struct objfile *) const override; | |
891813be TT |
345 | |
346 | struct dwarf2_per_cu_data *per_cu_data; | |
347 | }; | |
348 | ||
cd4fb1b2 SM |
349 | /* Persistent data held for a compilation unit, even when not |
350 | processing it. We put a pointer to this structure in the | |
891813be | 351 | psymtab. */ |
cd4fb1b2 SM |
352 | |
353 | struct dwarf2_per_cu_data | |
354 | { | |
355 | /* The start offset and length of this compilation unit. | |
356 | NOTE: Unlike comp_unit_head.length, this length includes | |
357 | initial_length_size. | |
358 | If the DIE refers to a DWO file, this is always of the original die, | |
359 | not the DWO file. */ | |
360 | sect_offset sect_off; | |
361 | unsigned int length; | |
362 | ||
363 | /* DWARF standard version this data has been read from (such as 4 or 5). */ | |
364 | short dwarf_version; | |
365 | ||
366 | /* Flag indicating this compilation unit will be read in before | |
367 | any of the current compilation units are processed. */ | |
368 | unsigned int queued : 1; | |
369 | ||
370 | /* This flag will be set when reading partial DIEs if we need to load | |
371 | absolutely all DIEs for this compilation unit, instead of just the ones | |
372 | we think are interesting. It gets set if we look for a DIE in the | |
373 | hash table and don't find it. */ | |
374 | unsigned int load_all_dies : 1; | |
375 | ||
376 | /* Non-zero if this CU is from .debug_types. | |
377 | Struct dwarf2_per_cu_data is contained in struct signatured_type iff | |
378 | this is non-zero. */ | |
379 | unsigned int is_debug_types : 1; | |
380 | ||
381 | /* Non-zero if this CU is from the .dwz file. */ | |
382 | unsigned int is_dwz : 1; | |
383 | ||
384 | /* Non-zero if reading a TU directly from a DWO file, bypassing the stub. | |
385 | This flag is only valid if is_debug_types is true. | |
386 | We can't read a CU directly from a DWO file: There are required | |
387 | attributes in the stub. */ | |
388 | unsigned int reading_dwo_directly : 1; | |
389 | ||
390 | /* Non-zero if the TU has been read. | |
391 | This is used to assist the "Stay in DWO Optimization" for Fission: | |
392 | When reading a DWO, it's faster to read TUs from the DWO instead of | |
393 | fetching them from random other DWOs (due to comdat folding). | |
394 | If the TU has already been read, the optimization is unnecessary | |
395 | (and unwise - we don't want to change where gdb thinks the TU lives | |
396 | "midflight"). | |
397 | This flag is only valid if is_debug_types is true. */ | |
398 | unsigned int tu_read : 1; | |
399 | ||
d3473f0c TT |
400 | /* Our index in the unshared "symtabs" vector. */ |
401 | unsigned index; | |
402 | ||
cd4fb1b2 SM |
403 | /* The section this CU/TU lives in. |
404 | If the DIE refers to a DWO file, this is always the original die, | |
405 | not the DWO file. */ | |
406 | struct dwarf2_section_info *section; | |
407 | ||
408 | /* Set to non-NULL iff this CU is currently loaded. When it gets freed out | |
409 | of the CU cache it gets reset to NULL again. This is left as NULL for | |
410 | dummy CUs (a CU header, but nothing else). */ | |
411 | struct dwarf2_cu *cu; | |
412 | ||
58990295 TV |
413 | /* The unit type of this CU. */ |
414 | enum dwarf_unit_type unit_type; | |
415 | ||
416 | /* The language of this CU. */ | |
417 | enum language lang; | |
418 | ||
cd4fb1b2 SM |
419 | /* The corresponding dwarf2_per_objfile. */ |
420 | struct dwarf2_per_objfile *dwarf2_per_objfile; | |
421 | ||
1859c670 SM |
422 | /* Backlink to the owner of this. */ |
423 | dwarf2_per_bfd *per_bfd; | |
424 | ||
5989a64e | 425 | /* When dwarf2_per_bfd::using_index is true, the 'quick' field |
cd4fb1b2 SM |
426 | is active. Otherwise, the 'psymtab' field is active. */ |
427 | union | |
428 | { | |
429 | /* The partial symbol table associated with this compilation unit, | |
430 | or NULL for unread partial units. */ | |
891813be | 431 | dwarf2_psymtab *psymtab; |
cd4fb1b2 SM |
432 | |
433 | /* Data needed by the "quick" functions. */ | |
434 | struct dwarf2_per_cu_quick_data *quick; | |
435 | } v; | |
436 | ||
96c738c0 TT |
437 | /* The CUs we import using DW_TAG_imported_unit. This is filled in |
438 | while reading psymtabs, used to compute the psymtab dependencies, | |
439 | and then cleared. Then it is filled in again while reading full | |
440 | symbols, and only deleted when the objfile is destroyed. | |
441 | ||
442 | This is also used to work around a difference between the way gold | |
443 | generates .gdb_index version <=7 and the way gdb does. Arguably this | |
444 | is a gold bug. For symbols coming from TUs, gold records in the index | |
445 | the CU that includes the TU instead of the TU itself. This breaks | |
446 | dw2_lookup_symbol: It assumes that if the index says symbol X lives | |
447 | in CU/TU Y, then one need only expand Y and a subsequent lookup in Y | |
448 | will find X. Alas TUs live in their own symtab, so after expanding CU Y | |
449 | we need to look in TU Z to find X. Fortunately, this is akin to | |
450 | DW_TAG_imported_unit, so we just use the same mechanism: For | |
451 | .gdb_index version <=7 this also records the TUs that the CU referred | |
452 | to. Concurrently with this change gdb was modified to emit version 8 | |
453 | indices so we only pay a price for gold generated indices. | |
454 | http://sourceware.org/bugzilla/show_bug.cgi?id=15021. | |
455 | ||
456 | This currently needs to be a public member due to how | |
457 | dwarf2_per_cu_data is allocated and used. Ideally in future things | |
458 | could be refactored to make this private. Until then please try to | |
459 | avoid direct access to this member, and instead use the helper | |
460 | functions above. */ | |
461 | std::vector <dwarf2_per_cu_data *> *imported_symtabs; | |
462 | ||
ae640021 AB |
463 | /* Return true of IMPORTED_SYMTABS is empty or not yet allocated. */ |
464 | bool imported_symtabs_empty () const | |
465 | { | |
466 | return (imported_symtabs == nullptr || imported_symtabs->empty ()); | |
467 | } | |
468 | ||
469 | /* Push P to the back of IMPORTED_SYMTABS, allocated IMPORTED_SYMTABS | |
470 | first if required. */ | |
471 | void imported_symtabs_push (dwarf2_per_cu_data *p) | |
472 | { | |
473 | if (imported_symtabs == nullptr) | |
474 | imported_symtabs = new std::vector <dwarf2_per_cu_data *>; | |
475 | imported_symtabs->push_back (p); | |
476 | } | |
477 | ||
478 | /* Return the size of IMPORTED_SYMTABS if it is allocated, otherwise | |
479 | return 0. */ | |
480 | size_t imported_symtabs_size () const | |
481 | { | |
482 | if (imported_symtabs == nullptr) | |
483 | return 0; | |
484 | return imported_symtabs->size (); | |
485 | } | |
486 | ||
487 | /* Delete IMPORTED_SYMTABS and set the pointer back to nullptr. */ | |
488 | void imported_symtabs_free () | |
489 | { | |
490 | delete imported_symtabs; | |
491 | imported_symtabs = nullptr; | |
492 | } | |
09ba997f TT |
493 | |
494 | /* Return the OBJFILE associated with this compilation unit. If | |
495 | this compilation unit came from a separate debuginfo file, then | |
496 | the master objfile is returned. */ | |
497 | struct objfile *objfile () const; | |
498 | ||
499 | /* Return the address size given in the compilation unit header for | |
500 | this CU. */ | |
501 | int addr_size () const; | |
502 | ||
503 | /* Return the offset size given in the compilation unit header for | |
504 | this CU. */ | |
505 | int offset_size () const; | |
506 | ||
507 | /* Return the DW_FORM_ref_addr size given in the compilation unit | |
508 | header for this CU. */ | |
509 | int ref_addr_size () const; | |
510 | ||
09ba997f TT |
511 | /* Return DWARF version number of this CU. */ |
512 | short version () const | |
513 | { | |
514 | return dwarf_version; | |
515 | } | |
197400e8 TT |
516 | |
517 | /* A type unit group has a per_cu object that is recognized by | |
518 | having no section. */ | |
519 | bool type_unit_group_p () const | |
520 | { | |
521 | return section == nullptr; | |
522 | } | |
cd4fb1b2 SM |
523 | }; |
524 | ||
525 | /* Entry in the signatured_types hash table. */ | |
526 | ||
527 | struct signatured_type | |
528 | { | |
529 | /* The "per_cu" object of this type. | |
530 | This struct is used iff per_cu.is_debug_types. | |
531 | N.B.: This is the first member so that it's easy to convert pointers | |
532 | between them. */ | |
533 | struct dwarf2_per_cu_data per_cu; | |
534 | ||
535 | /* The type's signature. */ | |
536 | ULONGEST signature; | |
537 | ||
538 | /* Offset in the TU of the type's DIE, as read from the TU header. | |
539 | If this TU is a DWO stub and the definition lives in a DWO file | |
540 | (specified by DW_AT_GNU_dwo_name), this value is unusable. */ | |
541 | cu_offset type_offset_in_tu; | |
542 | ||
543 | /* Offset in the section of the type's DIE. | |
544 | If the definition lives in a DWO file, this is the offset in the | |
545 | .debug_types.dwo section. | |
546 | The value is zero until the actual value is known. | |
547 | Zero is otherwise not a valid section offset. */ | |
548 | sect_offset type_offset_in_section; | |
549 | ||
550 | /* Type units are grouped by their DW_AT_stmt_list entry so that they | |
551 | can share them. This points to the containing symtab. */ | |
552 | struct type_unit_group *type_unit_group; | |
553 | ||
554 | /* The type. | |
555 | The first time we encounter this type we fully read it in and install it | |
556 | in the symbol tables. Subsequent times we only need the type. */ | |
557 | struct type *type; | |
558 | ||
559 | /* Containing DWO unit. | |
560 | This field is valid iff per_cu.reading_dwo_directly. */ | |
561 | struct dwo_unit *dwo_unit; | |
562 | }; | |
563 | ||
c4973306 SM |
564 | /* Open the separate '.dwz' debug file, if needed. Return NULL if |
565 | there is no .gnu_debugaltlink section in the file. Error if there | |
566 | is such a section but the file cannot be found. */ | |
567 | ||
c3699833 | 568 | extern dwz_file *dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd); |
c4973306 | 569 | |
8cb5117c SM |
570 | /* Return the type of the DIE at DIE_OFFSET in the CU named by |
571 | PER_CU. */ | |
572 | ||
573 | struct type *dwarf2_get_die_type (cu_offset die_offset, | |
574 | struct dwarf2_per_cu_data *per_cu); | |
575 | ||
450a1bfc SM |
576 | /* Given an index in .debug_addr, fetch the value. |
577 | NOTE: This can be called during dwarf expression evaluation, | |
578 | long after the debug information has been read, and thus per_cu->cu | |
579 | may no longer exist. */ | |
580 | ||
581 | CORE_ADDR dwarf2_read_addr_index (dwarf2_per_cu_data *per_cu, | |
82ca3f51 | 582 | dwarf2_per_objfile *dwarf2_per_objfile, |
450a1bfc SM |
583 | unsigned int addr_index); |
584 | ||
d4c9a4f8 SM |
585 | /* Return DWARF block referenced by DW_AT_location of DIE at SECT_OFF at PER_CU. |
586 | Returned value is intended for DW_OP_call*. Returned | |
587 | dwarf2_locexpr_baton->data has lifetime of | |
588 | PER_CU->DWARF2_PER_OBJFILE->OBJFILE. */ | |
589 | ||
590 | struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_sect_off | |
591 | (sect_offset sect_off, dwarf2_per_cu_data *per_cu, | |
592 | CORE_ADDR (*get_frame_pc) (void *baton), | |
593 | void *baton, bool resolve_abstract_p = false); | |
594 | ||
595 | /* Like dwarf2_fetch_die_loc_sect_off, but take a CU | |
596 | offset. */ | |
597 | ||
598 | struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_cu_off | |
599 | (cu_offset offset_in_cu, dwarf2_per_cu_data *per_cu, | |
600 | CORE_ADDR (*get_frame_pc) (void *baton), | |
601 | void *baton); | |
602 | ||
603 | /* If the DIE at SECT_OFF in PER_CU has a DW_AT_const_value, return a | |
604 | pointer to the constant bytes and set LEN to the length of the | |
605 | data. If memory is needed, allocate it on OBSTACK. If the DIE | |
606 | does not have a DW_AT_const_value, return NULL. */ | |
607 | ||
608 | extern const gdb_byte *dwarf2_fetch_constant_bytes | |
609 | (sect_offset sect_off, dwarf2_per_cu_data *per_cu, obstack *obstack, | |
610 | LONGEST *len); | |
611 | ||
612 | /* Return the type of the die at SECT_OFF in PER_CU. Return NULL if no | |
613 | valid type for this die is found. */ | |
614 | ||
615 | struct type *dwarf2_fetch_die_type_sect_off | |
616 | (sect_offset sect_off, dwarf2_per_cu_data *per_cu); | |
617 | ||
8fdd972c TT |
618 | /* When non-zero, dump line number entries as they are read in. */ |
619 | extern unsigned int dwarf_line_debug; | |
620 | ||
cd4fb1b2 | 621 | #endif /* DWARF2READ_H */ |