Change two more functions to be methods on die_info
[deliverable/binutils-gdb.git] / gdb / dwarf2 / die.h
1 /* DWARF DIEs
2
3 Copyright (C) 2003-2020 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 GDB_DWARF2_DIE_H
21 #define GDB_DWARF2_DIE_H
22
23 /* This data structure holds a complete die structure. */
24 struct die_info
25 {
26 /* Return the named attribute or NULL if not there, but do not
27 follow DW_AT_specification, etc. */
28 struct attribute *attr (dwarf_attribute name)
29 {
30 for (unsigned i = 0; i < num_attrs; ++i)
31 if (attrs[i].name == name)
32 return &attrs[i];
33 return NULL;
34 }
35
36 /* Return the address base of the compile unit, which, if exists, is
37 stored either at the attribute DW_AT_GNU_addr_base, or
38 DW_AT_addr_base. */
39 gdb::optional<ULONGEST> addr_base ()
40 {
41 struct attribute *attr = this->attr (DW_AT_addr_base);
42 if (attr == nullptr)
43 attr = this->attr (DW_AT_GNU_addr_base);
44 if (attr == nullptr)
45 return gdb::optional<ULONGEST> ();
46 return DW_UNSND (attr);
47 }
48
49 /* Return range lists base of the compile unit, which, if exists, is
50 stored either at the attribute DW_AT_rnglists_base or
51 DW_AT_GNU_ranges_base. */
52 ULONGEST ranges_base ()
53 {
54 struct attribute *attr = this->attr (DW_AT_rnglists_base);
55 if (attr == nullptr)
56 attr = this->attr (DW_AT_GNU_ranges_base);
57 if (attr == nullptr)
58 return 0;
59 return DW_UNSND (attr);
60 }
61
62
63 /* DWARF-2 tag for this DIE. */
64 ENUM_BITFIELD(dwarf_tag) tag : 16;
65
66 /* Number of attributes */
67 unsigned char num_attrs;
68
69 /* True if we're presently building the full type name for the
70 type derived from this DIE. */
71 unsigned char building_fullname : 1;
72
73 /* True if this die is in process. PR 16581. */
74 unsigned char in_process : 1;
75
76 /* True if this DIE has children. */
77 unsigned char has_children : 1;
78
79 /* Abbrev number */
80 unsigned int abbrev;
81
82 /* Offset in .debug_info or .debug_types section. */
83 sect_offset sect_off;
84
85 /* The dies in a compilation unit form an n-ary tree. PARENT
86 points to this die's parent; CHILD points to the first child of
87 this node; and all the children of a given node are chained
88 together via their SIBLING fields. */
89 struct die_info *child; /* Its first child, if any. */
90 struct die_info *sibling; /* Its next sibling, if any. */
91 struct die_info *parent; /* Its parent, if any. */
92
93 /* An array of attributes, with NUM_ATTRS elements. There may be
94 zero, but it's not common and zero-sized arrays are not
95 sufficiently portable C. */
96 struct attribute attrs[1];
97 };
98
99 #endif /* GDB_DWARF2_DIE_H */
This page took 0.040984 seconds and 5 git commands to generate.