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