]>
Commit | Line | Data |
---|---|---|
20386fa3 TT |
1 | /* Base class for mapped indices |
2 | ||
1d506c26 | 3 | Copyright (C) 2021-2024 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 | ||
38 | struct 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 | ||
19455ee1 | 50 | class cooked_index; |
758ffab4 | 51 | |
6606799f TT |
52 | /* Base class of all DWARF scanner types. */ |
53 | ||
54 | struct 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. */ | |
19455ee1 | 75 | virtual cooked_index *index_for_writing () = 0; |
52e5e48e TT |
76 | |
77 | /* Wait for reading of the debuginfo to be completely finished. | |
78 | This normally has a trivial implementation, but if a subclass | |
79 | does any background reading, it's needed to ensure that the | |
80 | reading is completed before destroying the containing per-BFD | |
81 | object. */ | |
82 | virtual void wait_completely () | |
83 | { | |
84 | } | |
6606799f TT |
85 | }; |
86 | ||
20386fa3 TT |
87 | /* Base class containing bits shared by both .gdb_index and |
88 | .debug_name indexes. */ | |
89 | ||
6606799f | 90 | struct mapped_index_base : public dwarf_scanner_base |
20386fa3 TT |
91 | { |
92 | mapped_index_base () = default; | |
93 | DISABLE_COPY_AND_ASSIGN (mapped_index_base); | |
94 | ||
95 | /* The name_component table (a sorted vector). See name_component's | |
96 | description above. */ | |
97 | std::vector<name_component> name_components; | |
98 | ||
99 | /* How NAME_COMPONENTS is sorted. */ | |
100 | enum case_sensitivity name_components_casing; | |
101 | ||
102 | /* Return the number of names in the symbol table. */ | |
103 | virtual size_t symbol_name_count () const = 0; | |
104 | ||
105 | /* Get the name of the symbol at IDX in the symbol table. */ | |
106 | virtual const char *symbol_name_at | |
107 | (offset_type idx, dwarf2_per_objfile *per_objfile) const = 0; | |
108 | ||
109 | /* Return whether the name at IDX in the symbol table should be | |
110 | ignored. */ | |
111 | virtual bool symbol_name_slot_invalid (offset_type idx) const | |
112 | { | |
113 | return false; | |
114 | } | |
115 | ||
116 | /* Build the symbol name component sorted vector, if we haven't | |
117 | yet. */ | |
118 | void build_name_components (dwarf2_per_objfile *per_objfile); | |
119 | ||
120 | /* Returns the lower (inclusive) and upper (exclusive) bounds of the | |
121 | possible matches for LN_NO_PARAMS in the name component | |
122 | vector. */ | |
123 | std::pair<std::vector<name_component>::const_iterator, | |
124 | std::vector<name_component>::const_iterator> | |
125 | find_name_components_bounds (const lookup_name_info &ln_no_params, | |
126 | enum language lang, | |
127 | dwarf2_per_objfile *per_objfile) const; | |
758ffab4 | 128 | |
19455ee1 | 129 | cooked_index *index_for_writing () override |
758ffab4 TT |
130 | { |
131 | error (_("Cannot use an index to create the index")); | |
132 | } | |
20386fa3 TT |
133 | }; |
134 | ||
135 | #endif /* GDB_DWARF2_MAPPED_INDEX_H */ |