Automatic date update in version.in
[binutils-gdb.git] / gdb / dwarf2 / abbrev-cache.h
blobd729eb9dd1bb19105a6956c782a5e1cd6e870f29
1 /* DWARF abbrev table cache
3 Copyright (C) 2022 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
20 #ifndef GDB_DWARF2_ABBREV_CACHE_H
21 #define GDB_DWARF2_ABBREV_CACHE_H
23 #include "dwarf2/abbrev.h"
24 #include "gdbtypes.h"
26 /* An abbrev cache holds abbrev tables for easier reuse. */
27 class abbrev_cache
29 public:
30 abbrev_cache ();
31 DISABLE_COPY_AND_ASSIGN (abbrev_cache);
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)
38 search_key key = { section, offset };
40 return (abbrev_table *) htab_find_with_hash (m_tables.get (), &key,
41 to_underlying (offset));
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);
51 private:
53 static hashval_t hash_table (const void *item);
54 static int eq_table (const void *lhs, const void *rhs);
56 struct search_key
58 struct dwarf2_section_info *section;
59 sect_offset offset;
62 /* Hash table of abbrev tables. */
63 htab_up m_tables;
66 #endif /* GDB_DWARF2_ABBREV_CACHE_H */