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