2020-02-09 04:40:54 +08:00
|
|
|
/* DWARF abbrev table
|
|
|
|
|
2022-01-01 22:56:03 +08:00
|
|
|
Copyright (C) 1994-2022 Free Software Foundation, Inc.
|
2020-02-09 04:40:54 +08:00
|
|
|
|
|
|
|
Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
|
|
|
|
Inc. with support from Florida State University (under contract
|
|
|
|
with the Ada Joint Program Office), and Silicon Graphics, Inc.
|
|
|
|
Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
|
|
|
|
based on Fred Fish's (Cygnus Support) implementation of DWARF 1
|
|
|
|
support.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#ifndef GDB_DWARF2_ABBREV_H
|
|
|
|
#define GDB_DWARF2_ABBREV_H
|
|
|
|
|
2020-05-28 01:48:18 +08:00
|
|
|
#include "hashtab.h"
|
|
|
|
|
2020-02-09 04:40:54 +08:00
|
|
|
struct attr_abbrev
|
2021-03-07 00:16:59 +08:00
|
|
|
{
|
|
|
|
ENUM_BITFIELD(dwarf_attribute) name : 16;
|
|
|
|
ENUM_BITFIELD(dwarf_form) form : 16;
|
2020-02-09 04:40:54 +08:00
|
|
|
|
2021-03-07 00:16:59 +08:00
|
|
|
/* It is valid only if FORM is DW_FORM_implicit_const. */
|
|
|
|
LONGEST implicit_const;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This data structure holds the information of an abbrev. */
|
|
|
|
struct abbrev_info
|
|
|
|
{
|
|
|
|
/* Number identifying abbrev. */
|
|
|
|
unsigned int number;
|
|
|
|
/* DWARF tag. */
|
2021-03-07 10:47:38 +08:00
|
|
|
ENUM_BITFIELD (dwarf_tag) tag : 16;
|
2021-03-07 00:16:59 +08:00
|
|
|
/* True if the DIE has children. */
|
2021-03-07 10:47:38 +08:00
|
|
|
bool has_children;
|
|
|
|
bool interesting;
|
|
|
|
unsigned short size_if_constant;
|
|
|
|
unsigned short sibling_offset;
|
2021-03-07 00:16:59 +08:00
|
|
|
/* Number of attributes. */
|
|
|
|
unsigned short num_attrs;
|
|
|
|
/* An array of attribute descriptions, allocated using the struct
|
|
|
|
hack. */
|
|
|
|
struct attr_abbrev attrs[1];
|
|
|
|
};
|
2020-02-09 04:40:54 +08:00
|
|
|
|
2020-02-09 04:40:54 +08:00
|
|
|
struct abbrev_table;
|
|
|
|
typedef std::unique_ptr<struct abbrev_table> abbrev_table_up;
|
|
|
|
|
2020-02-09 04:40:54 +08:00
|
|
|
/* Top level data structure to contain an abbreviation table. */
|
|
|
|
|
|
|
|
struct abbrev_table
|
|
|
|
{
|
2020-11-06 09:27:43 +08:00
|
|
|
/* Read an abbrev table from the indicated section, at the given
|
|
|
|
offset. The caller is responsible for ensuring that the section
|
|
|
|
has already been read. */
|
|
|
|
|
|
|
|
static abbrev_table_up read (struct dwarf2_section_info *section,
|
2020-02-09 04:40:54 +08:00
|
|
|
sect_offset sect_off);
|
|
|
|
|
|
|
|
/* Look up an abbrev in the table.
|
|
|
|
Returns NULL if the abbrev is not found. */
|
|
|
|
|
2021-03-14 00:41:04 +08:00
|
|
|
const struct abbrev_info *lookup_abbrev (unsigned int abbrev_number) const
|
2020-05-28 01:48:18 +08:00
|
|
|
{
|
|
|
|
struct abbrev_info search;
|
|
|
|
search.number = abbrev_number;
|
2020-02-09 04:40:54 +08:00
|
|
|
|
2020-05-28 01:48:18 +08:00
|
|
|
return (struct abbrev_info *) htab_find_with_hash (m_abbrevs.get (),
|
|
|
|
&search,
|
|
|
|
abbrev_number);
|
|
|
|
}
|
2020-02-09 04:40:54 +08:00
|
|
|
|
|
|
|
/* Where the abbrev table came from.
|
|
|
|
This is used as a sanity check when the table is used. */
|
|
|
|
const sect_offset sect_off;
|
|
|
|
|
Introduce DWARF abbrev cache
The replacement for the DWARF psymbol reader works in a somewhat
different way. The current reader reads and stores all the DIEs that
might be interesting. Then, if it is missing a DIE, it re-scans the
CU and reads them all. This approach is used for both intra- and
inter-CU references.
I instrumented the partial DIE hash to see how frequently it was used:
[ 0] -> 1538165
[ 1] -> 4912
[ 2] -> 96102
[ 3] -> 175
[ 4] -> 244
That is, most DIEs are never used, and some are looked up twice -- but
this is just an artifact of the implementation of
partial_die_info::fixup, which may do two lookups.
Based on this, the new implementation doesn't try to store any DIEs,
but instead just re-scans them on demand. In order to do this,
though, it is convenient to have a cache of DWARF abbrevs. This way,
if a second CU is needed to resolve an inter-CU reference, the abbrevs
for that CU need only be computed a single time.
2020-11-03 08:35:51 +08:00
|
|
|
struct dwarf2_section_info *section;
|
|
|
|
|
2020-02-09 04:40:54 +08:00
|
|
|
private:
|
|
|
|
|
Introduce DWARF abbrev cache
The replacement for the DWARF psymbol reader works in a somewhat
different way. The current reader reads and stores all the DIEs that
might be interesting. Then, if it is missing a DIE, it re-scans the
CU and reads them all. This approach is used for both intra- and
inter-CU references.
I instrumented the partial DIE hash to see how frequently it was used:
[ 0] -> 1538165
[ 1] -> 4912
[ 2] -> 96102
[ 3] -> 175
[ 4] -> 244
That is, most DIEs are never used, and some are looked up twice -- but
this is just an artifact of the implementation of
partial_die_info::fixup, which may do two lookups.
Based on this, the new implementation doesn't try to store any DIEs,
but instead just re-scans them on demand. In order to do this,
though, it is convenient to have a cache of DWARF abbrevs. This way,
if a second CU is needed to resolve an inter-CU reference, the abbrevs
for that CU need only be computed a single time.
2020-11-03 08:35:51 +08:00
|
|
|
abbrev_table (sect_offset off, struct dwarf2_section_info *sect);
|
2020-02-09 04:40:54 +08:00
|
|
|
|
|
|
|
DISABLE_COPY_AND_ASSIGN (abbrev_table);
|
|
|
|
|
|
|
|
/* Add an abbreviation to the table. */
|
2020-05-28 01:48:18 +08:00
|
|
|
void add_abbrev (struct abbrev_info *abbrev);
|
2020-02-09 04:40:54 +08:00
|
|
|
|
2020-02-09 04:40:54 +08:00
|
|
|
/* Hash table of abbrevs. */
|
|
|
|
htab_up m_abbrevs;
|
2020-02-09 04:40:54 +08:00
|
|
|
|
2020-02-09 04:40:54 +08:00
|
|
|
/* Storage for the abbrev table. */
|
|
|
|
auto_obstack m_abbrev_obstack;
|
|
|
|
};
|
2020-02-09 04:40:54 +08:00
|
|
|
|
|
|
|
#endif /* GDB_DWARF2_ABBREV_H */
|