GDB (xrefs)
Loading...
Searching...
No Matches
gdb
dwarf2
abbrev-cache.c
Go to the documentation of this file.
1
/* DWARF 2 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
#include "
defs.h
"
21
#include "
dwarf2/read.h
"
22
#include "
dwarf2/abbrev-cache.h
"
23
24
/* Hash function for an abbrev table. */
25
26
hashval_t
27
abbrev_cache::hash_table
(
const
void
*item)
28
{
29
const
struct
abbrev_table
*table = (
const
struct
abbrev_table
*) item;
30
return
to_underlying (table->
sect_off
);
31
}
32
33
/* Comparison function for abbrev table. */
34
35
int
36
abbrev_cache::eq_table
(
const
void
*lhs,
const
void
*rhs)
37
{
38
const
struct
abbrev_table
*l_table = (
const
struct
abbrev_table
*) lhs;
39
const
search_key
*key = (
const
search_key
*) rhs;
40
return
(l_table->
section
== key->
section
41
&& l_table->
sect_off
== key->
offset
);
42
}
43
44
abbrev_cache::abbrev_cache
()
45
: m_tables (htab_create_alloc (20, hash_table, eq_table,
46
htab_delete_entry<
abbrev_table
>,
47
xcalloc
,
xfree
))
48
{
49
}
50
51
void
52
abbrev_cache::add
(
abbrev_table_up
table)
53
{
54
/* We allow this as a convenience to the caller. */
55
if
(table ==
nullptr
)
56
return
;
57
58
search_key
key = { table->
section
, table->sect_off };
59
void
**slot = htab_find_slot_with_hash (
m_tables
.get (), &key,
60
to_underlying (table->sect_off),
61
INSERT);
62
/* If this one already existed, then it should have been reused. */
63
gdb_assert (*slot ==
nullptr
);
64
*slot = (
void
*) table.release ();
65
}
abbrev-cache.h
abbrev_table_up
std::unique_ptr< struct abbrev_table > abbrev_table_up
Definition
abbrev.h:61
xfree
void xfree(void *)
xcalloc
void * xcalloc(size_t number, size_t size)
Definition
alloc.c:85
abbrev_cache::add
void add(abbrev_table_up table)
Definition
abbrev-cache.c:52
abbrev_cache::abbrev_cache
abbrev_cache()
Definition
abbrev-cache.c:44
abbrev_cache::m_tables
htab_up m_tables
Definition
abbrev-cache.h:62
abbrev_cache::hash_table
static hashval_t hash_table(const void *item)
Definition
abbrev-cache.c:27
abbrev_cache::eq_table
static int eq_table(const void *lhs, const void *rhs)
Definition
abbrev-cache.c:36
defs.h
read.h
abbrev_cache::search_key
Definition
abbrev-cache.h:56
abbrev_cache::search_key::offset
sect_offset offset
Definition
abbrev-cache.h:58
abbrev_cache::search_key::section
struct dwarf2_section_info * section
Definition
abbrev-cache.h:57
abbrev_table
Definition
abbrev.h:66
abbrev_table::sect_off
const sect_offset sect_off
Definition
abbrev.h:89
abbrev_table::section
struct dwarf2_section_info * section
Definition
abbrev.h:91
Generated by
1.10.0