Regenerate AArch64 opcodes files
[binutils-gdb.git] / gdb / quick-symbol.h
blob676c3ede3733242081bee651669f96c46bbd30fd
1 /* "Quick" symbol functions
3 Copyright (C) 2021-2024 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_QUICK_SYMBOL_H
21 #define GDB_QUICK_SYMBOL_H
23 /* Like block_enum, but used as flags to pass to lookup functions. */
25 enum block_search_flag_values
27 SEARCH_GLOBAL_BLOCK = 1,
28 SEARCH_STATIC_BLOCK = 2
31 DEF_ENUM_FLAGS_TYPE (enum block_search_flag_values, block_search_flags);
33 /* Callback for quick_symbol_functions->map_symbol_filenames. */
35 typedef void (symbol_filename_ftype) (const char *filename,
36 const char *fullname);
38 /* Callback for quick_symbol_functions->expand_symtabs_matching
39 to match a file name. */
41 typedef bool (expand_symtabs_file_matcher_ftype) (const char *filename,
42 bool basenames);
44 /* Callback for quick_symbol_functions->expand_symtabs_matching
45 to match a symbol name. */
47 typedef bool (expand_symtabs_symbol_matcher_ftype) (const char *name);
49 /* Callback for quick_symbol_functions->expand_symtabs_matching
50 to be called after a symtab has been expanded. If this returns
51 true, more symtabs are checked; if it returns false, iteration
52 stops. */
54 typedef bool (expand_symtabs_exp_notify_ftype) (compunit_symtab *symtab);
56 /* The "quick" symbol functions exist so that symbol readers can
57 avoiding an initial read of all the symbols. For example, symbol
58 readers might choose to use the "partial symbol table" utilities,
59 which is one implementation of the quick symbol functions.
61 The quick symbol functions are generally opaque: the underlying
62 representation is hidden from the caller.
64 In general, these functions should only look at whatever special
65 index the symbol reader creates -- looking through the symbol
66 tables themselves is handled by generic code. If a function is
67 defined as returning a "symbol table", this means that the function
68 should only return a newly-created symbol table; it should not
69 examine pre-existing ones.
71 The exact list of functions here was determined in an ad hoc way
72 based on gdb's history. */
74 struct quick_symbol_functions
76 virtual ~quick_symbol_functions ()
80 /* Return true if this objfile has any "partial" symbols
81 available. */
82 virtual bool has_symbols (struct objfile *objfile) = 0;
84 /* Return true if OBJFILE has any unexpanded symtabs. A return value of
85 false indicates there are no unexpanded symtabs, this might mean that
86 all of the symtabs have been expanded (full debug has been read in),
87 or it might been that OBJFILE has no debug information. */
88 virtual bool has_unexpanded_symtabs (struct objfile *objfile) = 0;
90 /* Return the symbol table for the "last" file appearing in
91 OBJFILE. */
92 virtual struct symtab *find_last_source_symtab (struct objfile *objfile) = 0;
94 /* Forget all cached full file names for OBJFILE. */
95 virtual void forget_cached_source_info (struct objfile *objfile) = 0;
97 /* Check to see if the global symbol is defined in a "partial" symbol table
98 of OBJFILE. NAME is the name of the symbol to look for. DOMAIN
99 indicates what sorts of symbols to search for.
101 If found, sets *symbol_found_p to true and returns the symbol language.
102 defined, or NULL if no such symbol table exists. */
103 virtual enum language lookup_global_symbol_language
104 (struct objfile *objfile,
105 const char *name,
106 domain_search_flags domain,
107 bool *symbol_found_p) = 0;
109 /* Print statistics about any indices loaded for OBJFILE. The
110 statistics should be printed to gdb_stdout. This is used for
111 "maint print statistics". Statistics are printed in two
112 sections. PRINT_BCACHE is false when printing the first section
113 of general statistics, and true when printing bcache statistics. */
114 virtual void print_stats (struct objfile *objfile, bool print_bcache) = 0;
116 /* Dump any indices loaded for OBJFILE. The dump should go to
117 gdb_stdout. This is used for "maint print objfiles". */
118 virtual void dump (struct objfile *objfile) = 0;
120 /* Read all symbol tables associated with OBJFILE. */
121 virtual void expand_all_symtabs (struct objfile *objfile) = 0;
123 /* Expand all symbol tables in OBJFILE matching some criteria.
125 FILE_MATCHER is called for each file in OBJFILE. The file name
126 is passed to it. If the matcher returns false, the file is
127 skipped. If FILE_MATCHER is NULL the file is not skipped. If
128 BASENAMES is true the matcher should consider only file base
129 names (the passed file name is already only the lbasename'd
130 part).
132 If the file is not skipped, and SYMBOL_MATCHER and LOOKUP_NAME are NULL,
133 the symbol table is expanded.
135 Otherwise, individual symbols are considered.
137 If DOMAIN does not match, the symbol is skipped.
139 If the symbol name does not match LOOKUP_NAME, the symbol is skipped.
141 If SYMBOL_MATCHER returns false, then the symbol is skipped.
142 Note that if SYMBOL_MATCHER is non-NULL, then LOOKUP_NAME must
143 also be provided.
145 Otherwise, the symbol's symbol table is expanded and the
146 notification function is called. If the notification function
147 returns false, execution stops and this method returns false.
148 Otherwise, more files are considered. This method will return
149 true if all calls to the notification function return true. */
150 virtual bool expand_symtabs_matching
151 (struct objfile *objfile,
152 gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
153 const lookup_name_info *lookup_name,
154 gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
155 gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
156 block_search_flags search_flags,
157 domain_search_flags domain) = 0;
159 /* Return the comp unit from OBJFILE that contains PC and
160 SECTION. Return NULL if there is no such compunit. This
161 should return the compunit that contains a symbol whose
162 address exactly matches PC, or, if there is no exact match, the
163 compunit that contains a symbol whose address is closest to
164 PC. */
165 virtual struct compunit_symtab *find_pc_sect_compunit_symtab
166 (struct objfile *objfile, struct bound_minimal_symbol msymbol,
167 CORE_ADDR pc, struct obj_section *section, int warn_if_readin) = 0;
169 /* Return the comp unit from OBJFILE that contains a symbol at
170 ADDRESS. Return NULL if there is no such comp unit. Unlike
171 find_pc_sect_compunit_symtab, any sort of symbol (not just text
172 symbols) can be considered, and only exact address matches are
173 considered. */
174 virtual struct compunit_symtab *find_compunit_symtab_by_address
175 (struct objfile *objfile, CORE_ADDR address) = 0;
177 /* Call a callback for every file defined in OBJFILE whose symtab is
178 not already read in. FUN is the callback. It is passed the
179 file's FILENAME and the file's FULLNAME (if need_fullname is
180 non-zero). */
181 virtual void map_symbol_filenames
182 (struct objfile *objfile,
183 gdb::function_view<symbol_filename_ftype> fun,
184 bool need_fullname) = 0;
186 /* Compute the name and language of the main function for the given
187 objfile. Normally this is done during symbol reading, but this
188 method exists in case this work is done in a worker thread and
189 must be waited for. The implementation can call
190 set_objfile_main_name if results are found. */
191 virtual void compute_main_name (struct objfile *objfile)
196 typedef std::unique_ptr<quick_symbol_functions> quick_symbol_functions_up;
198 #endif /* GDB_QUICK_SYMBOL_H */