Create dwarf2/abbrev.[ch]
[deliverable/binutils-gdb.git] / gdb / dwarf2 / abbrev.h
1 /* DWARF abbrev table
2
3 Copyright (C) 1994-2020 Free Software Foundation, Inc.
4
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
10 support.
11
12 This file is part of GDB.
13
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.
18
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.
23
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/>. */
26
27 #ifndef GDB_DWARF2_ABBREV_H
28 #define GDB_DWARF2_ABBREV_H
29
30 /* This data structure holds the information of an abbrev. */
31 struct abbrev_info
32 {
33 unsigned int number; /* number identifying abbrev */
34 enum dwarf_tag tag; /* dwarf tag */
35 unsigned short has_children; /* boolean */
36 unsigned short num_attrs; /* number of attributes */
37 struct attr_abbrev *attrs; /* an array of attribute descriptions */
38 struct abbrev_info *next; /* next in chain */
39 };
40
41 struct attr_abbrev
42 {
43 ENUM_BITFIELD(dwarf_attribute) name : 16;
44 ENUM_BITFIELD(dwarf_form) form : 16;
45
46 /* It is valid only if FORM is DW_FORM_implicit_const. */
47 LONGEST implicit_const;
48 };
49
50 /* Size of abbrev_table.abbrev_hash_table. */
51 #define ABBREV_HASH_SIZE 121
52
53 /* Top level data structure to contain an abbreviation table. */
54
55 struct abbrev_table
56 {
57 explicit abbrev_table (sect_offset off)
58 : sect_off (off)
59 {
60 m_abbrevs =
61 XOBNEWVEC (&abbrev_obstack, struct abbrev_info *, ABBREV_HASH_SIZE);
62 memset (m_abbrevs, 0, ABBREV_HASH_SIZE * sizeof (struct abbrev_info *));
63 }
64
65 DISABLE_COPY_AND_ASSIGN (abbrev_table);
66
67 /* Allocate space for a struct abbrev_info object in
68 ABBREV_TABLE. */
69 struct abbrev_info *alloc_abbrev ();
70
71 /* Add an abbreviation to the table. */
72 void add_abbrev (unsigned int abbrev_number, struct abbrev_info *abbrev);
73
74 /* Look up an abbrev in the table.
75 Returns NULL if the abbrev is not found. */
76
77 struct abbrev_info *lookup_abbrev (unsigned int abbrev_number);
78
79
80 /* Where the abbrev table came from.
81 This is used as a sanity check when the table is used. */
82 const sect_offset sect_off;
83
84 /* Storage for the abbrev table. */
85 auto_obstack abbrev_obstack;
86
87 private:
88
89 /* Hash table of abbrevs.
90 This is an array of size ABBREV_HASH_SIZE allocated in abbrev_obstack.
91 It could be statically allocated, but the previous code didn't so we
92 don't either. */
93 struct abbrev_info **m_abbrevs;
94 };
95
96 typedef std::unique_ptr<struct abbrev_table> abbrev_table_up;
97
98 extern abbrev_table_up abbrev_table_read_table
99 (struct objfile *objfile,
100 struct dwarf2_section_info *section,
101 sect_offset sect_off);
102
103 #endif /* GDB_DWARF2_ABBREV_H */
This page took 0.040548 seconds and 4 git commands to generate.