gdb/mi: add new --group-by-objfile flag for -file-list-exec-source-files
[deliverable/binutils-gdb.git] / gdb / quick-symbol.h
1 /* "Quick" symbol functions
2
3 Copyright (C) 2021 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_QUICK_SYMBOL_H
21 #define GDB_QUICK_SYMBOL_H
22
23 /* Like block_enum, but used as flags to pass to lookup functions. */
24
25 enum block_search_flag_values
26 {
27 SEARCH_GLOBAL_BLOCK = 1,
28 SEARCH_STATIC_BLOCK = 2
29 };
30
31 DEF_ENUM_FLAGS_TYPE (enum block_search_flag_values, block_search_flags);
32
33 /* Comparison function for symbol look ups. */
34
35 typedef int (symbol_compare_ftype) (const char *string1,
36 const char *string2);
37
38 /* Callback for quick_symbol_functions->map_symbol_filenames. */
39
40 typedef void (symbol_filename_ftype) (const char *filename,
41 const char *fullname);
42
43 /* Callback for quick_symbol_functions->expand_symtabs_matching
44 to match a file name. */
45
46 typedef bool (expand_symtabs_file_matcher_ftype) (const char *filename,
47 bool basenames);
48
49 /* Callback for quick_symbol_functions->expand_symtabs_matching
50 to match a symbol name. */
51
52 typedef bool (expand_symtabs_symbol_matcher_ftype) (const char *name);
53
54 /* Callback for quick_symbol_functions->expand_symtabs_matching
55 to be called after a symtab has been expanded. If this returns
56 true, more symtabs are checked; if it returns false, iteration
57 stops. */
58
59 typedef bool (expand_symtabs_exp_notify_ftype) (compunit_symtab *symtab);
60
61 /* The "quick" symbol functions exist so that symbol readers can
62 avoiding an initial read of all the symbols. For example, symbol
63 readers might choose to use the "partial symbol table" utilities,
64 which is one implementation of the quick symbol functions.
65
66 The quick symbol functions are generally opaque: the underlying
67 representation is hidden from the caller.
68
69 In general, these functions should only look at whatever special
70 index the symbol reader creates -- looking through the symbol
71 tables themselves is handled by generic code. If a function is
72 defined as returning a "symbol table", this means that the function
73 should only return a newly-created symbol table; it should not
74 examine pre-existing ones.
75
76 The exact list of functions here was determined in an ad hoc way
77 based on gdb's history. */
78
79 struct quick_symbol_functions
80 {
81 virtual ~quick_symbol_functions ()
82 {
83 }
84
85 /* Return true if this objfile has any "partial" symbols
86 available. */
87 virtual bool has_symbols (struct objfile *objfile) = 0;
88
89 /* Return true if OBJFILE has any unexpanded symtabs. A return value of
90 false indicates there are no unexpanded symtabs, this might mean that
91 all of the symtabs have been expanded (full debug has been read in),
92 or it might been that OBJFILE has no debug information. */
93 virtual bool has_unexpanded_symtabs (struct objfile *objfile) = 0;
94
95 /* Return the symbol table for the "last" file appearing in
96 OBJFILE. */
97 virtual struct symtab *find_last_source_symtab (struct objfile *objfile) = 0;
98
99 /* Forget all cached full file names for OBJFILE. */
100 virtual void forget_cached_source_info (struct objfile *objfile) = 0;
101
102 /* Check to see if the global symbol is defined in a "partial" symbol table
103 of OBJFILE. NAME is the name of the symbol to look for. DOMAIN
104 indicates what sort of symbol to search for.
105
106 If found, sets *symbol_found_p to true and returns the symbol language.
107 defined, or NULL if no such symbol table exists. */
108 virtual enum language lookup_global_symbol_language
109 (struct objfile *objfile,
110 const char *name,
111 domain_enum domain,
112 bool *symbol_found_p) = 0;
113
114 /* Print statistics about any indices loaded for OBJFILE. The
115 statistics should be printed to gdb_stdout. This is used for
116 "maint print statistics". Statistics are printed in two
117 sections. PRINT_BCACHE is false when printing the first section
118 of general statistics, and true when printing bcache statistics. */
119 virtual void print_stats (struct objfile *objfile, bool print_bcache) = 0;
120
121 /* Dump any indices loaded for OBJFILE. The dump should go to
122 gdb_stdout. This is used for "maint print objfiles". */
123 virtual void dump (struct objfile *objfile) = 0;
124
125 /* Read all symbol tables associated with OBJFILE. */
126 virtual void expand_all_symtabs (struct objfile *objfile) = 0;
127
128 /* Find global or static symbols in all tables that are in DOMAIN
129 and for which MATCH (symbol name, NAME) == 0, reading in partial
130 symbol tables as needed. Look through global symbols if GLOBAL
131 and otherwise static symbols.
132
133 MATCH must be weaker than strcmp_iw_ordered in the sense that
134 strcmp_iw_ordered(x,y) == 0 --> MATCH(x,y) == 0. ORDERED_COMPARE,
135 if non-null, must be an ordering relation compatible with
136 strcmp_iw_ordered in the sense that
137 strcmp_iw_ordered(x,y) == 0 --> ORDERED_COMPARE(x,y) == 0
138 and
139 strcmp_iw_ordered(x,y) <= 0 --> ORDERED_COMPARE(x,y) <= 0
140 (allowing strcmp_iw_ordered(x,y) < 0 while ORDERED_COMPARE(x, y) == 0).
141 */
142
143 virtual void expand_matching_symbols
144 (struct objfile *,
145 const lookup_name_info &lookup_name,
146 domain_enum domain,
147 int global,
148 symbol_compare_ftype *ordered_compare) = 0;
149
150 /* Expand all symbol tables in OBJFILE matching some criteria.
151
152 FILE_MATCHER is called for each file in OBJFILE. The file name
153 is passed to it. If the matcher returns false, the file is
154 skipped. If FILE_MATCHER is NULL the file is not skipped. If
155 BASENAMES is true the matcher should consider only file base
156 names (the passed file name is already only the lbasename'd
157 part).
158
159 If the file is not skipped, and SYMBOL_MATCHER and LOOKUP_NAME are NULL,
160 the symbol table is expanded.
161
162 Otherwise, individual symbols are considered.
163
164 If DOMAIN or KIND do not match, the symbol is skipped.
165 If DOMAIN is UNDEF_DOMAIN, that is treated as a wildcard.
166
167 If the symbol name does not match LOOKUP_NAME, the symbol is skipped.
168
169 If SYMBOL_MATCHER returns false, then the symbol is skipped.
170
171 Otherwise, the symbol's symbol table is expanded and the
172 notification function is called. If the notification function
173 returns false, execution stops and this method returns false.
174 Otherwise, more files are considered. This method will return
175 true if all calls to the notification function return true. */
176 virtual bool expand_symtabs_matching
177 (struct objfile *objfile,
178 gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
179 const lookup_name_info *lookup_name,
180 gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
181 gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
182 block_search_flags search_flags,
183 domain_enum domain,
184 enum search_domain kind) = 0;
185
186 /* Return the comp unit from OBJFILE that contains PC and
187 SECTION. Return NULL if there is no such compunit. This
188 should return the compunit that contains a symbol whose
189 address exactly matches PC, or, if there is no exact match, the
190 compunit that contains a symbol whose address is closest to
191 PC. */
192 virtual struct compunit_symtab *find_pc_sect_compunit_symtab
193 (struct objfile *objfile, struct bound_minimal_symbol msymbol,
194 CORE_ADDR pc, struct obj_section *section, int warn_if_readin) = 0;
195
196 /* Return the comp unit from OBJFILE that contains a symbol at
197 ADDRESS. Return NULL if there is no such comp unit. Unlike
198 find_pc_sect_compunit_symtab, any sort of symbol (not just text
199 symbols) can be considered, and only exact address matches are
200 considered. */
201 virtual struct compunit_symtab *find_compunit_symtab_by_address
202 (struct objfile *objfile, CORE_ADDR address) = 0;
203
204 /* Call a callback for every file defined in OBJFILE whose symtab is
205 not already read in. FUN is the callback. It is passed the
206 file's FILENAME and the file's FULLNAME (if need_fullname is
207 non-zero). */
208 virtual void map_symbol_filenames
209 (struct objfile *objfile,
210 gdb::function_view<symbol_filename_ftype> fun,
211 bool need_fullname) = 0;
212
213 /* This is called when the objfile is relocated. It can be used to
214 clean up any internal caches. */
215 virtual void relocated ()
216 {
217 /* Do nothing. */
218 }
219
220 /* Return true if this class can lazily read the symbols. This may
221 only return true if there are in fact symbols to be read, because
222 this is used in the implementation of 'has_partial_symbols'. */
223 virtual bool can_lazily_read_symbols ()
224 {
225 return false;
226 }
227
228 /* Read the partial symbols for OBJFILE. This will only ever be
229 called if can_lazily_read_symbols returns true. */
230 virtual void read_partial_symbols (struct objfile *objfile)
231 {
232 }
233 };
234
235 typedef std::unique_ptr<quick_symbol_functions> quick_symbol_functions_up;
236
237 #endif /* GDB_QUICK_SYMBOL_H */
This page took 0.033701 seconds and 4 git commands to generate.