Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / dwarf2 / die.h
CommitLineData
c2d50fd0
TT
1/* DWARF DIEs
2
88b9d363 3 Copyright (C) 2003-2022 Free Software Foundation, Inc.
c2d50fd0
TT
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 GDB_DWARF2_DIE_H
21#define GDB_DWARF2_DIE_H
22
52c14d11
TT
23#include "complaints.h"
24
c2d50fd0
TT
25/* This data structure holds a complete die structure. */
26struct die_info
27{
052c8bb8
TT
28 /* Return the named attribute or NULL if not there, but do not
29 follow DW_AT_specification, etc. */
30 struct attribute *attr (dwarf_attribute name)
31 {
32 for (unsigned i = 0; i < num_attrs; ++i)
33 if (attrs[i].name == name)
34 return &attrs[i];
35 return NULL;
36 }
37
a39fdb41
TT
38 /* Return the address base of the compile unit, which, if exists, is
39 stored either at the attribute DW_AT_GNU_addr_base, or
40 DW_AT_addr_base. */
41 gdb::optional<ULONGEST> addr_base ()
42 {
eeb64781
TT
43 for (unsigned i = 0; i < num_attrs; ++i)
44 if (attrs[i].name == DW_AT_addr_base
52c14d11 45 || attrs[i].name == DW_AT_GNU_addr_base)
eeb64781 46 {
52c14d11
TT
47 if (attrs[i].form_is_unsigned ())
48 {
49 /* If both exist, just use the first one. */
50 return attrs[i].as_unsigned ();
51 }
52 complaint (_("address base attribute (offset %s) as wrong form"),
53 sect_offset_str (sect_off));
eeb64781
TT
54 }
55 return gdb::optional<ULONGEST> ();
a39fdb41
TT
56 }
57
2b0c7f41
SM
58 /* Return the base address of the compile unit into the .debug_ranges section,
59 which, if exists, is stored in the DW_AT_GNU_ranges_base attribute. This
60 value is only relevant in pre-DWARF 5 split-unit scenarios. */
61 ULONGEST gnu_ranges_base ()
a39fdb41 62 {
eeb64781 63 for (unsigned i = 0; i < num_attrs; ++i)
2b0c7f41 64 if (attrs[i].name == DW_AT_GNU_ranges_base)
eeb64781 65 {
52c14d11 66 if (attrs[i].form_is_unsigned ())
2b0c7f41
SM
67 return attrs[i].as_unsigned ();
68
69 complaint (_("ranges base attribute (offset %s) has wrong form"),
52c14d11 70 sect_offset_str (sect_off));
eeb64781 71 }
2b0c7f41 72
eeb64781 73 return 0;
a39fdb41
TT
74 }
75
2b0c7f41
SM
76 /* Return the rnglists base of the compile unit, which, if exists, is stored
77 in the DW_AT_rnglists_base attribute. */
78 ULONGEST rnglists_base ()
79 {
80 for (unsigned i = 0; i < num_attrs; ++i)
81 if (attrs[i].name == DW_AT_rnglists_base)
82 {
83 if (attrs[i].form_is_unsigned ())
84 return attrs[i].as_unsigned ();
85
86 complaint (_("rnglists base attribute (offset %s) has wrong form"),
87 sect_offset_str (sect_off));
88 }
89
90 return 0;
91 }
052c8bb8 92
c2d50fd0
TT
93 /* DWARF-2 tag for this DIE. */
94 ENUM_BITFIELD(dwarf_tag) tag : 16;
95
96 /* Number of attributes */
97 unsigned char num_attrs;
98
99 /* True if we're presently building the full type name for the
100 type derived from this DIE. */
101 unsigned char building_fullname : 1;
102
103 /* True if this die is in process. PR 16581. */
104 unsigned char in_process : 1;
105
106 /* True if this DIE has children. */
107 unsigned char has_children : 1;
108
109 /* Abbrev number */
110 unsigned int abbrev;
111
112 /* Offset in .debug_info or .debug_types section. */
113 sect_offset sect_off;
114
115 /* The dies in a compilation unit form an n-ary tree. PARENT
116 points to this die's parent; CHILD points to the first child of
117 this node; and all the children of a given node are chained
118 together via their SIBLING fields. */
119 struct die_info *child; /* Its first child, if any. */
120 struct die_info *sibling; /* Its next sibling, if any. */
121 struct die_info *parent; /* Its parent, if any. */
122
123 /* An array of attributes, with NUM_ATTRS elements. There may be
124 zero, but it's not common and zero-sized arrays are not
125 sufficiently portable C. */
126 struct attribute attrs[1];
127};
128
129#endif /* GDB_DWARF2_DIE_H */
This page took 0.181053 seconds and 4 git commands to generate.