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