]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/dwarf2/mapped-index.h
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / dwarf2 / mapped-index.h
CommitLineData
20386fa3
TT
1/* Base class for mapped indices
2
213516ef 3 Copyright (C) 2021-2023 Free Software Foundation, Inc.
20386fa3
TT
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_MAPPED_INDEX_H
21#define GDB_DWARF2_MAPPED_INDEX_H
22
23#include "language.h"
24
25/* An index into a (C++) symbol name component in a symbol name as
26 recorded in the mapped_index's symbol table. For each C++ symbol
27 in the symbol table, we record one entry for the start of each
28 component in the symbol in a table of name components, and then
29 sort the table, in order to be able to binary search symbol names,
30 ignoring leading namespaces, both completion and regular look up.
31 For example, for symbol "A::B::C", we'll have an entry that points
32 to "A::B::C", another that points to "B::C", and another for "C".
33 Note that function symbols in GDB index have no parameter
34 information, just the function/method names. You can convert a
35 name_component to a "const char *" using the
36 'mapped_index::symbol_name_at(offset_type)' method. */
37
38struct name_component
39{
40 /* Offset in the symbol name where the component starts. Stored as
41 a (32-bit) offset instead of a pointer to save memory and improve
42 locality on 64-bit architectures. */
43 offset_type name_offset;
44
45 /* The symbol's index in the symbol and constant pool tables of a
46 mapped_index. */
47 offset_type idx;
48};
49
758ffab4
TT
50class cooked_index_vector;
51
6606799f
TT
52/* Base class of all DWARF scanner types. */
53
54struct dwarf_scanner_base
55{
56 dwarf_scanner_base () = default;
57 virtual ~dwarf_scanner_base () = default;
58 DISABLE_COPY_AND_ASSIGN (dwarf_scanner_base);
59
60 /* Return a quick_symbol_functions instance that refers back to this
61 dwarf_scanner_base. */
62 virtual quick_symbol_functions_up make_quick_functions () const = 0;
f75a1d3a
TT
63
64 /* An ad hoc version check. This is needed for .gdb_index to check
65 whether a version 8 or above index is in use. Returns true if
66 the index is usable, false otherwise. */
67 virtual bool version_check () const
68 {
69 return true;
70 }
758ffab4
TT
71
72 /* This is called when writing an index. For a cooked index, it
73 will return 'this' as a cooked index. For other forms, it will
74 throw an exception with an appropriate error message. */
75 virtual cooked_index_vector *index_for_writing () = 0;
6606799f
TT
76};
77
20386fa3
TT
78/* Base class containing bits shared by both .gdb_index and
79 .debug_name indexes. */
80
6606799f 81struct mapped_index_base : public dwarf_scanner_base
20386fa3
TT
82{
83 mapped_index_base () = default;
84 DISABLE_COPY_AND_ASSIGN (mapped_index_base);
85
86 /* The name_component table (a sorted vector). See name_component's
87 description above. */
88 std::vector<name_component> name_components;
89
90 /* How NAME_COMPONENTS is sorted. */
91 enum case_sensitivity name_components_casing;
92
93 /* Return the number of names in the symbol table. */
94 virtual size_t symbol_name_count () const = 0;
95
96 /* Get the name of the symbol at IDX in the symbol table. */
97 virtual const char *symbol_name_at
98 (offset_type idx, dwarf2_per_objfile *per_objfile) const = 0;
99
100 /* Return whether the name at IDX in the symbol table should be
101 ignored. */
102 virtual bool symbol_name_slot_invalid (offset_type idx) const
103 {
104 return false;
105 }
106
107 /* Build the symbol name component sorted vector, if we haven't
108 yet. */
109 void build_name_components (dwarf2_per_objfile *per_objfile);
110
111 /* Returns the lower (inclusive) and upper (exclusive) bounds of the
112 possible matches for LN_NO_PARAMS in the name component
113 vector. */
114 std::pair<std::vector<name_component>::const_iterator,
115 std::vector<name_component>::const_iterator>
116 find_name_components_bounds (const lookup_name_info &ln_no_params,
117 enum language lang,
118 dwarf2_per_objfile *per_objfile) const;
758ffab4
TT
119
120 cooked_index_vector *index_for_writing () override
121 {
122 error (_("Cannot use an index to create the index"));
123 }
20386fa3
TT
124};
125
126#endif /* GDB_DWARF2_MAPPED_INDEX_H */