3 Copyright (C) 1994-2024 Free Software Foundation, Inc.
5 Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
6 Inc. with support from Florida State University (under contract
7 with the Ada Joint Program Office), and Silicon Graphics, Inc.
8 Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
9 based on Fred Fish's (Cygnus Support) implementation of DWARF 1
12 This file is part of GDB.
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 3 of the License, or
17 (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 #ifndef GDB_DWARF2_ABBREV_H
28 #define GDB_DWARF2_ABBREV_H
31 #include "gdbsupport/gdb_obstack.h"
32 #include "gdbsupport/unordered_set.h"
37 ENUM_BITFIELD(dwarf_attribute
) name
: 16;
38 ENUM_BITFIELD(dwarf_form
) form
: 16;
40 /* It is valid only if FORM is DW_FORM_implicit_const. */
41 LONGEST implicit_const
;
44 /* This data structure holds the information of an abbrev. */
47 /* Number identifying abbrev. */
50 ENUM_BITFIELD (dwarf_tag
) tag
: 16;
51 /* True if the DIE has children. */
54 unsigned short size_if_constant
;
55 unsigned short sibling_offset
;
56 /* Number of attributes. */
57 unsigned short num_attrs
;
58 /* An array of attribute descriptions, allocated using the struct
60 struct attr_abbrev attrs
[1];
64 typedef std::unique_ptr
<struct abbrev_table
> abbrev_table_up
;
66 /* Top level data structure to contain an abbreviation table.
68 In DWARF version 2, the description of the debugging information is
69 stored in a separate .debug_abbrev section. Before we read any
70 dies from a section we read in all abbreviations and install them
75 /* Read an abbrev table from the indicated section, at the given
76 offset. The caller is responsible for ensuring that the section
77 has already been read. */
79 static abbrev_table_up
read (struct dwarf2_section_info
*section
,
80 sect_offset sect_off
);
82 /* Look up an abbrev in the table.
83 Returns NULL if the abbrev is not found. */
85 const abbrev_info
*lookup_abbrev (unsigned int abbrev_number
) const
87 if (auto iter
= m_abbrevs
.find (abbrev_number
);
88 iter
!= m_abbrevs
.end ())
94 /* Where the abbrev table came from.
95 This is used as a sanity check when the table is used. */
96 const sect_offset sect_off
;
98 struct dwarf2_section_info
*section
;
102 abbrev_table (sect_offset off
, struct dwarf2_section_info
*sect
)
107 DISABLE_COPY_AND_ASSIGN (abbrev_table
);
109 /* Add an abbreviation to the table. */
110 void add_abbrev (const abbrev_info
*abbrev
)
111 { m_abbrevs
.emplace (abbrev
); }
113 struct abbrev_info_number_eq
115 using is_transparent
= void;
117 bool operator() (unsigned int number
,
118 const abbrev_info
*abbrev
) const noexcept
119 { return number
== abbrev
->number
; }
121 bool operator() (const abbrev_info
*lhs
,
122 const abbrev_info
*rhs
) const noexcept
123 { return (*this) (lhs
->number
, rhs
); }
126 struct abbrev_info_number_hash
128 using is_transparent
= void;
130 std::size_t operator() (unsigned int number
) const noexcept
131 { return std::hash
<unsigned int> () (number
); }
133 std::size_t operator() (const abbrev_info
*abbrev
) const noexcept
134 { return (*this) (abbrev
->number
); }
138 /* Hash table of abbrev, identified by their number. */
139 gdb::unordered_set
<const abbrev_info
*,
140 abbrev_info_number_hash
,
141 abbrev_info_number_eq
>
144 /* Storage for the abbrev table. */
145 auto_obstack m_abbrev_obstack
;
148 #endif /* GDB_DWARF2_ABBREV_H */