GDB (xrefs)
Loading...
Searching...
No Matches
abbrev-cache.h
Go to the documentation of this file.
1/* DWARF abbrev table cache
2
3 Copyright (C) 2022-2023 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#ifndef GDB_DWARF2_ABBREV_CACHE_H
21#define GDB_DWARF2_ABBREV_CACHE_H
22
23#include "dwarf2/abbrev.h"
24
25/* An abbrev cache holds abbrev tables for easier reuse. */
27{
28public:
29 abbrev_cache ();
31
32 /* Find an abbrev table coming from the abbrev section SECTION at
33 offset OFFSET. Return the table, or nullptr if it has not yet
34 been registered. */
35 abbrev_table *find (struct dwarf2_section_info *section, sect_offset offset)
36 {
37 search_key key = { section, offset };
38
39 return (abbrev_table *) htab_find_with_hash (m_tables.get (), &key,
40 to_underlying (offset));
41 }
42
43 /* Add TABLE to this cache. Ownership of TABLE is transferred to
44 the cache. Note that a table at a given section+offset may only
45 be registered once -- a violation of this will cause an assert.
46 To avoid this, call the 'find' method first, to see if the table
47 has already been read. */
48 void add (abbrev_table_up table);
49
50private:
51
52 static hashval_t hash_table (const void *item);
53 static int eq_table (const void *lhs, const void *rhs);
54
56 {
58 sect_offset offset;
59 };
60
61 /* Hash table of abbrev tables. */
62 htab_up m_tables;
63};
64
65#endif /* GDB_DWARF2_ABBREV_CACHE_H */
std::unique_ptr< struct abbrev_table > abbrev_table_up
Definition abbrev.h:61
abbrev_table * find(struct dwarf2_section_info *section, sect_offset offset)
DISABLE_COPY_AND_ASSIGN(abbrev_cache)
void add(abbrev_table_up table)
htab_up m_tables
static hashval_t hash_table(const void *item)
static int eq_table(const void *lhs, const void *rhs)
struct dwarf2_section_info * section