17d62b00eSchristos /* DWARF abbrev table 27d62b00eSchristos 3*6881a400Schristos Copyright (C) 1994-2023 Free Software Foundation, Inc. 47d62b00eSchristos 57d62b00eSchristos Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology, 67d62b00eSchristos Inc. with support from Florida State University (under contract 77d62b00eSchristos with the Ada Joint Program Office), and Silicon Graphics, Inc. 87d62b00eSchristos Initial contribution by Brent Benson, Harris Computer Systems, Inc., 97d62b00eSchristos based on Fred Fish's (Cygnus Support) implementation of DWARF 1 107d62b00eSchristos support. 117d62b00eSchristos 127d62b00eSchristos This file is part of GDB. 137d62b00eSchristos 147d62b00eSchristos This program is free software; you can redistribute it and/or modify 157d62b00eSchristos it under the terms of the GNU General Public License as published by 167d62b00eSchristos the Free Software Foundation; either version 3 of the License, or 177d62b00eSchristos (at your option) any later version. 187d62b00eSchristos 197d62b00eSchristos This program is distributed in the hope that it will be useful, 207d62b00eSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 217d62b00eSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 227d62b00eSchristos GNU General Public License for more details. 237d62b00eSchristos 247d62b00eSchristos You should have received a copy of the GNU General Public License 257d62b00eSchristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 267d62b00eSchristos 277d62b00eSchristos #ifndef GDB_DWARF2_ABBREV_H 287d62b00eSchristos #define GDB_DWARF2_ABBREV_H 297d62b00eSchristos 307d62b00eSchristos #include "hashtab.h" 317d62b00eSchristos 327d62b00eSchristos struct attr_abbrev 337d62b00eSchristos { 347d62b00eSchristos ENUM_BITFIELD(dwarf_attribute) name : 16; 357d62b00eSchristos ENUM_BITFIELD(dwarf_form) form : 16; 367d62b00eSchristos 377d62b00eSchristos /* It is valid only if FORM is DW_FORM_implicit_const. */ 387d62b00eSchristos LONGEST implicit_const; 397d62b00eSchristos }; 407d62b00eSchristos 41*6881a400Schristos /* This data structure holds the information of an abbrev. */ 42*6881a400Schristos struct abbrev_info 43*6881a400Schristos { 44*6881a400Schristos /* Number identifying abbrev. */ 45*6881a400Schristos unsigned int number; 46*6881a400Schristos /* DWARF tag. */ 47*6881a400Schristos ENUM_BITFIELD (dwarf_tag) tag : 16; 48*6881a400Schristos /* True if the DIE has children. */ 49*6881a400Schristos bool has_children; 50*6881a400Schristos bool interesting; 51*6881a400Schristos unsigned short size_if_constant; 52*6881a400Schristos unsigned short sibling_offset; 53*6881a400Schristos /* Number of attributes. */ 54*6881a400Schristos unsigned short num_attrs; 55*6881a400Schristos /* An array of attribute descriptions, allocated using the struct 56*6881a400Schristos hack. */ 57*6881a400Schristos struct attr_abbrev attrs[1]; 58*6881a400Schristos }; 59*6881a400Schristos 607d62b00eSchristos struct abbrev_table; 617d62b00eSchristos typedef std::unique_ptr<struct abbrev_table> abbrev_table_up; 627d62b00eSchristos 637d62b00eSchristos /* Top level data structure to contain an abbreviation table. */ 647d62b00eSchristos 657d62b00eSchristos struct abbrev_table 667d62b00eSchristos { 67*6881a400Schristos /* Read an abbrev table from the indicated section, at the given 68*6881a400Schristos offset. The caller is responsible for ensuring that the section 69*6881a400Schristos has already been read. */ 70*6881a400Schristos 71*6881a400Schristos static abbrev_table_up read (struct dwarf2_section_info *section, 727d62b00eSchristos sect_offset sect_off); 737d62b00eSchristos 747d62b00eSchristos /* Look up an abbrev in the table. 757d62b00eSchristos Returns NULL if the abbrev is not found. */ 767d62b00eSchristos 77*6881a400Schristos const struct abbrev_info *lookup_abbrev (unsigned int abbrev_number) const 787d62b00eSchristos { 797d62b00eSchristos struct abbrev_info search; 807d62b00eSchristos search.number = abbrev_number; 817d62b00eSchristos 827d62b00eSchristos return (struct abbrev_info *) htab_find_with_hash (m_abbrevs.get (), 837d62b00eSchristos &search, 847d62b00eSchristos abbrev_number); 857d62b00eSchristos } 867d62b00eSchristos 877d62b00eSchristos /* Where the abbrev table came from. 887d62b00eSchristos This is used as a sanity check when the table is used. */ 897d62b00eSchristos const sect_offset sect_off; 907d62b00eSchristos 91*6881a400Schristos struct dwarf2_section_info *section; 92*6881a400Schristos 937d62b00eSchristos private: 947d62b00eSchristos 95*6881a400Schristos abbrev_table (sect_offset off, struct dwarf2_section_info *sect); 967d62b00eSchristos 977d62b00eSchristos DISABLE_COPY_AND_ASSIGN (abbrev_table); 987d62b00eSchristos 997d62b00eSchristos /* Add an abbreviation to the table. */ 1007d62b00eSchristos void add_abbrev (struct abbrev_info *abbrev); 1017d62b00eSchristos 1027d62b00eSchristos /* Hash table of abbrevs. */ 1037d62b00eSchristos htab_up m_abbrevs; 1047d62b00eSchristos 1057d62b00eSchristos /* Storage for the abbrev table. */ 1067d62b00eSchristos auto_obstack m_abbrev_obstack; 1077d62b00eSchristos }; 1087d62b00eSchristos 1097d62b00eSchristos #endif /* GDB_DWARF2_ABBREV_H */ 110