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#include "gdbtypes.h"
25
26/* An abbrev cache holds abbrev tables for easier reuse. */
28{
29public:
30 abbrev_cache ();
32
33 /* Find an abbrev table coming from the abbrev section SECTION at
34 offset OFFSET. Return the table, or nullptr if it has not yet
35 been registered. */
36 abbrev_table *find (struct dwarf2_section_info *section, sect_offset offset)
37 {
38 search_key key = { section, offset };
39
40 return (abbrev_table *) htab_find_with_hash (m_tables.get (), &key,
41 to_underlying (offset));
42 }
43
44 /* Add TABLE to this cache. Ownership of TABLE is transferred to
45 the cache. Note that a table at a given section+offset may only
46 be registered once -- a violation of this will cause an assert.
47 To avoid this, call the 'find' method first, to see if the table
48 has already been read. */
49 void add (abbrev_table_up table);
50
51private:
52
53 static hashval_t hash_table (const void *item);
54 static int eq_table (const void *lhs, const void *rhs);
55
57 {
59 sect_offset offset;
60 };
61
62 /* Hash table of abbrev tables. */
63 htab_up m_tables;
64};
65
66#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