]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/dwarf2/read.h
Allocate dwarf2_per_cu_data with 'new'
[thirdparty/binutils-gdb.git] / gdb / dwarf2 / read.h
1 /* DWARF 2 debugging format support for GDB.
2
3 Copyright (C) 1994-2021 Free Software Foundation, Inc.
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
23 #include <queue>
24 #include <unordered_map>
25 #include "dwarf2/comp-unit.h"
26 #include "dwarf2/index-cache.h"
27 #include "dwarf2/section.h"
28 #include "filename-seen-cache.h"
29 #include "gdb_obstack.h"
30 #include "gdbsupport/hash_enum.h"
31 #include "gdbsupport/function-view.h"
32 #include "psympriv.h"
33
34 /* Hold 'maintenance (set|show) dwarf' commands. */
35 extern struct cmd_list_element *set_dwarf_cmdlist;
36 extern struct cmd_list_element *show_dwarf_cmdlist;
37
38 struct tu_stats
39 {
40 int nr_uniq_abbrev_tables;
41 int nr_symtabs;
42 int nr_symtab_sharers;
43 int nr_stmt_less_type_units;
44 int nr_all_type_units_reallocs;
45 };
46
47 struct dwarf2_cu;
48 struct dwarf2_debug_sections;
49 struct dwarf2_per_cu_data;
50 struct mapped_index;
51 struct mapped_debug_names;
52 struct signatured_type;
53 struct type_unit_group;
54
55 /* One item on the queue of compilation units to read in full symbols
56 for. */
57 struct dwarf2_queue_item
58 {
59 dwarf2_queue_item (dwarf2_per_cu_data *cu, dwarf2_per_objfile *per_objfile,
60 enum language lang)
61 : per_cu (cu),
62 per_objfile (per_objfile),
63 pretend_language (lang)
64 {
65 }
66
67 ~dwarf2_queue_item ();
68
69 DISABLE_COPY_AND_ASSIGN (dwarf2_queue_item);
70
71 dwarf2_per_cu_data *per_cu;
72 dwarf2_per_objfile *per_objfile;
73 enum language pretend_language;
74 };
75
76 /* Some DWARF data can be shared across objfiles who share the same BFD,
77 this data is stored in this object.
78
79 Two dwarf2_per_objfile objects representing objfiles sharing the same BFD
80 will point to the same instance of dwarf2_per_bfd, unless the BFD requires
81 relocation. */
82
83 struct dwarf2_per_bfd
84 {
85 /* Construct a dwarf2_per_bfd for OBFD. NAMES points to the
86 dwarf2 section names, or is NULL if the standard ELF names are
87 used. CAN_COPY is true for formats where symbol
88 interposition is possible and so symbol values must follow copy
89 relocation rules. */
90 dwarf2_per_bfd (bfd *obfd, const dwarf2_debug_sections *names, bool can_copy);
91
92 ~dwarf2_per_bfd ();
93
94 DISABLE_COPY_AND_ASSIGN (dwarf2_per_bfd);
95
96 /* Return the CU/TU given its index.
97
98 This is intended for loops like:
99
100 for (i = 0; i < (dwarf2_per_bfd->n_comp_units
101 + dwarf2_per_bfd->n_type_units); ++i)
102 {
103 dwarf2_per_cu_data *per_cu = dwarf2_per_bfd->get_cutu (i);
104
105 ...;
106 }
107 */
108 dwarf2_per_cu_data *get_cutu (int index);
109
110 /* Return the CU given its index.
111 This differs from get_cutu in that it's for when you know INDEX refers to a
112 CU. */
113 dwarf2_per_cu_data *get_cu (int index);
114
115 /* Return the TU given its index.
116 This differs from get_cutu in that it's for when you know INDEX refers to a
117 TU. */
118 signatured_type *get_tu (int index);
119
120 /* A convenience function to allocate a dwarf2_per_cu_data. The
121 returned object has its "index" field set properly. The object
122 is allocated on the dwarf2_per_bfd obstack. */
123 std::unique_ptr<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
127 is allocated on the dwarf2_per_bfd obstack. */
128 std::unique_ptr<signatured_type> allocate_signatured_type ();
129
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
135 private:
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
142 public:
143 /* The corresponding BFD. */
144 bfd *obfd;
145
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
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 {};
159 dwarf2_section_info str_offsets {};
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
170 std::vector<dwarf2_section_info> types;
171
172 /* Table of all the compilation units. This is used to locate
173 the target compilation unit of a particular reference. */
174 std::vector<std::unique_ptr<dwarf2_per_cu_data>> all_comp_units;
175
176 /* The .debug_types-related CUs (TUs). */
177 std::vector<std::unique_ptr<signatured_type>> all_type_units;
178
179 /* Table of struct type_unit_group objects.
180 The hash key is the DW_AT_stmt_list value. */
181 htab_up type_unit_groups;
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. */
185 htab_up signatured_types;
186
187 /* Type unit statistics, to see how well the scaling improvements
188 are doing. */
189 struct tu_stats tu_stats {};
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. */
193 htab_up dwo_files;
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. */
199 std::unique_ptr<struct dwp_file> dwp_file;
200
201 /* The shared '.dwz' file, if one exists. This is used when the
202 original data was compressed using 'dwz -m'. */
203 std::unique_ptr<struct dwz_file> dwz_file;
204
205 /* Whether copy relocations are supported by this object format. */
206 bool can_copy;
207
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. */
217 std::unique_ptr<mapped_index> index_table;
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. */
229 htab_up quick_file_names_table;
230
231 /* Set during partial symbol reading, to prevent queueing of full
232 symbols. */
233 bool reading_partial_symbols = false;
234
235 /* The CUs we recently read. */
236 std::vector<dwarf2_per_cu_data *> just_read_cus;
237
238 /* If we loaded the index from an external file, this contains the
239 resources associated to the open file, memory mapping, etc. */
240 std::unique_ptr<index_cache_resource> index_cache_res;
241
242 /* Mapping from abstract origin DIE to concrete DIEs that reference it as
243 DW_AT_abstract_origin. */
244 std::unordered_map<sect_offset, std::vector<sect_offset>,
245 gdb::hash_enum<sect_offset>>
246 abstract_to_concrete;
247
248 /* CUs that are queued to be read. */
249 gdb::optional<std::queue<dwarf2_queue_item>> queue;
250
251 /* We keep a separate reference to the partial symtabs, in case we
252 are sharing them between objfiles. This is only set after
253 partial symbols have been read the first time. */
254 std::shared_ptr<psymtab_storage> partial_symtabs;
255
256 /* The address map that is used by the DWARF index code. */
257 struct addrmap *index_addrmap = nullptr;
258
259 private:
260
261 /* The total number of per_cu and signatured_type objects that have
262 been created so far for this reader. */
263 size_t m_num_psymtabs = 0;
264 };
265
266 /* This is the per-objfile data associated with a type_unit_group. */
267
268 struct type_unit_group_unshareable
269 {
270 /* The compunit symtab.
271 Type units in a group needn't all be defined in the same source file,
272 so we create an essentially anonymous symtab as the compunit symtab. */
273 struct compunit_symtab *compunit_symtab = nullptr;
274
275 /* The number of symtabs from the line header.
276 The value here must match line_header.num_file_names. */
277 unsigned int num_symtabs = 0;
278
279 /* The symbol tables for this TU (obtained from the files listed in
280 DW_AT_stmt_list).
281 WARNING: The order of entries here must match the order of entries
282 in the line header. After the first TU using this type_unit_group, the
283 line header for the subsequent TUs is recreated from this. This is done
284 because we need to use the same symtabs for each TU using the same
285 DW_AT_stmt_list value. Also note that symtabs may be repeated here,
286 there's no guarantee the line header doesn't have duplicate entries. */
287 struct symtab **symtabs = nullptr;
288 };
289
290 /* Collection of data recorded per objfile.
291 This hangs off of dwarf2_objfile_data_key.
292
293 Some DWARF data cannot (currently) be shared across objfiles. Such
294 data is stored in this object. */
295
296 struct dwarf2_per_objfile
297 {
298 dwarf2_per_objfile (struct objfile *objfile, dwarf2_per_bfd *per_bfd)
299 : objfile (objfile), per_bfd (per_bfd)
300 {}
301
302 ~dwarf2_per_objfile ();
303
304 /* Return pointer to string at .debug_line_str offset as read from BUF.
305 BUF is assumed to be in a compilation unit described by CU_HEADER.
306 Return *BYTES_READ_PTR count of bytes read from BUF. */
307 const char *read_line_string (const gdb_byte *buf,
308 const struct comp_unit_head *cu_header,
309 unsigned int *bytes_read_ptr);
310
311 /* Resize the M_SYMTABS vector to the needed size (the number of partial
312 symtabs allocated by the per-bfd). */
313 void resize_symtabs ()
314 {
315 /* The symtabs vector should only grow, not shrink. */
316 gdb_assert (per_bfd->num_psymtabs () >= m_symtabs.size ());
317
318 m_symtabs.resize (per_bfd->num_psymtabs ());
319 }
320
321 /* Return true if the symtab corresponding to PER_CU has been set,
322 false otherwise. */
323 bool symtab_set_p (const dwarf2_per_cu_data *per_cu) const;
324
325 /* Return the compunit_symtab associated to PER_CU, if it has been created. */
326 compunit_symtab *get_symtab (const dwarf2_per_cu_data *per_cu) const;
327
328 /* Set the compunit_symtab associated to PER_CU. */
329 void set_symtab (const dwarf2_per_cu_data *per_cu, compunit_symtab *symtab);
330
331 /* Get the type_unit_group_unshareable corresponding to TU_GROUP. If one
332 does not exist, create it. */
333 type_unit_group_unshareable *get_type_unit_group_unshareable
334 (type_unit_group *tu_group);
335
336 struct type *get_type_for_signatured_type (signatured_type *sig_type) const;
337
338 void set_type_for_signatured_type (signatured_type *sig_type,
339 struct type *type);
340
341 /* Find an integer type SIZE_IN_BYTES bytes in size and return it.
342 UNSIGNED_P controls if the integer is unsigned or not. */
343 struct type *int_type (int size_in_bytes, bool unsigned_p) const;
344
345 /* Get the dwarf2_cu matching PER_CU for this objfile. */
346 dwarf2_cu *get_cu (dwarf2_per_cu_data *per_cu);
347
348 /* Set the dwarf2_cu matching PER_CU for this objfile. */
349 void set_cu (dwarf2_per_cu_data *per_cu, dwarf2_cu *cu);
350
351 /* Remove/free the dwarf2_cu matching PER_CU for this objfile. */
352 void remove_cu (dwarf2_per_cu_data *per_cu);
353
354 /* Free all cached compilation units. */
355 void remove_all_cus ();
356
357 /* Increase the age counter on each CU compilation unit and free
358 any that are too old. */
359 void age_comp_units ();
360
361 /* Back link. */
362 struct objfile *objfile;
363
364 /* Pointer to the data that is (possibly) shared between this objfile and
365 other objfiles backed by the same BFD. */
366 struct dwarf2_per_bfd *per_bfd;
367
368 /* Table mapping type DIEs to their struct type *.
369 This is nullptr if not allocated yet.
370 The mapping is done via (CU/TU + DIE offset) -> type. */
371 htab_up die_type_hash;
372
373 /* Table containing line_header indexed by offset and offset_in_dwz. */
374 htab_up line_header_hash;
375
376 private:
377 /* Hold the corresponding compunit_symtab for each CU or TU. This
378 is indexed by dwarf2_per_cu_data::index. A NULL value means
379 that the CU/TU has not been expanded yet. */
380 std::vector<compunit_symtab *> m_symtabs;
381
382 /* Map from a type unit group to the corresponding unshared
383 structure. */
384 typedef std::unique_ptr<type_unit_group_unshareable>
385 type_unit_group_unshareable_up;
386
387 std::unordered_map<type_unit_group *, type_unit_group_unshareable_up>
388 m_type_units;
389
390 /* Map from signatured types to the corresponding struct type. */
391 std::unordered_map<signatured_type *, struct type *> m_type_map;
392
393 /* Map from the objfile-independent dwarf2_per_cu_data instances to the
394 corresponding objfile-dependent dwarf2_cu instances. */
395 std::unordered_map<dwarf2_per_cu_data *, dwarf2_cu *> m_dwarf2_cus;
396 };
397
398 /* Get the dwarf2_per_objfile associated to OBJFILE. */
399
400 dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile);
401
402 /* A partial symtab specialized for DWARF. */
403 struct dwarf2_psymtab : public partial_symtab
404 {
405 dwarf2_psymtab (const char *filename,
406 psymtab_storage *partial_symtabs,
407 objfile_per_bfd_storage *objfile_per_bfd,
408 dwarf2_per_cu_data *per_cu)
409 : partial_symtab (filename, partial_symtabs, objfile_per_bfd, 0),
410 per_cu_data (per_cu)
411 {
412 }
413
414 void read_symtab (struct objfile *) override;
415 void expand_psymtab (struct objfile *) override;
416 bool readin_p (struct objfile *) const override;
417 compunit_symtab *get_compunit_symtab (struct objfile *) const override;
418
419 struct dwarf2_per_cu_data *per_cu_data;
420 };
421
422 /* Persistent data held for a compilation unit, even when not
423 processing it. We put a pointer to this structure in the
424 psymtab. */
425
426 struct dwarf2_per_cu_data
427 {
428 dwarf2_per_cu_data ()
429 : queued (false),
430 load_all_dies (false),
431 is_debug_types (false),
432 is_dwz (false),
433 reading_dwo_directly (false),
434 tu_read (false),
435 m_header_read_in (false),
436 unit_type {},
437 lang (language_unknown)
438 {
439 }
440
441 /* The start offset and length of this compilation unit.
442 NOTE: Unlike comp_unit_head.length, this length includes
443 initial_length_size.
444 If the DIE refers to a DWO file, this is always of the original die,
445 not the DWO file. */
446 sect_offset sect_off {};
447 unsigned int length = 0;
448
449 /* DWARF standard version this data has been read from (such as 4 or 5). */
450 unsigned char dwarf_version = 0;
451
452 /* Flag indicating this compilation unit will be read in before
453 any of the current compilation units are processed. */
454 unsigned int queued : 1;
455
456 /* This flag will be set when reading partial DIEs if we need to load
457 absolutely all DIEs for this compilation unit, instead of just the ones
458 we think are interesting. It gets set if we look for a DIE in the
459 hash table and don't find it. */
460 unsigned int load_all_dies : 1;
461
462 /* Non-zero if this CU is from .debug_types.
463 Struct dwarf2_per_cu_data is contained in struct signatured_type iff
464 this is non-zero. */
465 unsigned int is_debug_types : 1;
466
467 /* Non-zero if this CU is from the .dwz file. */
468 unsigned int is_dwz : 1;
469
470 /* Non-zero if reading a TU directly from a DWO file, bypassing the stub.
471 This flag is only valid if is_debug_types is true.
472 We can't read a CU directly from a DWO file: There are required
473 attributes in the stub. */
474 unsigned int reading_dwo_directly : 1;
475
476 /* Non-zero if the TU has been read.
477 This is used to assist the "Stay in DWO Optimization" for Fission:
478 When reading a DWO, it's faster to read TUs from the DWO instead of
479 fetching them from random other DWOs (due to comdat folding).
480 If the TU has already been read, the optimization is unnecessary
481 (and unwise - we don't want to change where gdb thinks the TU lives
482 "midflight").
483 This flag is only valid if is_debug_types is true. */
484 unsigned int tu_read : 1;
485
486 /* True if HEADER has been read in.
487
488 Don't access this field directly. It should be private, but we can't make
489 it private at the moment. */
490 mutable bool m_header_read_in : 1;
491
492 /* The unit type of this CU. */
493 ENUM_BITFIELD (dwarf_unit_type) unit_type : 8;
494
495 /* The language of this CU. */
496 ENUM_BITFIELD (language) lang : LANGUAGE_BITS;
497
498 /* Our index in the unshared "symtabs" vector. */
499 unsigned index = 0;
500
501 /* The section this CU/TU lives in.
502 If the DIE refers to a DWO file, this is always the original die,
503 not the DWO file. */
504 struct dwarf2_section_info *section = nullptr;
505
506 /* Backlink to the owner of this. */
507 dwarf2_per_bfd *per_bfd = nullptr;
508
509 /* DWARF header of this CU. Note that dwarf2_cu reads its own version of the
510 header, which may differ from this one, since it may pass rcuh_kind::TYPE
511 to read_comp_unit_head, whereas for dwarf2_per_cu_data we always pass
512 rcuh_kind::COMPILE.
513
514 Don't access this field directly, use the get_header method instead. It
515 should be private, but we can't make it private at the moment. */
516 mutable comp_unit_head m_header {};
517
518 /* When dwarf2_per_bfd::using_index is true, the 'quick' field
519 is active. Otherwise, the 'psymtab' field is active. */
520 union
521 {
522 /* The partial symbol table associated with this compilation unit,
523 or NULL for unread partial units. */
524 dwarf2_psymtab *psymtab;
525
526 /* Data needed by the "quick" functions. */
527 struct dwarf2_per_cu_quick_data *quick;
528 } v {};
529
530 /* The CUs we import using DW_TAG_imported_unit. This is filled in
531 while reading psymtabs, used to compute the psymtab dependencies,
532 and then cleared. Then it is filled in again while reading full
533 symbols, and only deleted when the objfile is destroyed.
534
535 This is also used to work around a difference between the way gold
536 generates .gdb_index version <=7 and the way gdb does. Arguably this
537 is a gold bug. For symbols coming from TUs, gold records in the index
538 the CU that includes the TU instead of the TU itself. This breaks
539 dw2_lookup_symbol: It assumes that if the index says symbol X lives
540 in CU/TU Y, then one need only expand Y and a subsequent lookup in Y
541 will find X. Alas TUs live in their own symtab, so after expanding CU Y
542 we need to look in TU Z to find X. Fortunately, this is akin to
543 DW_TAG_imported_unit, so we just use the same mechanism: For
544 .gdb_index version <=7 this also records the TUs that the CU referred
545 to. Concurrently with this change gdb was modified to emit version 8
546 indices so we only pay a price for gold generated indices.
547 http://sourceware.org/bugzilla/show_bug.cgi?id=15021.
548
549 This currently needs to be a public member due to how
550 dwarf2_per_cu_data is allocated and used. Ideally in future things
551 could be refactored to make this private. Until then please try to
552 avoid direct access to this member, and instead use the helper
553 functions above. */
554 std::vector <dwarf2_per_cu_data *> *imported_symtabs = nullptr;
555
556 /* Return true of IMPORTED_SYMTABS is empty or not yet allocated. */
557 bool imported_symtabs_empty () const
558 {
559 return (imported_symtabs == nullptr || imported_symtabs->empty ());
560 }
561
562 /* Push P to the back of IMPORTED_SYMTABS, allocated IMPORTED_SYMTABS
563 first if required. */
564 void imported_symtabs_push (dwarf2_per_cu_data *p)
565 {
566 if (imported_symtabs == nullptr)
567 imported_symtabs = new std::vector <dwarf2_per_cu_data *>;
568 imported_symtabs->push_back (p);
569 }
570
571 /* Return the size of IMPORTED_SYMTABS if it is allocated, otherwise
572 return 0. */
573 size_t imported_symtabs_size () const
574 {
575 if (imported_symtabs == nullptr)
576 return 0;
577 return imported_symtabs->size ();
578 }
579
580 /* Delete IMPORTED_SYMTABS and set the pointer back to nullptr. */
581 void imported_symtabs_free ()
582 {
583 delete imported_symtabs;
584 imported_symtabs = nullptr;
585 }
586
587 /* Get the header of this per_cu, reading it if necessary. */
588 const comp_unit_head *get_header () const;
589
590 /* Return the address size given in the compilation unit header for
591 this CU. */
592 int addr_size () const;
593
594 /* Return the offset size given in the compilation unit header for
595 this CU. */
596 int offset_size () const;
597
598 /* Return the DW_FORM_ref_addr size given in the compilation unit
599 header for this CU. */
600 int ref_addr_size () const;
601
602 /* Return DWARF version number of this CU. */
603 short version () const
604 {
605 return dwarf_version;
606 }
607
608 /* A type unit group has a per_cu object that is recognized by
609 having no section. */
610 bool type_unit_group_p () const
611 {
612 return section == nullptr;
613 }
614 };
615
616 /* Entry in the signatured_types hash table. */
617
618 struct signatured_type : public dwarf2_per_cu_data
619 {
620 /* The type's signature. */
621 ULONGEST signature = 0;
622
623 /* Offset in the TU of the type's DIE, as read from the TU header.
624 If this TU is a DWO stub and the definition lives in a DWO file
625 (specified by DW_AT_GNU_dwo_name), this value is unusable. */
626 cu_offset type_offset_in_tu {};
627
628 /* Offset in the section of the type's DIE.
629 If the definition lives in a DWO file, this is the offset in the
630 .debug_types.dwo section.
631 The value is zero until the actual value is known.
632 Zero is otherwise not a valid section offset. */
633 sect_offset type_offset_in_section {};
634
635 /* Type units are grouped by their DW_AT_stmt_list entry so that they
636 can share them. This points to the containing symtab. */
637 struct type_unit_group *type_unit_group = nullptr;
638
639 /* Containing DWO unit.
640 This field is valid iff per_cu.reading_dwo_directly. */
641 struct dwo_unit *dwo_unit = nullptr;
642 };
643
644 /* Return the type of the DIE at DIE_OFFSET in the CU named by
645 PER_CU. */
646
647 struct type *dwarf2_get_die_type (cu_offset die_offset,
648 dwarf2_per_cu_data *per_cu,
649 dwarf2_per_objfile *per_objfile);
650
651 /* Given an index in .debug_addr, fetch the value.
652 NOTE: This can be called during dwarf expression evaluation,
653 long after the debug information has been read, and thus per_cu->cu
654 may no longer exist. */
655
656 CORE_ADDR dwarf2_read_addr_index (dwarf2_per_cu_data *per_cu,
657 dwarf2_per_objfile *per_objfile,
658 unsigned int addr_index);
659
660 /* Return DWARF block referenced by DW_AT_location of DIE at SECT_OFF at PER_CU.
661 Returned value is intended for DW_OP_call*. Returned
662 dwarf2_locexpr_baton->data has lifetime of
663 PER_CU->DWARF2_PER_OBJFILE->OBJFILE. */
664
665 struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_sect_off
666 (sect_offset sect_off, dwarf2_per_cu_data *per_cu,
667 dwarf2_per_objfile *per_objfile,
668 gdb::function_view<CORE_ADDR ()> get_frame_pc,
669 bool resolve_abstract_p = false);
670
671 /* Like dwarf2_fetch_die_loc_sect_off, but take a CU
672 offset. */
673
674 struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_cu_off
675 (cu_offset offset_in_cu, dwarf2_per_cu_data *per_cu,
676 dwarf2_per_objfile *per_objfile,
677 gdb::function_view<CORE_ADDR ()> get_frame_pc);
678
679 /* If the DIE at SECT_OFF in PER_CU has a DW_AT_const_value, return a
680 pointer to the constant bytes and set LEN to the length of the
681 data. If memory is needed, allocate it on OBSTACK. If the DIE
682 does not have a DW_AT_const_value, return NULL. */
683
684 extern const gdb_byte *dwarf2_fetch_constant_bytes
685 (sect_offset sect_off, dwarf2_per_cu_data *per_cu,
686 dwarf2_per_objfile *per_objfile, obstack *obstack,
687 LONGEST *len);
688
689 /* Return the type of the die at SECT_OFF in PER_CU. Return NULL if no
690 valid type for this die is found. */
691
692 struct type *dwarf2_fetch_die_type_sect_off
693 (sect_offset sect_off, dwarf2_per_cu_data *per_cu,
694 dwarf2_per_objfile *per_objfile);
695
696 /* When non-zero, dump line number entries as they are read in. */
697 extern unsigned int dwarf_line_debug;
698
699 /* Dwarf2 sections that can be accessed by dwarf2_get_section_info. */
700 enum dwarf2_section_enum {
701 DWARF2_DEBUG_FRAME,
702 DWARF2_EH_FRAME
703 };
704
705 extern void dwarf2_get_section_info (struct objfile *,
706 enum dwarf2_section_enum,
707 asection **, const gdb_byte **,
708 bfd_size_type *);
709
710 #endif /* DWARF2READ_H */