xref: /netbsd/external/gpl3/gdb/dist/gdb/dwarf2/die.h (revision 1424dfb3)
1*1424dfb3Schristos /* DWARF DIEs
2*1424dfb3Schristos 
3*1424dfb3Schristos    Copyright (C) 2003-2020 Free Software Foundation, Inc.
4*1424dfb3Schristos 
5*1424dfb3Schristos    This file is part of GDB.
6*1424dfb3Schristos 
7*1424dfb3Schristos    This program is free software; you can redistribute it and/or modify
8*1424dfb3Schristos    it under the terms of the GNU General Public License as published by
9*1424dfb3Schristos    the Free Software Foundation; either version 3 of the License, or
10*1424dfb3Schristos    (at your option) any later version.
11*1424dfb3Schristos 
12*1424dfb3Schristos    This program is distributed in the hope that it will be useful,
13*1424dfb3Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*1424dfb3Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*1424dfb3Schristos    GNU General Public License for more details.
16*1424dfb3Schristos 
17*1424dfb3Schristos    You should have received a copy of the GNU General Public License
18*1424dfb3Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19*1424dfb3Schristos 
20*1424dfb3Schristos #ifndef GDB_DWARF2_DIE_H
21*1424dfb3Schristos #define GDB_DWARF2_DIE_H
22*1424dfb3Schristos 
23*1424dfb3Schristos /* This data structure holds a complete die structure.  */
24*1424dfb3Schristos struct die_info
25*1424dfb3Schristos {
26*1424dfb3Schristos   /* Return the named attribute or NULL if not there, but do not
27*1424dfb3Schristos      follow DW_AT_specification, etc.  */
attrdie_info28*1424dfb3Schristos   struct attribute *attr (dwarf_attribute name)
29*1424dfb3Schristos   {
30*1424dfb3Schristos     for (unsigned i = 0; i < num_attrs; ++i)
31*1424dfb3Schristos       if (attrs[i].name == name)
32*1424dfb3Schristos 	return &attrs[i];
33*1424dfb3Schristos     return NULL;
34*1424dfb3Schristos   }
35*1424dfb3Schristos 
36*1424dfb3Schristos   /* Return the address base of the compile unit, which, if exists, is
37*1424dfb3Schristos      stored either at the attribute DW_AT_GNU_addr_base, or
38*1424dfb3Schristos      DW_AT_addr_base.  */
addr_basedie_info39*1424dfb3Schristos   gdb::optional<ULONGEST> addr_base ()
40*1424dfb3Schristos   {
41*1424dfb3Schristos     for (unsigned i = 0; i < num_attrs; ++i)
42*1424dfb3Schristos       if (attrs[i].name == DW_AT_addr_base
43*1424dfb3Schristos 	  || attrs[i].name == DW_AT_GNU_addr_base)
44*1424dfb3Schristos 	{
45*1424dfb3Schristos 	  /* If both exist, just use the first one.  */
46*1424dfb3Schristos 	  return DW_UNSND (&attrs[i]);
47*1424dfb3Schristos 	}
48*1424dfb3Schristos     return gdb::optional<ULONGEST> ();
49*1424dfb3Schristos   }
50*1424dfb3Schristos 
51*1424dfb3Schristos   /* Return range lists base of the compile unit, which, if exists, is
52*1424dfb3Schristos      stored either at the attribute DW_AT_rnglists_base or
53*1424dfb3Schristos      DW_AT_GNU_ranges_base.  */
ranges_basedie_info54*1424dfb3Schristos   ULONGEST ranges_base ()
55*1424dfb3Schristos   {
56*1424dfb3Schristos     for (unsigned i = 0; i < num_attrs; ++i)
57*1424dfb3Schristos       if (attrs[i].name == DW_AT_rnglists_base
58*1424dfb3Schristos 	  || attrs[i].name == DW_AT_GNU_ranges_base)
59*1424dfb3Schristos 	{
60*1424dfb3Schristos 	  /* If both exist, just use the first one.  */
61*1424dfb3Schristos 	  return DW_UNSND (&attrs[i]);
62*1424dfb3Schristos 	}
63*1424dfb3Schristos     return 0;
64*1424dfb3Schristos   }
65*1424dfb3Schristos 
66*1424dfb3Schristos 
67*1424dfb3Schristos   /* DWARF-2 tag for this DIE.  */
68*1424dfb3Schristos   ENUM_BITFIELD(dwarf_tag) tag : 16;
69*1424dfb3Schristos 
70*1424dfb3Schristos   /* Number of attributes */
71*1424dfb3Schristos   unsigned char num_attrs;
72*1424dfb3Schristos 
73*1424dfb3Schristos   /* True if we're presently building the full type name for the
74*1424dfb3Schristos      type derived from this DIE.  */
75*1424dfb3Schristos   unsigned char building_fullname : 1;
76*1424dfb3Schristos 
77*1424dfb3Schristos   /* True if this die is in process.  PR 16581.  */
78*1424dfb3Schristos   unsigned char in_process : 1;
79*1424dfb3Schristos 
80*1424dfb3Schristos   /* True if this DIE has children.  */
81*1424dfb3Schristos   unsigned char has_children : 1;
82*1424dfb3Schristos 
83*1424dfb3Schristos   /* Abbrev number */
84*1424dfb3Schristos   unsigned int abbrev;
85*1424dfb3Schristos 
86*1424dfb3Schristos   /* Offset in .debug_info or .debug_types section.  */
87*1424dfb3Schristos   sect_offset sect_off;
88*1424dfb3Schristos 
89*1424dfb3Schristos   /* The dies in a compilation unit form an n-ary tree.  PARENT
90*1424dfb3Schristos      points to this die's parent; CHILD points to the first child of
91*1424dfb3Schristos      this node; and all the children of a given node are chained
92*1424dfb3Schristos      together via their SIBLING fields.  */
93*1424dfb3Schristos   struct die_info *child;	/* Its first child, if any.  */
94*1424dfb3Schristos   struct die_info *sibling;	/* Its next sibling, if any.  */
95*1424dfb3Schristos   struct die_info *parent;	/* Its parent, if any.  */
96*1424dfb3Schristos 
97*1424dfb3Schristos   /* An array of attributes, with NUM_ATTRS elements.  There may be
98*1424dfb3Schristos      zero, but it's not common and zero-sized arrays are not
99*1424dfb3Schristos      sufficiently portable C.  */
100*1424dfb3Schristos   struct attribute attrs[1];
101*1424dfb3Schristos };
102*1424dfb3Schristos 
103*1424dfb3Schristos #endif /* GDB_DWARF2_DIE_H */
104