3 Copyright (C) 2003-2021 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
20 #ifndef GDB_DWARF2_DIE_H
21 #define GDB_DWARF2_DIE_H
23 #include "complaints.h"
25 /* This data structure holds a complete die structure. */
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
)
32 for (unsigned i
= 0; i
< num_attrs
; ++i
)
33 if (attrs
[i
].name
== name
)
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
41 gdb::optional
<ULONGEST
> addr_base ()
43 for (unsigned i
= 0; i
< num_attrs
; ++i
)
44 if (attrs
[i
].name
== DW_AT_addr_base
45 || attrs
[i
].name
== DW_AT_GNU_addr_base
)
47 if (attrs
[i
].form_is_unsigned ())
49 /* If both exist, just use the first one. */
50 return attrs
[i
].as_unsigned ();
52 complaint (_("address base attribute (offset %s) as wrong form"),
53 sect_offset_str (sect_off
));
55 return gdb::optional
<ULONGEST
> ();
58 /* Return range lists base of the compile unit, which, if exists, is
59 stored either at the attribute DW_AT_rnglists_base or
60 DW_AT_GNU_ranges_base. */
61 ULONGEST
ranges_base ()
63 for (unsigned i
= 0; i
< num_attrs
; ++i
)
64 if (attrs
[i
].name
== DW_AT_rnglists_base
65 || attrs
[i
].name
== DW_AT_GNU_ranges_base
)
67 if (attrs
[i
].form_is_unsigned ())
69 /* If both exist, just use the first one. */
70 return attrs
[i
].as_unsigned ();
72 complaint (_("ranges base attribute (offset %s) as wrong form"),
73 sect_offset_str (sect_off
));
79 /* DWARF-2 tag for this DIE. */
80 ENUM_BITFIELD(dwarf_tag
) tag
: 16;
82 /* Number of attributes */
83 unsigned char num_attrs
;
85 /* True if we're presently building the full type name for the
86 type derived from this DIE. */
87 unsigned char building_fullname
: 1;
89 /* True if this die is in process. PR 16581. */
90 unsigned char in_process
: 1;
92 /* True if this DIE has children. */
93 unsigned char has_children
: 1;
98 /* Offset in .debug_info or .debug_types section. */
101 /* The dies in a compilation unit form an n-ary tree. PARENT
102 points to this die's parent; CHILD points to the first child of
103 this node; and all the children of a given node are chained
104 together via their SIBLING fields. */
105 struct die_info
*child
; /* Its first child, if any. */
106 struct die_info
*sibling
; /* Its next sibling, if any. */
107 struct die_info
*parent
; /* Its parent, if any. */
109 /* An array of attributes, with NUM_ATTRS elements. There may be
110 zero, but it's not common and zero-sized arrays are not
111 sufficiently portable C. */
112 struct attribute attrs
[1];
115 #endif /* GDB_DWARF2_DIE_H */