symtab.h revision 1.11 1 1.1 christos /* Symbol table definitions for GDB.
2 1.1 christos
3 1.11 christos Copyright (C) 1986-2024 Free Software Foundation, Inc.
4 1.1 christos
5 1.1 christos This file is part of GDB.
6 1.1 christos
7 1.1 christos This program is free software; you can redistribute it and/or modify
8 1.1 christos it under the terms of the GNU General Public License as published by
9 1.1 christos the Free Software Foundation; either version 3 of the License, or
10 1.1 christos (at your option) any later version.
11 1.1 christos
12 1.1 christos This program is distributed in the hope that it will be useful,
13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 1.1 christos GNU General Public License for more details.
16 1.1 christos
17 1.1 christos You should have received a copy of the GNU General Public License
18 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 1.1 christos
20 1.1 christos #if !defined (SYMTAB_H)
21 1.1 christos #define SYMTAB_H 1
22 1.1 christos
23 1.8 christos #include <array>
24 1.7 christos #include <vector>
25 1.8 christos #include <string>
26 1.9 christos #include <set>
27 1.9 christos #include "gdbsupport/gdb_vecs.h"
28 1.1 christos #include "gdbtypes.h"
29 1.10 christos #include "gdbsupport/gdb_obstack.h"
30 1.10 christos #include "gdbsupport/gdb_regex.h"
31 1.9 christos #include "gdbsupport/enum-flags.h"
32 1.9 christos #include "gdbsupport/function-view.h"
33 1.11 christos #include <optional>
34 1.11 christos #include <string_view>
35 1.9 christos #include "gdbsupport/next-iterator.h"
36 1.10 christos #include "gdbsupport/iterator-range.h"
37 1.8 christos #include "completer.h"
38 1.9 christos #include "gdb-demangle.h"
39 1.10 christos #include "split-name.h"
40 1.11 christos #include "frame.h"
41 1.11 christos #include <optional>
42 1.1 christos
43 1.1 christos /* Opaque declarations. */
44 1.1 christos struct ui_file;
45 1.10 christos class frame_info_ptr;
46 1.1 christos struct symbol;
47 1.1 christos struct obstack;
48 1.1 christos struct objfile;
49 1.1 christos struct block;
50 1.1 christos struct blockvector;
51 1.1 christos struct axs_value;
52 1.1 christos struct agent_expr;
53 1.1 christos struct program_space;
54 1.1 christos struct language_defn;
55 1.1 christos struct common_block;
56 1.6 christos struct obj_section;
57 1.6 christos struct cmd_list_element;
58 1.8 christos class probe;
59 1.8 christos struct lookup_name_info;
60 1.10 christos struct code_breakpoint;
61 1.8 christos
62 1.8 christos /* How to match a lookup name against a symbol search name. */
63 1.8 christos enum class symbol_name_match_type
64 1.8 christos {
65 1.8 christos /* Wild matching. Matches unqualified symbol names in all
66 1.8 christos namespace/module/packages, etc. */
67 1.8 christos WILD,
68 1.8 christos
69 1.8 christos /* Full matching. The lookup name indicates a fully-qualified name,
70 1.8 christos and only matches symbol search names in the specified
71 1.8 christos namespace/module/package. */
72 1.8 christos FULL,
73 1.8 christos
74 1.8 christos /* Search name matching. This is like FULL, but the search name did
75 1.8 christos not come from the user; instead it is already a search name
76 1.9 christos retrieved from a search_name () call.
77 1.8 christos For Ada, this avoids re-encoding an already-encoded search name
78 1.8 christos (which would potentially incorrectly lowercase letters in the
79 1.8 christos linkage/search name that should remain uppercase). For C++, it
80 1.8 christos avoids trying to demangle a name we already know is
81 1.8 christos demangled. */
82 1.8 christos SEARCH_NAME,
83 1.8 christos
84 1.8 christos /* Expression matching. The same as FULL matching in most
85 1.8 christos languages. The same as WILD matching in Ada. */
86 1.8 christos EXPRESSION,
87 1.8 christos };
88 1.8 christos
89 1.8 christos /* Hash the given symbol search name according to LANGUAGE's
90 1.8 christos rules. */
91 1.8 christos extern unsigned int search_name_hash (enum language language,
92 1.8 christos const char *search_name);
93 1.8 christos
94 1.8 christos /* Ada-specific bits of a lookup_name_info object. This is lazily
95 1.8 christos constructed on demand. */
96 1.8 christos
97 1.8 christos class ada_lookup_name_info final
98 1.8 christos {
99 1.8 christos public:
100 1.8 christos /* Construct. */
101 1.8 christos explicit ada_lookup_name_info (const lookup_name_info &lookup_name);
102 1.8 christos
103 1.8 christos /* Compare SYMBOL_SEARCH_NAME with our lookup name, using MATCH_TYPE
104 1.8 christos as name match type. Returns true if there's a match, false
105 1.8 christos otherwise. If non-NULL, store the matching results in MATCH. */
106 1.8 christos bool matches (const char *symbol_search_name,
107 1.8 christos symbol_name_match_type match_type,
108 1.8 christos completion_match_result *comp_match_res) const;
109 1.8 christos
110 1.8 christos /* The Ada-encoded lookup name. */
111 1.8 christos const std::string &lookup_name () const
112 1.8 christos { return m_encoded_name; }
113 1.8 christos
114 1.8 christos /* Return true if we're supposed to be doing a wild match look
115 1.8 christos up. */
116 1.8 christos bool wild_match_p () const
117 1.8 christos { return m_wild_match_p; }
118 1.8 christos
119 1.8 christos /* Return true if we're looking up a name inside package
120 1.8 christos Standard. */
121 1.8 christos bool standard_p () const
122 1.8 christos { return m_standard_p; }
123 1.8 christos
124 1.8 christos /* Return true if doing a verbatim match. */
125 1.8 christos bool verbatim_p () const
126 1.8 christos { return m_verbatim_p; }
127 1.8 christos
128 1.10 christos /* A wrapper for ::split_name that handles some Ada-specific
129 1.10 christos peculiarities. */
130 1.11 christos std::vector<std::string_view> split_name () const
131 1.10 christos {
132 1.11 christos if (m_verbatim_p)
133 1.10 christos {
134 1.11 christos /* For verbatim matches, just return the encoded name
135 1.11 christos as-is. */
136 1.11 christos std::vector<std::string_view> result;
137 1.10 christos result.emplace_back (m_encoded_name);
138 1.10 christos return result;
139 1.10 christos }
140 1.11 christos /* Otherwise, split the decoded name for matching. */
141 1.11 christos return ::split_name (m_decoded_name.c_str (), split_style::DOT_STYLE);
142 1.10 christos }
143 1.10 christos
144 1.8 christos private:
145 1.8 christos /* The Ada-encoded lookup name. */
146 1.8 christos std::string m_encoded_name;
147 1.8 christos
148 1.11 christos /* The decoded lookup name. This is formed by calling ada_decode
149 1.11 christos with both 'operators' and 'wide' set to false. */
150 1.11 christos std::string m_decoded_name;
151 1.11 christos
152 1.8 christos /* Whether the user-provided lookup name was Ada encoded. If so,
153 1.8 christos then return encoded names in the 'matches' method's 'completion
154 1.8 christos match result' output. */
155 1.8 christos bool m_encoded_p : 1;
156 1.8 christos
157 1.8 christos /* True if really doing wild matching. Even if the user requests
158 1.8 christos wild matching, some cases require full matching. */
159 1.8 christos bool m_wild_match_p : 1;
160 1.8 christos
161 1.8 christos /* True if doing a verbatim match. This is true if the decoded
162 1.8 christos version of the symbol name is wrapped in '<'/'>'. This is an
163 1.8 christos escape hatch users can use to look up symbols the Ada encoding
164 1.8 christos does not understand. */
165 1.8 christos bool m_verbatim_p : 1;
166 1.8 christos
167 1.8 christos /* True if the user specified a symbol name that is inside package
168 1.8 christos Standard. Symbol names inside package Standard are handled
169 1.8 christos specially. We always do a non-wild match of the symbol name
170 1.8 christos without the "standard__" prefix, and only search static and
171 1.8 christos global symbols. This was primarily introduced in order to allow
172 1.8 christos the user to specifically access the standard exceptions using,
173 1.8 christos for instance, Standard.Constraint_Error when Constraint_Error is
174 1.8 christos ambiguous (due to the user defining its own Constraint_Error
175 1.8 christos entity inside its program). */
176 1.8 christos bool m_standard_p : 1;
177 1.8 christos };
178 1.8 christos
179 1.8 christos /* Language-specific bits of a lookup_name_info object, for languages
180 1.8 christos that do name searching using demangled names (C++/D/Go). This is
181 1.8 christos lazily constructed on demand. */
182 1.8 christos
183 1.8 christos struct demangle_for_lookup_info final
184 1.8 christos {
185 1.8 christos public:
186 1.8 christos demangle_for_lookup_info (const lookup_name_info &lookup_name,
187 1.8 christos language lang);
188 1.8 christos
189 1.8 christos /* The demangled lookup name. */
190 1.8 christos const std::string &lookup_name () const
191 1.8 christos { return m_demangled_name; }
192 1.8 christos
193 1.8 christos private:
194 1.8 christos /* The demangled lookup name. */
195 1.8 christos std::string m_demangled_name;
196 1.8 christos };
197 1.8 christos
198 1.8 christos /* Object that aggregates all information related to a symbol lookup
199 1.8 christos name. I.e., the name that is matched against the symbol's search
200 1.8 christos name. Caches per-language information so that it doesn't require
201 1.8 christos recomputing it for every symbol comparison, like for example the
202 1.8 christos Ada encoded name and the symbol's name hash for a given language.
203 1.8 christos The object is conceptually immutable once constructed, and thus has
204 1.8 christos no setters. This is to prevent some code path from tweaking some
205 1.8 christos property of the lookup name for some local reason and accidentally
206 1.8 christos altering the results of any continuing search(es).
207 1.8 christos lookup_name_info objects are generally passed around as a const
208 1.8 christos reference to reinforce that. (They're not passed around by value
209 1.8 christos because they're not small.) */
210 1.8 christos class lookup_name_info final
211 1.8 christos {
212 1.8 christos public:
213 1.9 christos /* We delete this overload so that the callers are required to
214 1.9 christos explicitly handle the lifetime of the name. */
215 1.9 christos lookup_name_info (std::string &&name,
216 1.9 christos symbol_name_match_type match_type,
217 1.9 christos bool completion_mode = false,
218 1.9 christos bool ignore_parameters = false) = delete;
219 1.9 christos
220 1.9 christos /* This overload requires that NAME have a lifetime at least as long
221 1.9 christos as the lifetime of this object. */
222 1.9 christos lookup_name_info (const std::string &name,
223 1.9 christos symbol_name_match_type match_type,
224 1.9 christos bool completion_mode = false,
225 1.9 christos bool ignore_parameters = false)
226 1.9 christos : m_match_type (match_type),
227 1.9 christos m_completion_mode (completion_mode),
228 1.9 christos m_ignore_parameters (ignore_parameters),
229 1.9 christos m_name (name)
230 1.9 christos {}
231 1.9 christos
232 1.9 christos /* This overload requires that NAME have a lifetime at least as long
233 1.9 christos as the lifetime of this object. */
234 1.9 christos lookup_name_info (const char *name,
235 1.8 christos symbol_name_match_type match_type,
236 1.8 christos bool completion_mode = false,
237 1.8 christos bool ignore_parameters = false)
238 1.8 christos : m_match_type (match_type),
239 1.8 christos m_completion_mode (completion_mode),
240 1.8 christos m_ignore_parameters (ignore_parameters),
241 1.9 christos m_name (name)
242 1.8 christos {}
243 1.8 christos
244 1.8 christos /* Getters. See description of each corresponding field. */
245 1.8 christos symbol_name_match_type match_type () const { return m_match_type; }
246 1.8 christos bool completion_mode () const { return m_completion_mode; }
247 1.11 christos std::string_view name () const { return m_name; }
248 1.8 christos const bool ignore_parameters () const { return m_ignore_parameters; }
249 1.8 christos
250 1.9 christos /* Like the "name" method but guarantees that the returned string is
251 1.9 christos \0-terminated. */
252 1.9 christos const char *c_str () const
253 1.9 christos {
254 1.9 christos /* Actually this is always guaranteed due to how the class is
255 1.9 christos constructed. */
256 1.9 christos return m_name.data ();
257 1.9 christos }
258 1.9 christos
259 1.8 christos /* Return a version of this lookup name that is usable with
260 1.8 christos comparisons against symbols have no parameter info, such as
261 1.8 christos psymbols and GDB index symbols. */
262 1.8 christos lookup_name_info make_ignore_params () const
263 1.8 christos {
264 1.9 christos return lookup_name_info (c_str (), m_match_type, m_completion_mode,
265 1.8 christos true /* ignore params */);
266 1.8 christos }
267 1.8 christos
268 1.8 christos /* Get the search name hash for searches in language LANG. */
269 1.8 christos unsigned int search_name_hash (language lang) const
270 1.8 christos {
271 1.8 christos /* Only compute each language's hash once. */
272 1.8 christos if (!m_demangled_hashes_p[lang])
273 1.8 christos {
274 1.8 christos m_demangled_hashes[lang]
275 1.9 christos = ::search_name_hash (lang, language_lookup_name (lang));
276 1.8 christos m_demangled_hashes_p[lang] = true;
277 1.8 christos }
278 1.8 christos return m_demangled_hashes[lang];
279 1.8 christos }
280 1.8 christos
281 1.8 christos /* Get the search name for searches in language LANG. */
282 1.9 christos const char *language_lookup_name (language lang) const
283 1.8 christos {
284 1.8 christos switch (lang)
285 1.8 christos {
286 1.8 christos case language_ada:
287 1.9 christos return ada ().lookup_name ().c_str ();
288 1.8 christos case language_cplus:
289 1.9 christos return cplus ().lookup_name ().c_str ();
290 1.8 christos case language_d:
291 1.9 christos return d ().lookup_name ().c_str ();
292 1.8 christos case language_go:
293 1.9 christos return go ().lookup_name ().c_str ();
294 1.8 christos default:
295 1.9 christos return m_name.data ();
296 1.8 christos }
297 1.8 christos }
298 1.8 christos
299 1.10 christos /* A wrapper for ::split_name (see split-name.h) that splits this
300 1.10 christos name, and that handles any language-specific peculiarities. */
301 1.11 christos std::vector<std::string_view> split_name (language lang) const
302 1.10 christos {
303 1.10 christos if (lang == language_ada)
304 1.10 christos return ada ().split_name ();
305 1.10 christos split_style style = split_style::NONE;
306 1.10 christos switch (lang)
307 1.10 christos {
308 1.10 christos case language_cplus:
309 1.10 christos case language_rust:
310 1.10 christos style = split_style::CXX;
311 1.10 christos break;
312 1.10 christos case language_d:
313 1.10 christos case language_go:
314 1.11 christos style = split_style::DOT_STYLE;
315 1.10 christos break;
316 1.10 christos }
317 1.10 christos return ::split_name (language_lookup_name (lang), style);
318 1.10 christos }
319 1.10 christos
320 1.8 christos /* Get the Ada-specific lookup info. */
321 1.8 christos const ada_lookup_name_info &ada () const
322 1.8 christos {
323 1.8 christos maybe_init (m_ada);
324 1.8 christos return *m_ada;
325 1.8 christos }
326 1.8 christos
327 1.8 christos /* Get the C++-specific lookup info. */
328 1.8 christos const demangle_for_lookup_info &cplus () const
329 1.8 christos {
330 1.8 christos maybe_init (m_cplus, language_cplus);
331 1.8 christos return *m_cplus;
332 1.8 christos }
333 1.8 christos
334 1.8 christos /* Get the D-specific lookup info. */
335 1.8 christos const demangle_for_lookup_info &d () const
336 1.8 christos {
337 1.8 christos maybe_init (m_d, language_d);
338 1.8 christos return *m_d;
339 1.8 christos }
340 1.8 christos
341 1.8 christos /* Get the Go-specific lookup info. */
342 1.8 christos const demangle_for_lookup_info &go () const
343 1.8 christos {
344 1.8 christos maybe_init (m_go, language_go);
345 1.8 christos return *m_go;
346 1.8 christos }
347 1.8 christos
348 1.8 christos /* Get a reference to a lookup_name_info object that matches any
349 1.8 christos symbol name. */
350 1.8 christos static const lookup_name_info &match_any ();
351 1.8 christos
352 1.8 christos private:
353 1.8 christos /* Initialize FIELD, if not initialized yet. */
354 1.8 christos template<typename Field, typename... Args>
355 1.8 christos void maybe_init (Field &field, Args&&... args) const
356 1.8 christos {
357 1.8 christos if (!field)
358 1.8 christos field.emplace (*this, std::forward<Args> (args)...);
359 1.8 christos }
360 1.8 christos
361 1.8 christos /* The lookup info as passed to the ctor. */
362 1.8 christos symbol_name_match_type m_match_type;
363 1.8 christos bool m_completion_mode;
364 1.8 christos bool m_ignore_parameters;
365 1.11 christos std::string_view m_name;
366 1.8 christos
367 1.8 christos /* Language-specific info. These fields are filled lazily the first
368 1.8 christos time a lookup is done in the corresponding language. They're
369 1.8 christos mutable because lookup_name_info objects are typically passed
370 1.8 christos around by const reference (see intro), and they're conceptually
371 1.8 christos "cache" that can always be reconstructed from the non-mutable
372 1.8 christos fields. */
373 1.11 christos mutable std::optional<ada_lookup_name_info> m_ada;
374 1.11 christos mutable std::optional<demangle_for_lookup_info> m_cplus;
375 1.11 christos mutable std::optional<demangle_for_lookup_info> m_d;
376 1.11 christos mutable std::optional<demangle_for_lookup_info> m_go;
377 1.8 christos
378 1.8 christos /* The demangled hashes. Stored in an array with one entry for each
379 1.8 christos possible language. The second array records whether we've
380 1.8 christos already computed the each language's hash. (These are separate
381 1.8 christos arrays instead of a single array of optional<unsigned> to avoid
382 1.8 christos alignment padding). */
383 1.8 christos mutable std::array<unsigned int, nr_languages> m_demangled_hashes;
384 1.8 christos mutable std::array<bool, nr_languages> m_demangled_hashes_p {};
385 1.8 christos };
386 1.8 christos
387 1.8 christos /* Comparison function for completion symbol lookup.
388 1.8 christos
389 1.8 christos Returns true if the symbol name matches against LOOKUP_NAME.
390 1.8 christos
391 1.8 christos SYMBOL_SEARCH_NAME should be a symbol's "search" name.
392 1.8 christos
393 1.8 christos On success and if non-NULL, COMP_MATCH_RES->match is set to point
394 1.8 christos to the symbol name as should be presented to the user as a
395 1.8 christos completion match list element. In most languages, this is the same
396 1.8 christos as the symbol's search name, but in some, like Ada, the display
397 1.8 christos name is dynamically computed within the comparison routine.
398 1.8 christos
399 1.8 christos Also, on success and if non-NULL, COMP_MATCH_RES->match_for_lcd
400 1.8 christos points the part of SYMBOL_SEARCH_NAME that was considered to match
401 1.8 christos LOOKUP_NAME. E.g., in C++, in linespec/wild mode, if the symbol is
402 1.8 christos "foo::function()" and LOOKUP_NAME is "function(", MATCH_FOR_LCD
403 1.8 christos points to "function()" inside SYMBOL_SEARCH_NAME. */
404 1.8 christos typedef bool (symbol_name_matcher_ftype)
405 1.8 christos (const char *symbol_search_name,
406 1.8 christos const lookup_name_info &lookup_name,
407 1.8 christos completion_match_result *comp_match_res);
408 1.1 christos
409 1.1 christos /* Some of the structures in this file are space critical.
410 1.1 christos The space-critical structures are:
411 1.1 christos
412 1.1 christos struct general_symbol_info
413 1.1 christos struct symbol
414 1.1 christos struct partial_symbol
415 1.1 christos
416 1.1 christos These structures are laid out to encourage good packing.
417 1.1 christos They use ENUM_BITFIELD and short int fields, and they order the
418 1.1 christos structure members so that fields less than a word are next
419 1.1 christos to each other so they can be packed together. */
420 1.1 christos
421 1.1 christos /* Rearranged: used ENUM_BITFIELD and rearranged field order in
422 1.1 christos all the space critical structures (plus struct minimal_symbol).
423 1.1 christos Memory usage dropped from 99360768 bytes to 90001408 bytes.
424 1.1 christos I measured this with before-and-after tests of
425 1.1 christos "HEAD-old-gdb -readnow HEAD-old-gdb" and
426 1.1 christos "HEAD-new-gdb -readnow HEAD-old-gdb" on native i686-pc-linux-gnu,
427 1.1 christos red hat linux 8, with LD_LIBRARY_PATH=/usr/lib/debug,
428 1.1 christos typing "maint space 1" at the first command prompt.
429 1.1 christos
430 1.1 christos Here is another measurement (from andrew c):
431 1.1 christos # no /usr/lib/debug, just plain glibc, like a normal user
432 1.1 christos gdb HEAD-old-gdb
433 1.1 christos (gdb) break internal_error
434 1.1 christos (gdb) run
435 1.1 christos (gdb) maint internal-error
436 1.1 christos (gdb) backtrace
437 1.1 christos (gdb) maint space 1
438 1.1 christos
439 1.1 christos gdb gdb_6_0_branch 2003-08-19 space used: 8896512
440 1.1 christos gdb HEAD 2003-08-19 space used: 8904704
441 1.1 christos gdb HEAD 2003-08-21 space used: 8396800 (+symtab.h)
442 1.1 christos gdb HEAD 2003-08-21 space used: 8265728 (+gdbtypes.h)
443 1.1 christos
444 1.1 christos The third line shows the savings from the optimizations in symtab.h.
445 1.1 christos The fourth line shows the savings from the optimizations in
446 1.1 christos gdbtypes.h. Both optimizations are in gdb HEAD now.
447 1.1 christos
448 1.1 christos --chastain 2003-08-21 */
449 1.1 christos
450 1.1 christos /* Define a structure for the information that is common to all symbol types,
451 1.1 christos including minimal symbols, partial symbols, and full symbols. In a
452 1.1 christos multilanguage environment, some language specific information may need to
453 1.1 christos be recorded along with each symbol. */
454 1.1 christos
455 1.1 christos /* This structure is space critical. See space comments at the top. */
456 1.1 christos
457 1.1 christos struct general_symbol_info
458 1.1 christos {
459 1.9 christos /* Short version as to when to use which name accessor:
460 1.9 christos Use natural_name () to refer to the name of the symbol in the original
461 1.9 christos source code. Use linkage_name () if you want to know what the linker
462 1.9 christos thinks the symbol's name is. Use print_name () for output. Use
463 1.9 christos demangled_name () if you specifically need to know whether natural_name ()
464 1.9 christos and linkage_name () are different. */
465 1.9 christos
466 1.9 christos const char *linkage_name () const
467 1.9 christos { return m_name; }
468 1.9 christos
469 1.9 christos /* Return SYMBOL's "natural" name, i.e. the name that it was called in
470 1.9 christos the original source code. In languages like C++ where symbols may
471 1.9 christos be mangled for ease of manipulation by the linker, this is the
472 1.9 christos demangled name. */
473 1.9 christos const char *natural_name () const;
474 1.9 christos
475 1.9 christos /* Returns a version of the name of a symbol that is
476 1.9 christos suitable for output. In C++ this is the "demangled" form of the
477 1.9 christos name if demangle is on and the "mangled" form of the name if
478 1.9 christos demangle is off. In other languages this is just the symbol name.
479 1.9 christos The result should never be NULL. Don't use this for internal
480 1.9 christos purposes (e.g. storing in a hashtable): it's only suitable for output. */
481 1.9 christos const char *print_name () const
482 1.9 christos { return demangle ? natural_name () : linkage_name (); }
483 1.9 christos
484 1.9 christos /* Return the demangled name for a symbol based on the language for
485 1.9 christos that symbol. If no demangled name exists, return NULL. */
486 1.9 christos const char *demangled_name () const;
487 1.9 christos
488 1.9 christos /* Returns the name to be used when sorting and searching symbols.
489 1.9 christos In C++, we search for the demangled form of a name,
490 1.9 christos and so sort symbols accordingly. In Ada, however, we search by mangled
491 1.9 christos name. If there is no distinct demangled name, then this
492 1.9 christos returns the same value (same pointer) as linkage_name (). */
493 1.9 christos const char *search_name () const;
494 1.9 christos
495 1.9 christos /* Set just the linkage name of a symbol; do not try to demangle
496 1.9 christos it. Used for constructs which do not have a mangled name,
497 1.9 christos e.g. struct tags. Unlike compute_and_set_names, linkage_name must
498 1.9 christos be terminated and either already on the objfile's obstack or
499 1.9 christos permanently allocated. */
500 1.9 christos void set_linkage_name (const char *linkage_name)
501 1.9 christos { m_name = linkage_name; }
502 1.9 christos
503 1.9 christos /* Set the demangled name of this symbol to NAME. NAME must be
504 1.9 christos already correctly allocated. If the symbol's language is Ada,
505 1.9 christos then the name is ignored and the obstack is set. */
506 1.9 christos void set_demangled_name (const char *name, struct obstack *obstack);
507 1.9 christos
508 1.9 christos enum language language () const
509 1.9 christos { return m_language; }
510 1.9 christos
511 1.9 christos /* Initializes the language dependent portion of a symbol
512 1.9 christos depending upon the language for the symbol. */
513 1.9 christos void set_language (enum language language, struct obstack *obstack);
514 1.9 christos
515 1.9 christos /* Set the linkage and natural names of a symbol, by demangling
516 1.9 christos the linkage name. If linkage_name may not be nullterminated,
517 1.9 christos copy_name must be set to true. */
518 1.11 christos void compute_and_set_names (std::string_view linkage_name, bool copy_name,
519 1.9 christos struct objfile_per_bfd_storage *per_bfd,
520 1.11 christos std::optional<hashval_t> hash
521 1.11 christos = std::optional<hashval_t> ());
522 1.10 christos
523 1.10 christos CORE_ADDR value_address () const
524 1.10 christos {
525 1.10 christos return m_value.address;
526 1.10 christos }
527 1.10 christos
528 1.10 christos void set_value_address (CORE_ADDR address)
529 1.10 christos {
530 1.10 christos m_value.address = address;
531 1.10 christos }
532 1.9 christos
533 1.11 christos /* Return the unrelocated address of this symbol. */
534 1.11 christos unrelocated_addr unrelocated_address () const
535 1.11 christos {
536 1.11 christos return m_value.unrel_addr;
537 1.11 christos }
538 1.11 christos
539 1.11 christos /* Set the unrelocated address of this symbol. */
540 1.11 christos void set_unrelocated_address (unrelocated_addr addr)
541 1.11 christos {
542 1.11 christos m_value.unrel_addr = addr;
543 1.11 christos }
544 1.11 christos
545 1.1 christos /* Name of the symbol. This is a required field. Storage for the
546 1.1 christos name is allocated on the objfile_obstack for the associated
547 1.1 christos objfile. For languages like C++ that make a distinction between
548 1.1 christos the mangled name and demangled name, this is the mangled
549 1.1 christos name. */
550 1.1 christos
551 1.9 christos const char *m_name;
552 1.1 christos
553 1.1 christos /* Value of the symbol. Which member of this union to use, and what
554 1.1 christos it means, depends on what kind of symbol this is and its
555 1.1 christos SYMBOL_CLASS. See comments there for more details. All of these
556 1.1 christos are in host byte order (though what they point to might be in
557 1.1 christos target byte order, e.g. LOC_CONST_BYTES). */
558 1.1 christos
559 1.1 christos union
560 1.1 christos {
561 1.1 christos LONGEST ivalue;
562 1.1 christos
563 1.3 christos const struct block *block;
564 1.1 christos
565 1.1 christos const gdb_byte *bytes;
566 1.1 christos
567 1.1 christos CORE_ADDR address;
568 1.1 christos
569 1.11 christos /* The address, if unrelocated. An unrelocated symbol does not
570 1.11 christos have the runtime section offset applied. */
571 1.11 christos unrelocated_addr unrel_addr;
572 1.11 christos
573 1.1 christos /* A common block. Used with LOC_COMMON_BLOCK. */
574 1.1 christos
575 1.3 christos const struct common_block *common_block;
576 1.1 christos
577 1.1 christos /* For opaque typedef struct chain. */
578 1.1 christos
579 1.1 christos struct symbol *chain;
580 1.1 christos }
581 1.10 christos m_value;
582 1.1 christos
583 1.1 christos /* Since one and only one language can apply, wrap the language specific
584 1.1 christos information inside a union. */
585 1.1 christos
586 1.1 christos union
587 1.1 christos {
588 1.1 christos /* A pointer to an obstack that can be used for storage associated
589 1.1 christos with this symbol. This is only used by Ada, and only when the
590 1.1 christos 'ada_mangled' field is zero. */
591 1.1 christos struct obstack *obstack;
592 1.1 christos
593 1.1 christos /* This is used by languages which wish to store a demangled name.
594 1.7 christos currently used by Ada, C++, and Objective C. */
595 1.6 christos const char *demangled_name;
596 1.1 christos }
597 1.1 christos language_specific;
598 1.1 christos
599 1.1 christos /* Record the source code language that applies to this symbol.
600 1.1 christos This is used to select one of the fields from the language specific
601 1.1 christos union above. */
602 1.1 christos
603 1.9 christos ENUM_BITFIELD(language) m_language : LANGUAGE_BITS;
604 1.1 christos
605 1.6 christos /* This is only used by Ada. If set, then the 'demangled_name' field
606 1.1 christos of language_specific is valid. Otherwise, the 'obstack' field is
607 1.1 christos valid. */
608 1.1 christos unsigned int ada_mangled : 1;
609 1.1 christos
610 1.1 christos /* Which section is this symbol in? This is an index into
611 1.1 christos section_offsets for this objfile. Negative means that the symbol
612 1.1 christos does not get relocated relative to a section. */
613 1.1 christos
614 1.10 christos short m_section;
615 1.10 christos
616 1.10 christos /* Set the index into the obj_section list (within the containing
617 1.10 christos objfile) for the section that contains this symbol. See M_SECTION
618 1.10 christos for more details. */
619 1.10 christos
620 1.10 christos void set_section_index (short idx)
621 1.10 christos { m_section = idx; }
622 1.10 christos
623 1.10 christos /* Return the index into the obj_section list (within the containing
624 1.10 christos objfile) for the section that contains this symbol. See M_SECTION
625 1.10 christos for more details. */
626 1.10 christos
627 1.10 christos short section_index () const
628 1.10 christos { return m_section; }
629 1.10 christos
630 1.10 christos /* Return the obj_section from OBJFILE for this symbol. The symbol
631 1.10 christos returned is based on the SECTION member variable, and can be nullptr
632 1.10 christos if SECTION is negative. */
633 1.10 christos
634 1.10 christos struct obj_section *obj_section (const struct objfile *objfile) const;
635 1.1 christos };
636 1.1 christos
637 1.1 christos extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
638 1.1 christos
639 1.9 christos /* Try to determine the demangled name for a symbol, based on the
640 1.9 christos language of that symbol. If the language is set to language_auto,
641 1.9 christos it will attempt to find any demangling algorithm that works and
642 1.9 christos then set the language appropriately. The returned name is allocated
643 1.9 christos by the demangler and should be xfree'd. */
644 1.9 christos
645 1.10 christos extern gdb::unique_xmalloc_ptr<char> symbol_find_demangled_name
646 1.10 christos (struct general_symbol_info *gsymbol, const char *mangled);
647 1.1 christos
648 1.10 christos /* Return true if NAME matches the "search" name of GSYMBOL, according
649 1.8 christos to the symbol's language. */
650 1.8 christos extern bool symbol_matches_search_name
651 1.8 christos (const struct general_symbol_info *gsymbol,
652 1.8 christos const lookup_name_info &name);
653 1.8 christos
654 1.8 christos /* Compute the hash of the given symbol search name of a symbol of
655 1.8 christos language LANGUAGE. */
656 1.8 christos extern unsigned int search_name_hash (enum language language,
657 1.8 christos const char *search_name);
658 1.1 christos
659 1.1 christos /* Classification types for a minimal symbol. These should be taken as
660 1.1 christos "advisory only", since if gdb can't easily figure out a
661 1.1 christos classification it simply selects mst_unknown. It may also have to
662 1.1 christos guess when it can't figure out which is a better match between two
663 1.1 christos types (mst_data versus mst_bss) for example. Since the minimal
664 1.1 christos symbol info is sometimes derived from the BFD library's view of a
665 1.1 christos file, we need to live with what information bfd supplies. */
666 1.1 christos
667 1.1 christos enum minimal_symbol_type
668 1.1 christos {
669 1.1 christos mst_unknown = 0, /* Unknown type, the default */
670 1.1 christos mst_text, /* Generally executable instructions */
671 1.8 christos
672 1.8 christos /* A GNU ifunc symbol, in the .text section. GDB uses to know
673 1.8 christos whether the user is setting a breakpoint on a GNU ifunc function,
674 1.8 christos and thus GDB needs to actually set the breakpoint on the target
675 1.8 christos function. It is also used to know whether the program stepped
676 1.8 christos into an ifunc resolver -- the resolver may get a separate
677 1.8 christos symbol/alias under a different name, but it'll have the same
678 1.8 christos address as the ifunc symbol. */
679 1.8 christos mst_text_gnu_ifunc, /* Executable code returning address
680 1.8 christos of executable code */
681 1.8 christos
682 1.8 christos /* A GNU ifunc function descriptor symbol, in a data section
683 1.8 christos (typically ".opd"). Seen on architectures that use function
684 1.8 christos descriptors, like PPC64/ELFv1. In this case, this symbol's value
685 1.8 christos is the address of the descriptor. There'll be a corresponding
686 1.8 christos mst_text_gnu_ifunc synthetic symbol for the text/entry
687 1.8 christos address. */
688 1.8 christos mst_data_gnu_ifunc, /* Executable code returning address
689 1.1 christos of executable code */
690 1.8 christos
691 1.1 christos mst_slot_got_plt, /* GOT entries for .plt sections */
692 1.1 christos mst_data, /* Generally initialized data */
693 1.1 christos mst_bss, /* Generally uninitialized data */
694 1.1 christos mst_abs, /* Generally absolute (nonrelocatable) */
695 1.1 christos /* GDB uses mst_solib_trampoline for the start address of a shared
696 1.1 christos library trampoline entry. Breakpoints for shared library functions
697 1.1 christos are put there if the shared library is not yet loaded.
698 1.1 christos After the shared library is loaded, lookup_minimal_symbol will
699 1.1 christos prefer the minimal symbol from the shared library (usually
700 1.1 christos a mst_text symbol) over the mst_solib_trampoline symbol, and the
701 1.1 christos breakpoints will be moved to their true address in the shared
702 1.1 christos library via breakpoint_re_set. */
703 1.1 christos mst_solib_trampoline, /* Shared library trampoline code */
704 1.1 christos /* For the mst_file* types, the names are only guaranteed to be unique
705 1.1 christos within a given .o file. */
706 1.1 christos mst_file_text, /* Static version of mst_text */
707 1.1 christos mst_file_data, /* Static version of mst_data */
708 1.6 christos mst_file_bss, /* Static version of mst_bss */
709 1.6 christos nr_minsym_types
710 1.1 christos };
711 1.1 christos
712 1.6 christos /* The number of enum minimal_symbol_type values, with some padding for
713 1.6 christos reasonable growth. */
714 1.6 christos #define MINSYM_TYPE_BITS 4
715 1.11 christos static_assert (nr_minsym_types <= (1 << MINSYM_TYPE_BITS));
716 1.10 christos
717 1.1 christos /* Define a simple structure used to hold some very basic information about
718 1.1 christos all defined global symbols (text, data, bss, abs, etc). The only required
719 1.1 christos information is the general_symbol_info.
720 1.1 christos
721 1.1 christos In many cases, even if a file was compiled with no special options for
722 1.1 christos debugging at all, as long as was not stripped it will contain sufficient
723 1.1 christos information to build a useful minimal symbol table using this structure.
724 1.1 christos Even when a file contains enough debugging information to build a full
725 1.1 christos symbol table, these minimal symbols are still useful for quickly mapping
726 1.1 christos between names and addresses, and vice versa. They are also sometimes
727 1.1 christos used to figure out what full symbol table entries need to be read in. */
728 1.1 christos
729 1.9 christos struct minimal_symbol : public general_symbol_info
730 1.1 christos {
731 1.10 christos LONGEST value_longest () const
732 1.10 christos {
733 1.10 christos return m_value.ivalue;
734 1.10 christos }
735 1.10 christos
736 1.10 christos /* The relocated address of the minimal symbol, using the section
737 1.10 christos offsets from OBJFILE. */
738 1.10 christos CORE_ADDR value_address (objfile *objfile) const;
739 1.10 christos
740 1.11 christos /* It does not make sense to call this for minimal symbols, as they
741 1.11 christos are stored unrelocated. */
742 1.11 christos CORE_ADDR value_address () const = delete;
743 1.11 christos
744 1.10 christos /* The unrelocated address of the minimal symbol. */
745 1.11 christos unrelocated_addr unrelocated_address () const
746 1.10 christos {
747 1.11 christos return m_value.unrel_addr;
748 1.11 christos }
749 1.11 christos
750 1.11 christos /* The unrelocated address just after the end of the the minimal
751 1.11 christos symbol. */
752 1.11 christos unrelocated_addr unrelocated_end_address () const
753 1.11 christos {
754 1.11 christos return unrelocated_addr (CORE_ADDR (unrelocated_address ()) + size ());
755 1.10 christos }
756 1.10 christos
757 1.10 christos /* Return this minimal symbol's type. */
758 1.10 christos
759 1.10 christos minimal_symbol_type type () const
760 1.10 christos {
761 1.10 christos return m_type;
762 1.10 christos }
763 1.10 christos
764 1.10 christos /* Set this minimal symbol's type. */
765 1.10 christos
766 1.10 christos void set_type (minimal_symbol_type type)
767 1.10 christos {
768 1.10 christos m_type = type;
769 1.10 christos }
770 1.10 christos
771 1.10 christos /* Return this minimal symbol's size. */
772 1.10 christos
773 1.10 christos unsigned long size () const
774 1.10 christos {
775 1.10 christos return m_size;
776 1.10 christos }
777 1.10 christos
778 1.10 christos /* Set this minimal symbol's size. */
779 1.10 christos
780 1.10 christos void set_size (unsigned long size)
781 1.10 christos {
782 1.10 christos m_size = size;
783 1.10 christos m_has_size = 1;
784 1.10 christos }
785 1.10 christos
786 1.10 christos /* Return true if this minimal symbol's size is known. */
787 1.10 christos
788 1.10 christos bool has_size () const
789 1.10 christos {
790 1.10 christos return m_has_size;
791 1.10 christos }
792 1.10 christos
793 1.10 christos /* Return this minimal symbol's first target-specific flag. */
794 1.10 christos
795 1.10 christos bool target_flag_1 () const
796 1.10 christos {
797 1.10 christos return m_target_flag_1;
798 1.10 christos }
799 1.10 christos
800 1.10 christos /* Set this minimal symbol's first target-specific flag. */
801 1.10 christos
802 1.10 christos void set_target_flag_1 (bool target_flag_1)
803 1.10 christos {
804 1.10 christos m_target_flag_1 = target_flag_1;
805 1.10 christos }
806 1.10 christos
807 1.10 christos /* Return this minimal symbol's second target-specific flag. */
808 1.10 christos
809 1.10 christos bool target_flag_2 () const
810 1.10 christos {
811 1.10 christos return m_target_flag_2;
812 1.10 christos }
813 1.10 christos
814 1.10 christos /* Set this minimal symbol's second target-specific flag. */
815 1.10 christos
816 1.10 christos void set_target_flag_2 (bool target_flag_2)
817 1.10 christos {
818 1.10 christos m_target_flag_2 = target_flag_2;
819 1.10 christos }
820 1.10 christos
821 1.6 christos /* Size of this symbol. dbx_end_psymtab in dbxread.c uses this
822 1.1 christos information to calculate the end of the partial symtab based on the
823 1.1 christos address of the last symbol plus the size of the last symbol. */
824 1.1 christos
825 1.10 christos unsigned long m_size;
826 1.1 christos
827 1.1 christos /* Which source file is this symbol in? Only relevant for mst_file_*. */
828 1.1 christos const char *filename;
829 1.1 christos
830 1.1 christos /* Classification type for this minimal symbol. */
831 1.1 christos
832 1.10 christos ENUM_BITFIELD(minimal_symbol_type) m_type : MINSYM_TYPE_BITS;
833 1.1 christos
834 1.1 christos /* Non-zero if this symbol was created by gdb.
835 1.1 christos Such symbols do not appear in the output of "info var|fun". */
836 1.1 christos unsigned int created_by_gdb : 1;
837 1.1 christos
838 1.1 christos /* Two flag bits provided for the use of the target. */
839 1.10 christos unsigned int m_target_flag_1 : 1;
840 1.10 christos unsigned int m_target_flag_2 : 1;
841 1.1 christos
842 1.1 christos /* Nonzero iff the size of the minimal symbol has been set.
843 1.1 christos Symbol size information can sometimes not be determined, because
844 1.1 christos the object file format may not carry that piece of information. */
845 1.10 christos unsigned int m_has_size : 1;
846 1.1 christos
847 1.9 christos /* Non-zero if this symbol ever had its demangled name set (even if
848 1.9 christos it was set to NULL). */
849 1.9 christos unsigned int name_set : 1;
850 1.9 christos
851 1.1 christos /* Minimal symbols with the same hash key are kept on a linked
852 1.1 christos list. This is the link. */
853 1.1 christos
854 1.1 christos struct minimal_symbol *hash_next;
855 1.1 christos
856 1.1 christos /* Minimal symbols are stored in two different hash tables. This is
857 1.1 christos the `next' pointer for the demangled hash table. */
858 1.1 christos
859 1.1 christos struct minimal_symbol *demangled_hash_next;
860 1.8 christos
861 1.9 christos /* True if this symbol is of some data type. */
862 1.8 christos
863 1.8 christos bool data_p () const;
864 1.8 christos
865 1.8 christos /* True if MSYMBOL is of some text type. */
866 1.8 christos
867 1.8 christos bool text_p () const;
868 1.11 christos
869 1.11 christos /* For data symbols only, given an objfile, if 'maybe_copied'
870 1.11 christos evaluates to 'true' for that objfile, then the symbol might be
871 1.11 christos subject to copy relocation. In this case, a minimal symbol
872 1.11 christos matching the symbol's linkage name is first looked for in the
873 1.11 christos main objfile. If found, then that address is used; otherwise the
874 1.11 christos address in this symbol is used. */
875 1.11 christos
876 1.11 christos bool maybe_copied (objfile *objfile) const;
877 1.11 christos
878 1.11 christos private:
879 1.11 christos /* Return the address of this minimal symbol, in the context of OBJF. The
880 1.11 christos MAYBE_COPIED flag must be set. If the minimal symbol appears in the
881 1.11 christos main program's minimal symbols, then that minsym's address is
882 1.11 christos returned; otherwise, this minimal symbol's address is returned. */
883 1.11 christos CORE_ADDR get_maybe_copied_address (objfile *objf) const;
884 1.1 christos };
885 1.1 christos
886 1.1 christos #include "minsyms.h"
887 1.1 christos
888 1.1 christos
889 1.1 christos
891 1.1 christos /* Represent one symbol name; a variable, constant, function or typedef. */
892 1.1 christos
893 1.1 christos /* Different name domains for symbols. Looking up a symbol specifies a
894 1.1 christos domain and ignores symbol definitions in other name domains. */
895 1.10 christos
896 1.1 christos enum domain_enum
897 1.11 christos {
898 1.11 christos #define SYM_DOMAIN(X) X ## _DOMAIN,
899 1.11 christos #include "sym-domains.def"
900 1.10 christos #undef SYM_DOMAIN
901 1.1 christos };
902 1.3 christos
903 1.3 christos /* The number of bits in a symbol used to represent the domain. */
904 1.6 christos
905 1.3 christos #define SYMBOL_DOMAIN_BITS 3
906 1.1 christos
907 1.1 christos extern const char *domain_name (domain_enum);
908 1.11 christos
909 1.11 christos /* Flags used for searching symbol tables. These can be combined to
910 1.11 christos let the search match multiple kinds of symbol. */
911 1.11 christos enum domain_search_flag
912 1.11 christos {
913 1.11 christos #define SYM_DOMAIN(X) \
914 1.11 christos SEARCH_ ## X ## _DOMAIN = (1 << X ## _DOMAIN),
915 1.11 christos #include "sym-domains.def"
916 1.11 christos #undef SYM_DOMAIN
917 1.11 christos };
918 1.11 christos DEF_ENUM_FLAGS_TYPE (enum domain_search_flag, domain_search_flags);
919 1.11 christos
920 1.11 christos /* A convenience constant to search for any symbol. */
921 1.11 christos constexpr domain_search_flags SEARCH_ALL_DOMAINS
922 1.11 christos = ((domain_search_flags) 0
923 1.11 christos #define SYM_DOMAIN(X) | SEARCH_ ## X ## _DOMAIN
924 1.11 christos #include "sym-domains.def"
925 1.11 christos #undef SYM_DOMAIN
926 1.11 christos );
927 1.11 christos
928 1.11 christos /* A convenience define for "C-like" name lookups, matching variables,
929 1.11 christos types, and functions. */
930 1.11 christos #define SEARCH_VFT \
931 1.11 christos (SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN | SEARCH_TYPE_DOMAIN)
932 1.11 christos
933 1.11 christos /* Return a string representing the given flags. */
934 1.11 christos extern std::string domain_name (domain_search_flags);
935 1.11 christos
936 1.11 christos /* Convert a symbol domain to search flags. */
937 1.11 christos static inline domain_search_flags
938 1.11 christos to_search_flags (domain_enum domain)
939 1.11 christos {
940 1.11 christos return domain_search_flags (domain_search_flag (1 << domain));
941 1.1 christos }
942 1.11 christos
943 1.11 christos /* Return true if the given domain matches the given flags, false
944 1.11 christos otherwise. */
945 1.11 christos static inline bool
946 1.1 christos search_flags_matches (domain_search_flags flags, domain_enum domain)
947 1.11 christos {
948 1.11 christos return (flags & to_search_flags (domain)) != 0;
949 1.1 christos }
950 1.11 christos
951 1.11 christos /* Some helpers for Python and Guile to account for backward
952 1.11 christos compatibility. Those exposed the domains for lookup as well as
953 1.11 christos checking attributes of a symbol, so special encoding and decoding
954 1.11 christos is needed to continue to support both uses. Domain constants must
955 1.11 christos remain unchanged, so that comparing a symbol's domain against a
956 1.11 christos constant yields the correct result, so search symbols are
957 1.11 christos distinguished by adding a flag bit. This way, either sort of
958 1.11 christos constant can be used for lookup. */
959 1.11 christos
960 1.11 christos /* The flag bit. */
961 1.11 christos constexpr int SCRIPTING_SEARCH_FLAG = 0x8000;
962 1.11 christos static_assert (SCRIPTING_SEARCH_FLAG > SEARCH_ALL_DOMAINS);
963 1.11 christos
964 1.11 christos /* Convert a domain constant to a "scripting domain". */
965 1.11 christos static constexpr inline int
966 1.11 christos to_scripting_domain (domain_enum val)
967 1.11 christos {
968 1.11 christos return val;
969 1.1 christos }
970 1.11 christos
971 1.11 christos /* Convert a search constant to a "scripting domain". */
972 1.11 christos static constexpr inline int
973 1.11 christos to_scripting_domain (domain_search_flags val)
974 1.11 christos {
975 1.11 christos return SCRIPTING_SEARCH_FLAG | (int) val;
976 1.1 christos }
977 1.11 christos
978 1.11 christos /* Convert from a "scripting domain" constant back to search flags.
979 1.11 christos Throws an exception if VAL is not one of the allowable values. */
980 1.1 christos extern domain_search_flags from_scripting_domain (int val);
981 1.1 christos
982 1.1 christos /* An address-class says where to find the value of a symbol. */
983 1.1 christos
984 1.1 christos enum address_class
985 1.1 christos {
986 1.1 christos /* Not used; catches errors. */
987 1.1 christos
988 1.1 christos LOC_UNDEF,
989 1.1 christos
990 1.1 christos /* Value is constant int SYMBOL_VALUE, host byteorder. */
991 1.1 christos
992 1.1 christos LOC_CONST,
993 1.1 christos
994 1.1 christos /* Value is at fixed address SYMBOL_VALUE_ADDRESS. */
995 1.1 christos
996 1.1 christos LOC_STATIC,
997 1.1 christos
998 1.1 christos /* Value is in register. SYMBOL_VALUE is the register number
999 1.1 christos in the original debug format. SYMBOL_REGISTER_OPS holds a
1000 1.1 christos function that can be called to transform this into the
1001 1.1 christos actual register number this represents in a specific target
1002 1.1 christos architecture (gdbarch).
1003 1.1 christos
1004 1.1 christos For some symbol formats (stabs, for some compilers at least),
1005 1.1 christos the compiler generates two symbols, an argument and a register.
1006 1.1 christos In some cases we combine them to a single LOC_REGISTER in symbol
1007 1.1 christos reading, but currently not for all cases (e.g. it's passed on the
1008 1.1 christos stack and then loaded into a register). */
1009 1.1 christos
1010 1.1 christos LOC_REGISTER,
1011 1.1 christos
1012 1.1 christos /* It's an argument; the value is at SYMBOL_VALUE offset in arglist. */
1013 1.1 christos
1014 1.1 christos LOC_ARG,
1015 1.1 christos
1016 1.1 christos /* Value address is at SYMBOL_VALUE offset in arglist. */
1017 1.1 christos
1018 1.1 christos LOC_REF_ARG,
1019 1.1 christos
1020 1.1 christos /* Value is in specified register. Just like LOC_REGISTER except the
1021 1.1 christos register holds the address of the argument instead of the argument
1022 1.1 christos itself. This is currently used for the passing of structs and unions
1023 1.1 christos on sparc and hppa. It is also used for call by reference where the
1024 1.1 christos address is in a register, at least by mipsread.c. */
1025 1.1 christos
1026 1.1 christos LOC_REGPARM_ADDR,
1027 1.1 christos
1028 1.1 christos /* Value is a local variable at SYMBOL_VALUE offset in stack frame. */
1029 1.1 christos
1030 1.1 christos LOC_LOCAL,
1031 1.1 christos
1032 1.1 christos /* Value not used; definition in SYMBOL_TYPE. Symbols in the domain
1033 1.1 christos STRUCT_DOMAIN all have this class. */
1034 1.1 christos
1035 1.1 christos LOC_TYPEDEF,
1036 1.1 christos
1037 1.1 christos /* Value is address SYMBOL_VALUE_ADDRESS in the code. */
1038 1.1 christos
1039 1.1 christos LOC_LABEL,
1040 1.1 christos
1041 1.1 christos /* In a symbol table, value is SYMBOL_BLOCK_VALUE of a `struct block'.
1042 1.1 christos In a partial symbol table, SYMBOL_VALUE_ADDRESS is the start address
1043 1.1 christos of the block. Function names have this class. */
1044 1.1 christos
1045 1.1 christos LOC_BLOCK,
1046 1.1 christos
1047 1.1 christos /* Value is a constant byte-sequence pointed to by SYMBOL_VALUE_BYTES, in
1048 1.1 christos target byte order. */
1049 1.1 christos
1050 1.1 christos LOC_CONST_BYTES,
1051 1.1 christos
1052 1.1 christos /* Value is at fixed address, but the address of the variable has
1053 1.1 christos to be determined from the minimal symbol table whenever the
1054 1.1 christos variable is referenced.
1055 1.1 christos This happens if debugging information for a global symbol is
1056 1.1 christos emitted and the corresponding minimal symbol is defined
1057 1.1 christos in another object file or runtime common storage.
1058 1.1 christos The linker might even remove the minimal symbol if the global
1059 1.1 christos symbol is never referenced, in which case the symbol remains
1060 1.1 christos unresolved.
1061 1.1 christos
1062 1.1 christos GDB would normally find the symbol in the minimal symbol table if it will
1063 1.1 christos not find it in the full symbol table. But a reference to an external
1064 1.1 christos symbol in a local block shadowing other definition requires full symbol
1065 1.6 christos without possibly having its address available for LOC_STATIC. Testcase
1066 1.6 christos is provided as `gdb.dwarf2/dw2-unresolved.exp'.
1067 1.11 christos
1068 1.11 christos This is also used for thread local storage (TLS) variables. In
1069 1.11 christos this case, the address of the TLS variable must be determined
1070 1.11 christos when the variable is referenced, from the msymbol's address,
1071 1.11 christos which is the offset of the TLS variable in the thread local
1072 1.1 christos storage of the shared library/object. */
1073 1.1 christos
1074 1.1 christos LOC_UNRESOLVED,
1075 1.1 christos
1076 1.1 christos /* The variable does not actually exist in the program.
1077 1.1 christos The value is ignored. */
1078 1.1 christos
1079 1.1 christos LOC_OPTIMIZED_OUT,
1080 1.1 christos
1081 1.1 christos /* The variable's address is computed by a set of location
1082 1.1 christos functions (see "struct symbol_computed_ops" below). */
1083 1.1 christos LOC_COMPUTED,
1084 1.1 christos
1085 1.1 christos /* The variable uses general_symbol_info->value->common_block field.
1086 1.1 christos It also always uses COMMON_BLOCK_DOMAIN. */
1087 1.1 christos LOC_COMMON_BLOCK,
1088 1.1 christos
1089 1.1 christos /* Not used, just notes the boundary of the enum. */
1090 1.1 christos LOC_FINAL_VALUE
1091 1.1 christos };
1092 1.6 christos
1093 1.6 christos /* The number of bits needed for values in enum address_class, with some
1094 1.6 christos padding for reasonable growth, and room for run-time registered address
1095 1.6 christos classes. See symtab.c:MAX_SYMBOL_IMPLS.
1096 1.6 christos This is a #define so that we can have a assertion elsewhere to
1097 1.6 christos verify that we have reserved enough space for synthetic address
1098 1.6 christos classes. */
1099 1.11 christos #define SYMBOL_ACLASS_BITS 5
1100 1.6 christos static_assert (LOC_FINAL_VALUE <= (1 << SYMBOL_ACLASS_BITS));
1101 1.1 christos
1102 1.1 christos /* The methods needed to implement LOC_COMPUTED. These methods can
1103 1.1 christos use the symbol's .aux_value for additional per-symbol information.
1104 1.1 christos
1105 1.1 christos At present this is only used to implement location expressions. */
1106 1.1 christos
1107 1.1 christos struct symbol_computed_ops
1108 1.1 christos {
1109 1.1 christos
1110 1.1 christos /* Return the value of the variable SYMBOL, relative to the stack
1111 1.1 christos frame FRAME. If the variable has been optimized out, return
1112 1.1 christos zero.
1113 1.6 christos
1114 1.6 christos Iff `read_needs_frame (SYMBOL)' is not SYMBOL_NEEDS_FRAME, then
1115 1.1 christos FRAME may be zero. */
1116 1.1 christos
1117 1.11 christos struct value *(*read_variable) (struct symbol * symbol,
1118 1.1 christos const frame_info_ptr &frame);
1119 1.1 christos
1120 1.1 christos /* Read variable SYMBOL like read_variable at (callee) FRAME's function
1121 1.1 christos entry. SYMBOL should be a function parameter, otherwise
1122 1.1 christos NO_ENTRY_VALUE_ERROR will be thrown. */
1123 1.11 christos struct value *(*read_variable_at_entry) (struct symbol *symbol,
1124 1.1 christos const frame_info_ptr &frame);
1125 1.6 christos
1126 1.6 christos /* Find the "symbol_needs_kind" value for the given symbol. This
1127 1.6 christos value determines whether reading the symbol needs memory (e.g., a
1128 1.6 christos global variable), just registers (a thread-local), or a frame (a
1129 1.6 christos local variable). */
1130 1.1 christos enum symbol_needs_kind (*get_symbol_read_needs) (struct symbol * symbol);
1131 1.1 christos
1132 1.1 christos /* Write to STREAM a natural-language description of the location of
1133 1.1 christos SYMBOL, in the context of ADDR. */
1134 1.1 christos void (*describe_location) (struct symbol * symbol, CORE_ADDR addr,
1135 1.1 christos struct ui_file * stream);
1136 1.1 christos
1137 1.1 christos /* Non-zero if this symbol's address computation is dependent on PC. */
1138 1.1 christos unsigned char location_has_loclist;
1139 1.1 christos
1140 1.1 christos /* Tracepoint support. Append bytecodes to the tracepoint agent
1141 1.1 christos expression AX that push the address of the object SYMBOL. Set
1142 1.1 christos VALUE appropriately. Note --- for objects in registers, this
1143 1.1 christos needn't emit any code; as long as it sets VALUE properly, then
1144 1.1 christos the caller will generate the right code in the process of
1145 1.1 christos treating this as an lvalue or rvalue. */
1146 1.8 christos
1147 1.8 christos void (*tracepoint_var_ref) (struct symbol *symbol, struct agent_expr *ax,
1148 1.3 christos struct axs_value *value);
1149 1.3 christos
1150 1.3 christos /* Generate C code to compute the location of SYMBOL. The C code is
1151 1.3 christos emitted to STREAM. GDBARCH is the current architecture and PC is
1152 1.3 christos the PC at which SYMBOL's location should be evaluated.
1153 1.3 christos REGISTERS_USED is a vector indexed by register number; the
1154 1.3 christos generator function should set an element in this vector if the
1155 1.3 christos corresponding register is needed by the location computation.
1156 1.3 christos The generated C code must assign the location to a local
1157 1.3 christos variable; this variable's name is RESULT_NAME. */
1158 1.8 christos
1159 1.3 christos void (*generate_c_location) (struct symbol *symbol, string_file *stream,
1160 1.10 christos struct gdbarch *gdbarch,
1161 1.3 christos std::vector<bool> ®isters_used,
1162 1.3 christos CORE_ADDR pc, const char *result_name);
1163 1.1 christos
1164 1.1 christos };
1165 1.1 christos
1166 1.1 christos /* The methods needed to implement LOC_BLOCK for inferior functions.
1167 1.1 christos These methods can use the symbol's .aux_value for additional
1168 1.1 christos per-symbol information. */
1169 1.1 christos
1170 1.1 christos struct symbol_block_ops
1171 1.1 christos {
1172 1.1 christos /* Fill in *START and *LENGTH with DWARF block data of function
1173 1.1 christos FRAMEFUNC valid for inferior context address PC. Set *LENGTH to
1174 1.1 christos zero if such location is not valid for PC; *START is left
1175 1.1 christos uninitialized in such case. */
1176 1.1 christos void (*find_frame_base_location) (struct symbol *framefunc, CORE_ADDR pc,
1177 1.6 christos const gdb_byte **start, size_t *length);
1178 1.6 christos
1179 1.6 christos /* Return the frame base address. FRAME is the frame for which we want to
1180 1.6 christos compute the base address while FRAMEFUNC is the symbol for the
1181 1.6 christos corresponding function. Return 0 on failure (FRAMEFUNC may not hold the
1182 1.6 christos information we need).
1183 1.6 christos
1184 1.6 christos This method is designed to work with static links (nested functions
1185 1.6 christos handling). Static links are function properties whose evaluation returns
1186 1.6 christos the frame base address for the enclosing frame. However, there are
1187 1.6 christos multiple definitions for "frame base": the content of the frame base
1188 1.6 christos register, the CFA as defined by DWARF unwinding information, ...
1189 1.6 christos
1190 1.9 christos So this specific method is supposed to compute the frame base address such
1191 1.6 christos as for nested functions, the static link computes the same address. For
1192 1.6 christos instance, considering DWARF debugging information, the static link is
1193 1.6 christos computed with DW_AT_static_link and this method must be used to compute
1194 1.6 christos the corresponding DW_AT_frame_base attribute. */
1195 1.11 christos CORE_ADDR (*get_frame_base) (struct symbol *framefunc,
1196 1.11 christos const frame_info_ptr &frame);
1197 1.11 christos
1198 1.11 christos /* Return the block for this function. So far, this is used to
1199 1.11 christos implement function aliases. So, if this is set, then it's not
1200 1.11 christos necessary to set the other functions in this structure; and vice
1201 1.11 christos versa. */
1202 1.1 christos const block *(*get_block_value) (const struct symbol *sym);
1203 1.1 christos };
1204 1.1 christos
1205 1.1 christos /* Functions used with LOC_REGISTER and LOC_REGPARM_ADDR. */
1206 1.1 christos
1207 1.1 christos struct symbol_register_ops
1208 1.1 christos {
1209 1.1 christos int (*register_number) (struct symbol *symbol, struct gdbarch *gdbarch);
1210 1.1 christos };
1211 1.1 christos
1212 1.1 christos /* Objects of this type are used to find the address class and the
1213 1.1 christos various computed ops vectors of a symbol. */
1214 1.1 christos
1215 1.1 christos struct symbol_impl
1216 1.1 christos {
1217 1.1 christos enum address_class aclass;
1218 1.1 christos
1219 1.1 christos /* Used with LOC_COMPUTED. */
1220 1.1 christos const struct symbol_computed_ops *ops_computed;
1221 1.1 christos
1222 1.1 christos /* Used with LOC_BLOCK. */
1223 1.1 christos const struct symbol_block_ops *ops_block;
1224 1.1 christos
1225 1.1 christos /* Used with LOC_REGISTER and LOC_REGPARM_ADDR. */
1226 1.1 christos const struct symbol_register_ops *ops_register;
1227 1.1 christos };
1228 1.8 christos
1229 1.8 christos /* struct symbol has some subclasses. This enum is used to
1230 1.8 christos differentiate between them. */
1231 1.8 christos
1232 1.8 christos enum symbol_subclass_kind
1233 1.8 christos {
1234 1.8 christos /* Plain struct symbol. */
1235 1.8 christos SYMBOL_NONE,
1236 1.8 christos
1237 1.8 christos /* struct template_symbol. */
1238 1.8 christos SYMBOL_TEMPLATE,
1239 1.8 christos
1240 1.8 christos /* struct rust_vtable_symbol. */
1241 1.8 christos SYMBOL_RUST_VTABLE
1242 1.8 christos };
1243 1.10 christos
1244 1.10 christos extern gdb::array_view<const struct symbol_impl> symbol_impls;
1245 1.1 christos
1246 1.1 christos /* This structure is space critical. See space comments at the top. */
1247 1.11 christos
1248 1.1 christos struct symbol : public general_symbol_info, public allocate_on_obstack<symbol>
1249 1.9 christos {
1250 1.9 christos symbol ()
1251 1.10 christos /* Class-initialization of bitfields is only allowed in C++20. */
1252 1.10 christos : m_domain (UNDEF_DOMAIN),
1253 1.10 christos m_aclass_index (0),
1254 1.10 christos m_is_objfile_owned (1),
1255 1.10 christos m_is_argument (0),
1256 1.9 christos m_is_inlined (0),
1257 1.10 christos maybe_copied (0),
1258 1.10 christos subclass (SYMBOL_NONE),
1259 1.9 christos m_artificial (false)
1260 1.9 christos {
1261 1.10 christos /* We can't use an initializer list for members of a base class, and
1262 1.9 christos general_symbol_info needs to stay a POD type. */
1263 1.10 christos m_name = nullptr;
1264 1.9 christos m_value.ivalue = 0;
1265 1.9 christos language_specific.obstack = nullptr;
1266 1.9 christos m_language = language_unknown;
1267 1.10 christos ada_mangled = 0;
1268 1.9 christos m_section = -1;
1269 1.10 christos /* GCC 4.8.5 (on CentOS 7) does not correctly compile class-
1270 1.9 christos initialization of unions, so we initialize it manually here. */
1271 1.9 christos owner.symtab = nullptr;
1272 1.1 christos }
1273 1.9 christos
1274 1.10 christos symbol (const symbol &) = default;
1275 1.10 christos symbol &operator= (const symbol &) = default;
1276 1.10 christos
1277 1.10 christos void set_aclass_index (unsigned int aclass_index)
1278 1.10 christos {
1279 1.10 christos m_aclass_index = aclass_index;
1280 1.10 christos }
1281 1.10 christos
1282 1.10 christos const symbol_impl &impl () const
1283 1.10 christos {
1284 1.10 christos return symbol_impls[this->m_aclass_index];
1285 1.10 christos }
1286 1.11 christos
1287 1.11 christos const symbol_block_ops *block_ops () const
1288 1.11 christos {
1289 1.11 christos return this->impl ().ops_block;
1290 1.11 christos }
1291 1.11 christos
1292 1.11 christos const symbol_computed_ops *computed_ops () const
1293 1.11 christos {
1294 1.11 christos return this->impl ().ops_computed;
1295 1.11 christos }
1296 1.11 christos
1297 1.11 christos const symbol_register_ops *register_ops () const
1298 1.11 christos {
1299 1.11 christos return this->impl ().ops_register;
1300 1.11 christos }
1301 1.10 christos
1302 1.10 christos address_class aclass () const
1303 1.10 christos {
1304 1.10 christos return this->impl ().aclass;
1305 1.10 christos }
1306 1.11 christos
1307 1.11 christos /* Return true if this symbol's domain matches FLAGS. */
1308 1.11 christos bool matches (domain_search_flags flags) const;
1309 1.10 christos
1310 1.10 christos domain_enum domain () const
1311 1.10 christos {
1312 1.10 christos return m_domain;
1313 1.10 christos }
1314 1.10 christos
1315 1.10 christos void set_domain (domain_enum domain)
1316 1.10 christos {
1317 1.10 christos m_domain = domain;
1318 1.10 christos }
1319 1.10 christos
1320 1.10 christos bool is_objfile_owned () const
1321 1.10 christos {
1322 1.10 christos return m_is_objfile_owned;
1323 1.10 christos }
1324 1.10 christos
1325 1.10 christos void set_is_objfile_owned (bool is_objfile_owned)
1326 1.10 christos {
1327 1.10 christos m_is_objfile_owned = is_objfile_owned;
1328 1.10 christos }
1329 1.10 christos
1330 1.10 christos bool is_argument () const
1331 1.10 christos {
1332 1.10 christos return m_is_argument;
1333 1.10 christos }
1334 1.10 christos
1335 1.10 christos void set_is_argument (bool is_argument)
1336 1.10 christos {
1337 1.10 christos m_is_argument = is_argument;
1338 1.10 christos }
1339 1.10 christos
1340 1.10 christos bool is_inlined () const
1341 1.10 christos {
1342 1.10 christos return m_is_inlined;
1343 1.10 christos }
1344 1.10 christos
1345 1.10 christos void set_is_inlined (bool is_inlined)
1346 1.10 christos {
1347 1.10 christos m_is_inlined = is_inlined;
1348 1.10 christos }
1349 1.10 christos
1350 1.10 christos bool is_cplus_template_function () const
1351 1.10 christos {
1352 1.10 christos return this->subclass == SYMBOL_TEMPLATE;
1353 1.10 christos }
1354 1.10 christos
1355 1.10 christos struct type *type () const
1356 1.10 christos {
1357 1.10 christos return m_type;
1358 1.10 christos }
1359 1.10 christos
1360 1.10 christos void set_type (struct type *type)
1361 1.10 christos {
1362 1.10 christos m_type = type;
1363 1.10 christos }
1364 1.11 christos
1365 1.10 christos unsigned int line () const
1366 1.10 christos {
1367 1.10 christos return m_line;
1368 1.10 christos }
1369 1.11 christos
1370 1.10 christos void set_line (unsigned int line)
1371 1.10 christos {
1372 1.10 christos m_line = line;
1373 1.10 christos }
1374 1.10 christos
1375 1.10 christos LONGEST value_longest () const
1376 1.10 christos {
1377 1.10 christos return m_value.ivalue;
1378 1.10 christos }
1379 1.10 christos
1380 1.10 christos void set_value_longest (LONGEST value)
1381 1.10 christos {
1382 1.10 christos m_value.ivalue = value;
1383 1.10 christos }
1384 1.10 christos
1385 1.10 christos CORE_ADDR value_address () const
1386 1.10 christos {
1387 1.11 christos if (this->maybe_copied)
1388 1.10 christos return this->get_maybe_copied_address ();
1389 1.10 christos else
1390 1.10 christos return m_value.address;
1391 1.10 christos }
1392 1.10 christos
1393 1.10 christos void set_value_address (CORE_ADDR address)
1394 1.10 christos {
1395 1.10 christos m_value.address = address;
1396 1.10 christos }
1397 1.10 christos
1398 1.10 christos const gdb_byte *value_bytes () const
1399 1.10 christos {
1400 1.10 christos return m_value.bytes;
1401 1.10 christos }
1402 1.10 christos
1403 1.10 christos void set_value_bytes (const gdb_byte *bytes)
1404 1.10 christos {
1405 1.10 christos m_value.bytes = bytes;
1406 1.10 christos }
1407 1.10 christos
1408 1.10 christos const common_block *value_common_block () const
1409 1.10 christos {
1410 1.10 christos return m_value.common_block;
1411 1.10 christos }
1412 1.10 christos
1413 1.10 christos void set_value_common_block (const common_block *common_block)
1414 1.10 christos {
1415 1.10 christos m_value.common_block = common_block;
1416 1.10 christos }
1417 1.11 christos
1418 1.10 christos const block *value_block () const;
1419 1.10 christos
1420 1.10 christos void set_value_block (const block *block)
1421 1.10 christos {
1422 1.10 christos m_value.block = block;
1423 1.10 christos }
1424 1.10 christos
1425 1.10 christos symbol *value_chain () const
1426 1.10 christos {
1427 1.10 christos return m_value.chain;
1428 1.10 christos }
1429 1.10 christos
1430 1.10 christos void set_value_chain (symbol *sym)
1431 1.10 christos {
1432 1.10 christos m_value.chain = sym;
1433 1.10 christos }
1434 1.10 christos
1435 1.10 christos /* Return true if this symbol was marked as artificial. */
1436 1.10 christos bool is_artificial () const
1437 1.10 christos {
1438 1.10 christos return m_artificial;
1439 1.10 christos }
1440 1.10 christos
1441 1.10 christos /* Set the 'artificial' flag on this symbol. */
1442 1.10 christos void set_is_artificial (bool artificial)
1443 1.10 christos {
1444 1.10 christos m_artificial = artificial;
1445 1.10 christos }
1446 1.10 christos
1447 1.10 christos /* Return the OBJFILE of this symbol. It is an error to call this
1448 1.10 christos if is_objfile_owned is false, which only happens for
1449 1.10 christos architecture-provided types. */
1450 1.10 christos
1451 1.10 christos struct objfile *objfile () const;
1452 1.10 christos
1453 1.10 christos /* Return the ARCH of this symbol. */
1454 1.10 christos
1455 1.10 christos struct gdbarch *arch () const;
1456 1.10 christos
1457 1.10 christos /* Return the symtab of this symbol. It is an error to call this if
1458 1.10 christos is_objfile_owned is false, which only happens for
1459 1.10 christos architecture-provided types. */
1460 1.10 christos
1461 1.10 christos struct symtab *symtab () const;
1462 1.10 christos
1463 1.10 christos /* Set the symtab of this symbol to SYMTAB. It is an error to call
1464 1.10 christos this if is_objfile_owned is false, which only happens for
1465 1.10 christos architecture-provided types. */
1466 1.10 christos
1467 1.1 christos void set_symtab (struct symtab *symtab);
1468 1.1 christos
1469 1.1 christos /* Data type of value */
1470 1.10 christos
1471 1.1 christos struct type *m_type = nullptr;
1472 1.3 christos
1473 1.3 christos /* The owner of this symbol.
1474 1.3 christos Which one to use is defined by symbol.is_objfile_owned. */
1475 1.3 christos
1476 1.3 christos union
1477 1.3 christos {
1478 1.3 christos /* The symbol table containing this symbol. This is the file associated
1479 1.3 christos with LINE. It can be NULL during symbols read-in but it is never NULL
1480 1.3 christos during normal operation. */
1481 1.3 christos struct symtab *symtab;
1482 1.3 christos
1483 1.3 christos /* For types defined by the architecture. */
1484 1.3 christos struct gdbarch *arch;
1485 1.1 christos } owner;
1486 1.1 christos
1487 1.1 christos /* Domain code. */
1488 1.10 christos
1489 1.1 christos ENUM_BITFIELD(domain_enum) m_domain : SYMBOL_DOMAIN_BITS;
1490 1.1 christos
1491 1.1 christos /* Address class. This holds an index into the 'symbol_impls'
1492 1.1 christos table. The actual enum address_class value is stored there,
1493 1.1 christos alongside any per-class ops vectors. */
1494 1.10 christos
1495 1.1 christos unsigned int m_aclass_index : SYMBOL_ACLASS_BITS;
1496 1.3 christos
1497 1.9 christos /* If non-zero then symbol is objfile-owned, use owner.symtab.
1498 1.3 christos Otherwise symbol is arch-owned, use owner.arch. */
1499 1.10 christos
1500 1.3 christos unsigned int m_is_objfile_owned : 1;
1501 1.1 christos
1502 1.1 christos /* Whether this is an argument. */
1503 1.10 christos
1504 1.1 christos unsigned m_is_argument : 1;
1505 1.1 christos
1506 1.10 christos /* Whether this is an inlined function (class LOC_BLOCK only). */
1507 1.1 christos unsigned m_is_inlined : 1;
1508 1.9 christos
1509 1.9 christos /* For LOC_STATIC only, if this is set, then the symbol might be
1510 1.9 christos subject to copy relocation. In this case, a minimal symbol
1511 1.9 christos matching the symbol's linkage name is first looked for in the
1512 1.9 christos main objfile. If found, then that address is used; otherwise the
1513 1.9 christos address in this symbol is used. */
1514 1.9 christos
1515 1.9 christos unsigned maybe_copied : 1;
1516 1.8 christos
1517 1.8 christos /* The concrete type of this symbol. */
1518 1.8 christos
1519 1.1 christos ENUM_BITFIELD (symbol_subclass_kind) subclass : 2;
1520 1.10 christos
1521 1.10 christos /* Whether this symbol is artificial. */
1522 1.10 christos
1523 1.10 christos bool m_artificial : 1;
1524 1.1 christos
1525 1.1 christos /* Line number of this symbol's definition, except for inlined
1526 1.1 christos functions. For an inlined function (class LOC_BLOCK and
1527 1.1 christos SYMBOL_INLINED set) this is the line number of the function's call
1528 1.1 christos site. Inlined function symbols are not definitions, and they are
1529 1.11 christos never found by symbol table lookup.
1530 1.1 christos If this symbol is arch-owned, LINE shall be zero. */
1531 1.11 christos
1532 1.1 christos unsigned int m_line = 0;
1533 1.1 christos
1534 1.1 christos /* An arbitrary data pointer, allowing symbol readers to record
1535 1.1 christos additional information on a per-symbol basis. Note that this data
1536 1.6 christos must be allocated using the same obstack as the symbol itself. */
1537 1.6 christos /* So far it is only used by:
1538 1.6 christos LOC_COMPUTED: to find the location information
1539 1.6 christos LOC_BLOCK (DWARF2 function): information used internally by the
1540 1.1 christos DWARF 2 code --- specifically, the location expression for the frame
1541 1.1 christos base for this function. */
1542 1.1 christos /* FIXME drow/2003-02-21: For the LOC_BLOCK case, it might be better
1543 1.1 christos to add a magic symbol to the block containing this information,
1544 1.1 christos or to have a generic debug info annotation slot for symbols. */
1545 1.9 christos
1546 1.1 christos void *aux_value = nullptr;
1547 1.9 christos
1548 1.11 christos struct symbol *hash_next = nullptr;
1549 1.11 christos
1550 1.11 christos private:
1551 1.11 christos /* Return the address of this symbol. The MAYBE_COPIED flag must be set.
1552 1.11 christos If the symbol appears in the main program's minimal symbols, then
1553 1.11 christos that minsym's address is returned; otherwise, this symbol's address is
1554 1.11 christos returned. */
1555 1.1 christos CORE_ADDR get_maybe_copied_address () const;
1556 1.1 christos };
1557 1.6 christos
1558 1.6 christos /* Several lookup functions return both a symbol and the block in which the
1559 1.6 christos symbol is found. This structure is used in these cases. */
1560 1.6 christos
1561 1.6 christos struct block_symbol
1562 1.6 christos {
1563 1.6 christos /* The symbol that was found, or NULL if no symbol was found. */
1564 1.6 christos struct symbol *symbol;
1565 1.6 christos
1566 1.6 christos /* If SYMBOL is not NULL, then this is the block in which the symbol is
1567 1.6 christos defined. */
1568 1.6 christos const struct block *block;
1569 1.6 christos };
1570 1.3 christos
1571 1.3 christos /* Note: There is no accessor macro for symbol.owner because it is
1572 1.3 christos "private". */
1573 1.1 christos
1574 1.1 christos #define SYMBOL_LOCATION_BATON(symbol) (symbol)->aux_value
1575 1.11 christos
1576 1.11 christos inline const block *
1577 1.11 christos symbol::value_block () const
1578 1.11 christos {
1579 1.11 christos if (const symbol_block_ops *block_ops = this->block_ops ();
1580 1.11 christos block_ops != nullptr && block_ops->get_block_value != nullptr)
1581 1.11 christos return block_ops->get_block_value (this);
1582 1.11 christos
1583 1.11 christos return m_value.block;
1584 1.11 christos }
1585 1.1 christos
1586 1.1 christos extern int register_symbol_computed_impl (enum address_class,
1587 1.1 christos const struct symbol_computed_ops *);
1588 1.1 christos
1589 1.1 christos extern int register_symbol_block_impl (enum address_class aclass,
1590 1.1 christos const struct symbol_block_ops *ops);
1591 1.1 christos
1592 1.1 christos extern int register_symbol_register_impl (enum address_class,
1593 1.1 christos const struct symbol_register_ops *);
1594 1.1 christos
1595 1.8 christos /* An instance of this type is used to represent a C++ template
1596 1.10 christos function. A symbol is really of this type iff
1597 1.1 christos symbol::is_cplus_template_function is true. */
1598 1.8 christos
1599 1.1 christos struct template_symbol : public symbol
1600 1.1 christos {
1601 1.9 christos /* The number of template arguments. */
1602 1.1 christos int n_template_arguments = 0;
1603 1.1 christos
1604 1.1 christos /* The template arguments. This is an array with
1605 1.9 christos N_TEMPLATE_ARGUMENTS elements. */
1606 1.1 christos struct symbol **template_arguments = nullptr;
1607 1.1 christos };
1608 1.8 christos
1609 1.8 christos /* A symbol that represents a Rust virtual table object. */
1610 1.8 christos
1611 1.8 christos struct rust_vtable_symbol : public symbol
1612 1.8 christos {
1613 1.8 christos /* The concrete type for which this vtable was created; that is, in
1614 1.9 christos "impl Trait for Type", this is "Type". */
1615 1.8 christos struct type *concrete_type = nullptr;
1616 1.8 christos };
1617 1.1 christos
1618 1.1 christos
1619 1.1 christos /* Each item represents a line-->pc (or the reverse) mapping. This is
1621 1.1 christos somewhat more wasteful of space than one might wish, but since only
1622 1.1 christos the files which are actually debugged are read in to core, we don't
1623 1.1 christos waste much space. */
1624 1.1 christos
1625 1.11 christos struct linetable_entry
1626 1.11 christos {
1627 1.11 christos /* Set the (unrelocated) PC for this entry. */
1628 1.11 christos void set_unrelocated_pc (unrelocated_addr pc)
1629 1.11 christos { m_pc = pc; }
1630 1.11 christos
1631 1.11 christos /* Return the unrelocated PC for this entry. */
1632 1.11 christos unrelocated_addr unrelocated_pc () const
1633 1.11 christos { return m_pc; }
1634 1.11 christos
1635 1.11 christos /* Return the relocated PC for this entry. */
1636 1.11 christos CORE_ADDR pc (const struct objfile *objfile) const;
1637 1.11 christos
1638 1.11 christos bool operator< (const linetable_entry &other) const
1639 1.11 christos {
1640 1.11 christos if (m_pc == other.m_pc
1641 1.11 christos && (line != 0) != (other.line != 0))
1642 1.11 christos return line == 0;
1643 1.11 christos return m_pc < other.m_pc;
1644 1.11 christos }
1645 1.11 christos
1646 1.11 christos /* Two entries are equal if they have the same line and PC. The
1647 1.11 christos other members are ignored. */
1648 1.11 christos bool operator== (const linetable_entry &other) const
1649 1.9 christos { return line == other.line && m_pc == other.m_pc; }
1650 1.1 christos
1651 1.9 christos /* The line number for this entry. */
1652 1.9 christos int line;
1653 1.11 christos
1654 1.9 christos /* True if this PC is a good location to place a breakpoint for LINE. */
1655 1.10 christos bool is_stmt : 1;
1656 1.10 christos
1657 1.10 christos /* True if this location is a good location to place a breakpoint after a
1658 1.10 christos function prologue. */
1659 1.11 christos bool prologue_end : 1;
1660 1.11 christos
1661 1.11 christos /* True if this location marks the start of the epilogue. */
1662 1.11 christos bool epilogue_begin : 1;
1663 1.11 christos
1664 1.9 christos private:
1665 1.11 christos
1666 1.1 christos /* The address for this entry. */
1667 1.1 christos unrelocated_addr m_pc;
1668 1.1 christos };
1669 1.1 christos
1670 1.1 christos /* The order of entries in the linetable is significant. They should
1671 1.1 christos be sorted by increasing values of the pc field. If there is more than
1672 1.1 christos one entry for a given pc, then I'm not sure what should happen (and
1673 1.1 christos I not sure whether we currently handle it the best way).
1674 1.1 christos
1675 1.1 christos Example: a C for statement generally looks like this
1676 1.1 christos
1677 1.1 christos 10 0x100 - for the init/test part of a for stmt.
1678 1.1 christos 20 0x200
1679 1.1 christos 30 0x300
1680 1.1 christos 10 0x400 - for the increment part of a for stmt.
1681 1.1 christos
1682 1.1 christos If an entry has a line number of zero, it marks the start of a PC
1683 1.1 christos range for which no line number information is available. It is
1684 1.1 christos acceptable, though wasteful of table space, for such a range to be
1685 1.1 christos zero length. */
1686 1.1 christos
1687 1.1 christos struct linetable
1688 1.1 christos {
1689 1.1 christos int nitems;
1690 1.1 christos
1691 1.1 christos /* Actually NITEMS elements. If you don't like this use of the
1692 1.1 christos `struct hack', you can shove it up your ANSI (seriously, if the
1693 1.1 christos committee tells us how to do it, we can probably go along). */
1694 1.1 christos struct linetable_entry item[1];
1695 1.1 christos };
1696 1.1 christos
1697 1.1 christos /* How to relocate the symbols from each section in a symbol file.
1698 1.9 christos The ordering and meaning of the offsets is file-type-dependent;
1699 1.1 christos typically it is indexed by section numbers or symbol types or
1700 1.9 christos something like that. */
1701 1.1 christos
1702 1.1 christos typedef std::vector<CORE_ADDR> section_offsets;
1703 1.3 christos
1704 1.1 christos /* Each source file or header is represented by a struct symtab.
1705 1.1 christos The name "symtab" is historical, another name for it is "filetab".
1706 1.1 christos These objects are chained through the `next' field. */
1707 1.1 christos
1708 1.10 christos struct symtab
1709 1.10 christos {
1710 1.10 christos struct compunit_symtab *compunit () const
1711 1.10 christos {
1712 1.10 christos return m_compunit;
1713 1.10 christos }
1714 1.10 christos
1715 1.10 christos void set_compunit (struct compunit_symtab *compunit)
1716 1.10 christos {
1717 1.10 christos m_compunit = compunit;
1718 1.11 christos }
1719 1.10 christos
1720 1.10 christos const struct linetable *linetable () const
1721 1.10 christos {
1722 1.10 christos return m_linetable;
1723 1.11 christos }
1724 1.10 christos
1725 1.10 christos void set_linetable (const struct linetable *linetable)
1726 1.10 christos {
1727 1.10 christos m_linetable = linetable;
1728 1.10 christos }
1729 1.10 christos
1730 1.10 christos enum language language () const
1731 1.10 christos {
1732 1.10 christos return m_language;
1733 1.10 christos }
1734 1.10 christos
1735 1.10 christos void set_language (enum language language)
1736 1.10 christos {
1737 1.10 christos m_language = language;
1738 1.5 christos }
1739 1.5 christos
1740 1.1 christos /* Unordered chain of all filetabs in the compunit, with the exception
1741 1.1 christos that the "main" source file is the first entry in the list. */
1742 1.1 christos
1743 1.3 christos struct symtab *next;
1744 1.1 christos
1745 1.10 christos /* Backlink to containing compunit symtab. */
1746 1.1 christos
1747 1.1 christos struct compunit_symtab *m_compunit;
1748 1.1 christos
1749 1.1 christos /* Table mapping core addresses to line numbers for this file.
1750 1.11 christos Can be NULL if none. Never shared between different symtabs. */
1751 1.1 christos
1752 1.10 christos const struct linetable *m_linetable;
1753 1.10 christos
1754 1.10 christos /* Name of this source file, in a form appropriate to print to the user.
1755 1.1 christos
1756 1.1 christos This pointer is never nullptr. */
1757 1.1 christos
1758 1.10 christos const char *filename;
1759 1.10 christos
1760 1.10 christos /* Filename for this source file, used as an identifier to link with
1761 1.10 christos related objects such as associated macro_source_file objects. It must
1762 1.10 christos therefore match the name of any macro_source_file object created for this
1763 1.10 christos source file. The value can be the same as FILENAME if it is known to
1764 1.10 christos follow that rule, or another form of the same file name, this is up to
1765 1.10 christos the specific debug info reader.
1766 1.10 christos
1767 1.10 christos This pointer is never nullptr.*/
1768 1.1 christos const char *filename_for_id;
1769 1.1 christos
1770 1.10 christos /* Language of this source file. */
1771 1.1 christos
1772 1.3 christos enum language m_language;
1773 1.3 christos
1774 1.3 christos /* Full name of file as found by searching the source path.
1775 1.3 christos NULL if not yet known. */
1776 1.3 christos
1777 1.3 christos char *fullname;
1778 1.10 christos };
1779 1.10 christos
1780 1.10 christos /* A range adapter to allowing iterating over all the file tables in a list. */
1781 1.3 christos
1782 1.3 christos using symtab_range = next_range<symtab>;
1783 1.3 christos
1784 1.3 christos /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well
1785 1.3 christos as the list of all source files (what gdb has historically associated with
1786 1.3 christos the term "symtab").
1787 1.3 christos Additional information is recorded here that is common to all symtabs in a
1788 1.3 christos compilation unit (DWARF or otherwise).
1789 1.3 christos
1790 1.3 christos Example:
1791 1.3 christos For the case of a program built out of these files:
1792 1.3 christos
1793 1.3 christos foo.c
1794 1.3 christos foo1.h
1795 1.3 christos foo2.h
1796 1.3 christos bar.c
1797 1.3 christos foo1.h
1798 1.3 christos bar.h
1799 1.3 christos
1800 1.3 christos This is recorded as:
1801 1.10 christos
1802 1.10 christos objfile -> foo.c(cu) -> bar.c(cu) -> NULL
1803 1.10 christos | |
1804 1.10 christos v v
1805 1.10 christos foo.c bar.c
1806 1.10 christos | |
1807 1.10 christos v v
1808 1.10 christos foo1.h foo1.h
1809 1.10 christos | |
1810 1.10 christos v v
1811 1.10 christos foo2.h bar.h
1812 1.10 christos | |
1813 1.3 christos v v
1814 1.3 christos NULL NULL
1815 1.3 christos
1816 1.3 christos where "foo.c(cu)" and "bar.c(cu)" are struct compunit_symtab objects,
1817 1.3 christos and the files foo.c, etc. are struct symtab objects. */
1818 1.3 christos
1819 1.10 christos struct compunit_symtab
1820 1.10 christos {
1821 1.10 christos struct objfile *objfile () const
1822 1.10 christos {
1823 1.10 christos return m_objfile;
1824 1.10 christos }
1825 1.10 christos
1826 1.10 christos void set_objfile (struct objfile *objfile)
1827 1.10 christos {
1828 1.10 christos m_objfile = objfile;
1829 1.10 christos }
1830 1.10 christos
1831 1.10 christos symtab_range filetabs () const
1832 1.10 christos {
1833 1.10 christos return symtab_range (m_filetabs);
1834 1.10 christos }
1835 1.10 christos
1836 1.10 christos void add_filetab (symtab *filetab)
1837 1.10 christos {
1838 1.10 christos if (m_filetabs == nullptr)
1839 1.10 christos {
1840 1.10 christos m_filetabs = filetab;
1841 1.10 christos m_last_filetab = filetab;
1842 1.10 christos }
1843 1.10 christos else
1844 1.10 christos {
1845 1.10 christos m_last_filetab->next = filetab;
1846 1.10 christos m_last_filetab = filetab;
1847 1.10 christos }
1848 1.10 christos }
1849 1.10 christos
1850 1.10 christos const char *debugformat () const
1851 1.10 christos {
1852 1.10 christos return m_debugformat;
1853 1.10 christos }
1854 1.10 christos
1855 1.10 christos void set_debugformat (const char *debugformat)
1856 1.10 christos {
1857 1.10 christos m_debugformat = debugformat;
1858 1.10 christos }
1859 1.10 christos
1860 1.10 christos const char *producer () const
1861 1.10 christos {
1862 1.10 christos return m_producer;
1863 1.10 christos }
1864 1.10 christos
1865 1.10 christos void set_producer (const char *producer)
1866 1.10 christos {
1867 1.10 christos m_producer = producer;
1868 1.10 christos }
1869 1.10 christos
1870 1.10 christos const char *dirname () const
1871 1.10 christos {
1872 1.10 christos return m_dirname;
1873 1.10 christos }
1874 1.10 christos
1875 1.10 christos void set_dirname (const char *dirname)
1876 1.10 christos {
1877 1.10 christos m_dirname = dirname;
1878 1.10 christos }
1879 1.10 christos
1880 1.10 christos struct blockvector *blockvector ()
1881 1.10 christos {
1882 1.10 christos return m_blockvector;
1883 1.10 christos }
1884 1.10 christos
1885 1.10 christos const struct blockvector *blockvector () const
1886 1.10 christos {
1887 1.10 christos return m_blockvector;
1888 1.10 christos }
1889 1.10 christos
1890 1.10 christos void set_blockvector (struct blockvector *blockvector)
1891 1.10 christos {
1892 1.10 christos m_blockvector = blockvector;
1893 1.10 christos }
1894 1.10 christos
1895 1.10 christos bool locations_valid () const
1896 1.10 christos {
1897 1.10 christos return m_locations_valid;
1898 1.10 christos }
1899 1.10 christos
1900 1.10 christos void set_locations_valid (bool locations_valid)
1901 1.10 christos {
1902 1.10 christos m_locations_valid = locations_valid;
1903 1.10 christos }
1904 1.10 christos
1905 1.10 christos bool epilogue_unwind_valid () const
1906 1.10 christos {
1907 1.10 christos return m_epilogue_unwind_valid;
1908 1.10 christos }
1909 1.10 christos
1910 1.10 christos void set_epilogue_unwind_valid (bool epilogue_unwind_valid)
1911 1.10 christos {
1912 1.10 christos m_epilogue_unwind_valid = epilogue_unwind_valid;
1913 1.10 christos }
1914 1.10 christos
1915 1.10 christos struct macro_table *macro_table () const
1916 1.10 christos {
1917 1.10 christos return m_macro_table;
1918 1.10 christos }
1919 1.10 christos
1920 1.10 christos void set_macro_table (struct macro_table *macro_table)
1921 1.10 christos {
1922 1.10 christos m_macro_table = macro_table;
1923 1.10 christos }
1924 1.10 christos
1925 1.10 christos /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
1926 1.10 christos
1927 1.10 christos PRIMARY_FILETAB must already be a filetab of this compunit symtab. */
1928 1.10 christos
1929 1.10 christos void set_primary_filetab (symtab *primary_filetab);
1930 1.10 christos
1931 1.10 christos /* Return the primary filetab of the compunit. */
1932 1.10 christos symtab *primary_filetab () const;
1933 1.10 christos
1934 1.10 christos /* Set m_call_site_htab. */
1935 1.10 christos void set_call_site_htab (htab_t call_site_htab);
1936 1.10 christos
1937 1.10 christos /* Find call_site info for PC. */
1938 1.10 christos call_site *find_call_site (CORE_ADDR pc) const;
1939 1.10 christos
1940 1.10 christos /* Return the language of this compunit_symtab. */
1941 1.3 christos enum language language () const;
1942 1.3 christos
1943 1.3 christos /* Unordered chain of all compunit symtabs of this objfile. */
1944 1.3 christos struct compunit_symtab *next;
1945 1.10 christos
1946 1.3 christos /* Object file from which this symtab information was read. */
1947 1.3 christos struct objfile *m_objfile;
1948 1.3 christos
1949 1.3 christos /* Name of the symtab.
1950 1.3 christos This is *not* intended to be a usable filename, and is
1951 1.3 christos for debugging purposes only. */
1952 1.3 christos const char *name;
1953 1.3 christos
1954 1.3 christos /* Unordered list of file symtabs, except that by convention the "main"
1955 1.3 christos source file (e.g., .c, .cc) is guaranteed to be first.
1956 1.10 christos Each symtab is a file, either the "main" source file (e.g., .c, .cc)
1957 1.3 christos or header (e.g., .h). */
1958 1.3 christos symtab *m_filetabs;
1959 1.3 christos
1960 1.3 christos /* Last entry in FILETABS list.
1961 1.3 christos Subfiles are added to the end of the list so they accumulate in order,
1962 1.3 christos with the main source subfile living at the front.
1963 1.10 christos The main reason is so that the main source file symtab is at the head
1964 1.3 christos of the list, and the rest appear in order for debugging convenience. */
1965 1.3 christos symtab *m_last_filetab;
1966 1.3 christos
1967 1.1 christos /* Non-NULL string that identifies the format of the debugging information,
1968 1.1 christos such as "stabs", "dwarf 1", "dwarf 2", "coff", etc. This is mostly useful
1969 1.10 christos for automated testing of gdb but may also be information that is
1970 1.1 christos useful to the user. */
1971 1.3 christos const char *m_debugformat;
1972 1.10 christos
1973 1.1 christos /* String of producer version information, or NULL if we don't know. */
1974 1.3 christos const char *m_producer;
1975 1.10 christos
1976 1.1 christos /* Directory in which it was compiled, or NULL if we don't know. */
1977 1.3 christos const char *m_dirname;
1978 1.3 christos
1979 1.10 christos /* List of all symbol scope blocks for this symtab. It is shared among
1980 1.1 christos all symtabs in a given compilation unit. */
1981 1.3 christos struct blockvector *m_blockvector;
1982 1.3 christos
1983 1.3 christos /* Symtab has been compiled with both optimizations and debug info so that
1984 1.10 christos GDB may stop skipping prologues as variables locations are valid already
1985 1.1 christos at function entry points. */
1986 1.3 christos unsigned int m_locations_valid : 1;
1987 1.3 christos
1988 1.10 christos /* DWARF unwinder for this CU is valid even for epilogues (PC at the return
1989 1.1 christos instruction). This is supported by GCC since 4.5.0. */
1990 1.1 christos unsigned int m_epilogue_unwind_valid : 1;
1991 1.10 christos
1992 1.1 christos /* struct call_site entries for this compilation unit or NULL. */
1993 1.3 christos htab_t m_call_site_htab;
1994 1.3 christos
1995 1.3 christos /* The macro table for this symtab. Like the blockvector, this
1996 1.3 christos is shared between different symtabs in a given compilation unit.
1997 1.10 christos It's debatable whether it *should* be shared among all the symtabs in
1998 1.1 christos the given compilation unit, but it currently is. */
1999 1.1 christos struct macro_table *m_macro_table;
2000 1.3 christos
2001 1.3 christos /* If non-NULL, then this points to a NULL-terminated vector of
2002 1.3 christos included compunits. When searching the static or global
2003 1.1 christos block of this compunit, the corresponding block of all
2004 1.1 christos included compunits will also be searched. Note that this
2005 1.3 christos list must be flattened -- the symbol reader is responsible for
2006 1.3 christos ensuring that this vector contains the transitive closure of all
2007 1.3 christos included compunits. */
2008 1.3 christos struct compunit_symtab **includes;
2009 1.3 christos
2010 1.3 christos /* If this is an included compunit, this points to one includer
2011 1.3 christos of the table. This user is considered the canonical compunit
2012 1.3 christos containing this one. An included compunit may itself be
2013 1.3 christos included by another. */
2014 1.1 christos struct compunit_symtab *user;
2015 1.10 christos };
2016 1.1 christos
2017 1.9 christos using compunit_symtab_range = next_range<compunit_symtab>;
2018 1.9 christos
2019 1.9 christos /* Return true if this symtab is the "main" symtab of its compunit_symtab. */
2020 1.9 christos
2021 1.9 christos static inline bool
2022 1.10 christos is_main_symtab_of_compunit_symtab (struct symtab *symtab)
2023 1.9 christos {
2024 1.11 christos return symtab == symtab->compunit ()->primary_filetab ();
2025 1.11 christos }
2026 1.11 christos
2027 1.11 christos /* Return true if epilogue unwind info of CUST is valid. */
2028 1.11 christos
2029 1.11 christos static inline bool
2030 1.11 christos compunit_epilogue_unwind_valid (struct compunit_symtab *cust)
2031 1.11 christos {
2032 1.11 christos /* In absence of producer information, assume epilogue unwind info is
2033 1.11 christos valid. */
2034 1.11 christos if (cust == nullptr)
2035 1.11 christos return true;
2036 1.11 christos
2037 1.1 christos return cust->epilogue_unwind_valid ();
2038 1.1 christos }
2039 1.1 christos
2040 1.1 christos
2042 1.1 christos /* The virtual function table is now an array of structures which have the
2043 1.1 christos form { int16 offset, delta; void *pfn; }.
2044 1.1 christos
2045 1.1 christos In normal virtual function tables, OFFSET is unused.
2046 1.1 christos DELTA is the amount which is added to the apparent object's base
2047 1.1 christos address in order to point to the actual object to which the
2048 1.1 christos virtual function should be applied.
2049 1.1 christos PFN is a pointer to the virtual function.
2050 1.1 christos
2051 1.1 christos Note that this macro is g++ specific (FIXME). */
2052 1.1 christos
2053 1.1 christos #define VTBL_FNADDR_OFFSET 2
2054 1.1 christos
2055 1.1 christos /* External variables and functions for the objects described above. */
2056 1.1 christos
2057 1.1 christos /* True if we are nested inside psymtab_to_symtab. */
2058 1.1 christos
2059 1.1 christos extern int currently_reading_symtab;
2060 1.1 christos
2061 1.1 christos /* symtab.c lookup functions */
2062 1.1 christos
2063 1.1 christos extern const char multiple_symbols_ask[];
2064 1.1 christos extern const char multiple_symbols_all[];
2065 1.1 christos extern const char multiple_symbols_cancel[];
2066 1.1 christos
2067 1.1 christos const char *multiple_symbols_select_mode (void);
2068 1.1 christos
2069 1.1 christos /* lookup a symbol table by source file name. */
2070 1.1 christos
2071 1.1 christos extern struct symtab *lookup_symtab (const char *);
2072 1.1 christos
2073 1.1 christos /* An object of this type is passed as the 'is_a_field_of_this'
2074 1.1 christos argument to lookup_symbol and lookup_symbol_in_language. */
2075 1.1 christos
2076 1.1 christos struct field_of_this_result
2077 1.1 christos {
2078 1.1 christos /* The type in which the field was found. If this is NULL then the
2079 1.1 christos symbol was not found in 'this'. If non-NULL, then one of the
2080 1.1 christos other fields will be non-NULL as well. */
2081 1.1 christos
2082 1.1 christos struct type *type;
2083 1.1 christos
2084 1.1 christos /* If the symbol was found as an ordinary field of 'this', then this
2085 1.1 christos is non-NULL and points to the particular field. */
2086 1.3 christos
2087 1.1 christos struct field *field;
2088 1.1 christos
2089 1.1 christos /* If the symbol was found as a function field of 'this', then this
2090 1.1 christos is non-NULL and points to the particular field. */
2091 1.1 christos
2092 1.3 christos struct fn_fieldlist *fn_field;
2093 1.3 christos };
2094 1.3 christos
2095 1.3 christos /* Find the definition for a specified symbol name NAME
2096 1.3 christos in domain DOMAIN in language LANGUAGE, visible from lexical block BLOCK
2097 1.3 christos if non-NULL or from global/static blocks if BLOCK is NULL.
2098 1.3 christos Returns the struct symbol pointer, or NULL if no symbol is found.
2099 1.3 christos C++: if IS_A_FIELD_OF_THIS is non-NULL on entry, check to see if
2100 1.1 christos NAME is a field of the current implied argument `this'. If so fill in the
2101 1.6 christos fields of IS_A_FIELD_OF_THIS, otherwise the fields are set to NULL.
2102 1.6 christos The symbol's section is fixed up if necessary. */
2103 1.6 christos
2104 1.11 christos extern struct block_symbol
2105 1.6 christos lookup_symbol_in_language (const char *,
2106 1.6 christos const struct block *,
2107 1.1 christos const domain_search_flags,
2108 1.3 christos enum language,
2109 1.1 christos struct field_of_this_result *);
2110 1.6 christos
2111 1.6 christos /* Same as lookup_symbol_in_language, but using the current language. */
2112 1.11 christos
2113 1.6 christos extern struct block_symbol lookup_symbol (const char *,
2114 1.1 christos const struct block *,
2115 1.8 christos const domain_search_flags,
2116 1.8 christos struct field_of_this_result *);
2117 1.8 christos
2118 1.8 christos /* Find the definition for a specified symbol search name in domain
2119 1.9 christos DOMAIN, visible from lexical block BLOCK if non-NULL or from
2120 1.8 christos global/static blocks if BLOCK is NULL. The passed-in search name
2121 1.8 christos should not come from the user; instead it should already be a
2122 1.8 christos search name as retrieved from a search_name () call. See definition of
2123 1.8 christos symbol_name_match_type::SEARCH_NAME. Returns the struct symbol
2124 1.11 christos pointer, or NULL if no symbol is found. The symbol's section is
2125 1.11 christos fixed up if necessary. */
2126 1.11 christos
2127 1.11 christos extern struct block_symbol lookup_symbol_search_name
2128 1.8 christos (const char *search_name,
2129 1.1 christos const struct block *block,
2130 1.1 christos domain_search_flags domain);
2131 1.1 christos
2132 1.1 christos /* Some helper functions for languages that need to write their own
2133 1.3 christos lookup_symbol_nonlocal functions. */
2134 1.6 christos
2135 1.3 christos /* Lookup a symbol in the static block associated to BLOCK, if there
2136 1.6 christos is one; do nothing if BLOCK is NULL or a global block.
2137 1.6 christos Upon success fixes up the symbol's section if necessary. */
2138 1.6 christos
2139 1.11 christos extern struct block_symbol
2140 1.3 christos lookup_symbol_in_static_block (const char *name,
2141 1.3 christos const struct block *block,
2142 1.6 christos const domain_search_flags domain);
2143 1.1 christos
2144 1.11 christos /* Search all static file-level symbols for NAME from DOMAIN.
2145 1.11 christos Upon success fixes up the symbol's section if necessary. */
2146 1.1 christos
2147 1.3 christos extern struct block_symbol lookup_static_symbol
2148 1.3 christos (const char *name, const domain_search_flags domain);
2149 1.3 christos
2150 1.3 christos /* Lookup a symbol in all files' global blocks.
2151 1.3 christos
2152 1.3 christos If BLOCK is non-NULL then it is used for two things:
2153 1.3 christos 1) If a target-specific lookup routine for libraries exists, then use the
2154 1.3 christos routine for the objfile of BLOCK, and
2155 1.1 christos 2) The objfile of BLOCK is used to assist in determining the search order
2156 1.6 christos if the target requires it.
2157 1.3 christos See gdbarch_iterate_over_objfiles_in_search_order.
2158 1.6 christos
2159 1.6 christos Upon success fixes up the symbol's section if necessary. */
2160 1.6 christos
2161 1.11 christos extern struct block_symbol
2162 1.1 christos lookup_global_symbol (const char *name,
2163 1.3 christos const struct block *block,
2164 1.6 christos const domain_search_flags domain);
2165 1.3 christos
2166 1.6 christos /* Lookup a symbol in block BLOCK.
2167 1.6 christos Upon success fixes up the symbol's section if necessary. */
2168 1.8 christos
2169 1.6 christos extern struct symbol *
2170 1.11 christos lookup_symbol_in_block (const char *name,
2171 1.3 christos symbol_name_match_type match_type,
2172 1.3 christos const struct block *block,
2173 1.3 christos const domain_search_flags domain);
2174 1.1 christos
2175 1.6 christos /* Look up the `this' symbol for LANG in BLOCK. Return the symbol if
2176 1.6 christos found, or NULL if not found. */
2177 1.6 christos
2178 1.1 christos extern struct block_symbol
2179 1.3 christos lookup_language_this (const struct language_defn *lang,
2180 1.1 christos const struct block *block);
2181 1.1 christos
2182 1.1 christos /* Lookup a [struct, union, enum] by name, within a specified block. */
2183 1.1 christos
2184 1.1 christos extern struct type *lookup_struct (const char *, const struct block *);
2185 1.1 christos
2186 1.1 christos extern struct type *lookup_union (const char *, const struct block *);
2187 1.1 christos
2188 1.1 christos extern struct type *lookup_enum (const char *, const struct block *);
2189 1.8 christos
2190 1.8 christos /* from blockframe.c: */
2191 1.8 christos
2192 1.1 christos /* lookup the function symbol corresponding to the address. The
2193 1.1 christos return value will not be an inlined function; the containing
2194 1.1 christos function will be returned instead. */
2195 1.8 christos
2196 1.8 christos extern struct symbol *find_pc_function (CORE_ADDR);
2197 1.8 christos
2198 1.1 christos /* lookup the function corresponding to the address and section. The
2199 1.1 christos return value will not be an inlined function; the containing
2200 1.1 christos function will be returned instead. */
2201 1.8 christos
2202 1.8 christos extern struct symbol *find_pc_sect_function (CORE_ADDR, struct obj_section *);
2203 1.8 christos
2204 1.8 christos /* lookup the function symbol corresponding to the address and
2205 1.8 christos section. The return value will be the closest enclosing function,
2206 1.8 christos which might be an inline function. */
2207 1.8 christos
2208 1.8 christos extern struct symbol *find_pc_sect_containing_function
2209 1.8 christos (CORE_ADDR pc, struct obj_section *section);
2210 1.8 christos
2211 1.8 christos /* Find the symbol at the given address. Returns NULL if no symbol
2212 1.8 christos found. Only exact matches for ADDRESS are considered. */
2213 1.8 christos
2214 1.8 christos extern struct symbol *find_symbol_at_address (CORE_ADDR);
2215 1.8 christos
2216 1.8 christos /* Finds the "function" (text symbol) that is smaller than PC but
2217 1.8 christos greatest of all of the potential text symbols in SECTION. Sets
2218 1.8 christos *NAME and/or *ADDRESS conditionally if that pointer is non-null.
2219 1.8 christos If ENDADDR is non-null, then set *ENDADDR to be the end of the
2220 1.8 christos function (exclusive). If the optional parameter BLOCK is non-null,
2221 1.8 christos then set *BLOCK to the address of the block corresponding to the
2222 1.8 christos function symbol, if such a symbol could be found during the lookup;
2223 1.9 christos nullptr is used as a return value for *BLOCK if no block is found.
2224 1.9 christos This function either succeeds or fails (not halfway succeeds). If
2225 1.8 christos it succeeds, it sets *NAME, *ADDRESS, and *ENDADDR to real
2226 1.8 christos information and returns true. If it fails, it sets *NAME, *ADDRESS
2227 1.8 christos and *ENDADDR to zero and returns false.
2228 1.8 christos
2229 1.8 christos If the function in question occupies non-contiguous ranges,
2230 1.8 christos *ADDRESS and *ENDADDR are (subject to the conditions noted above) set
2231 1.8 christos to the start and end of the range in which PC is found. Thus
2232 1.8 christos *ADDRESS <= PC < *ENDADDR with no intervening gaps (in which ranges
2233 1.8 christos from other functions might be found).
2234 1.8 christos
2235 1.8 christos This property allows find_pc_partial_function to be used (as it had
2236 1.8 christos been prior to the introduction of non-contiguous range support) by
2237 1.8 christos various tdep files for finding a start address and limit address
2238 1.8 christos for prologue analysis. This still isn't ideal, however, because we
2239 1.8 christos probably shouldn't be doing prologue analysis (in which
2240 1.8 christos instructions are scanned to determine frame size and stack layout)
2241 1.8 christos for any range that doesn't contain the entry pc. Moreover, a good
2242 1.8 christos argument can be made that prologue analysis ought to be performed
2243 1.8 christos starting from the entry pc even when PC is within some other range.
2244 1.8 christos This might suggest that *ADDRESS and *ENDADDR ought to be set to the
2245 1.8 christos limits of the entry pc range, but that will cause the
2246 1.8 christos *ADDRESS <= PC < *ENDADDR condition to be violated; many of the
2247 1.8 christos callers of find_pc_partial_function expect this condition to hold.
2248 1.8 christos
2249 1.8 christos Callers which require the start and/or end addresses for the range
2250 1.9 christos containing the entry pc should instead call
2251 1.9 christos find_function_entry_range_from_pc. */
2252 1.9 christos
2253 1.9 christos extern bool find_pc_partial_function (CORE_ADDR pc, const char **name,
2254 1.9 christos CORE_ADDR *address, CORE_ADDR *endaddr,
2255 1.9 christos const struct block **block = nullptr);
2256 1.9 christos
2257 1.9 christos /* Like find_pc_partial_function, above, but returns the underlying
2258 1.9 christos general_symbol_info (rather than the name) as an out parameter. */
2259 1.9 christos
2260 1.9 christos extern bool find_pc_partial_function_sym
2261 1.8 christos (CORE_ADDR pc, const general_symbol_info **sym,
2262 1.8 christos CORE_ADDR *address, CORE_ADDR *endaddr,
2263 1.8 christos const struct block **block = nullptr);
2264 1.8 christos
2265 1.8 christos /* Like find_pc_partial_function, above, but *ADDRESS and *ENDADDR are
2266 1.8 christos set to start and end addresses of the range containing the entry pc.
2267 1.8 christos
2268 1.8 christos Note that it is not necessarily the case that (for non-NULL ADDRESS
2269 1.8 christos and ENDADDR arguments) the *ADDRESS <= PC < *ENDADDR condition will
2270 1.8 christos hold.
2271 1.8 christos
2272 1.8 christos See comment for find_pc_partial_function, above, for further
2273 1.8 christos explanation. */
2274 1.1 christos
2275 1.8 christos extern bool find_function_entry_range_from_pc (CORE_ADDR pc,
2276 1.1 christos const char **name,
2277 1.8 christos CORE_ADDR *address,
2278 1.8 christos CORE_ADDR *endaddr);
2279 1.1 christos
2280 1.8 christos /* Return the type of a function with its first instruction exactly at
2281 1.8 christos the PC address. Return NULL otherwise. */
2282 1.8 christos
2283 1.8 christos extern struct type *find_function_type (CORE_ADDR pc);
2284 1.8 christos
2285 1.8 christos /* See if we can figure out the function's actual type from the type
2286 1.8 christos that the resolver returns. RESOLVER_FUNADDR is the address of the
2287 1.8 christos ifunc resolver. */
2288 1.8 christos
2289 1.8 christos extern struct type *find_gnu_ifunc_target_type (CORE_ADDR resolver_funaddr);
2290 1.1 christos
2291 1.1 christos /* Find the GNU ifunc minimal symbol that matches SYM. */
2292 1.1 christos extern bound_minimal_symbol find_gnu_ifunc (const symbol *sym);
2293 1.1 christos
2294 1.1 christos extern void clear_pc_function_cache (void);
2295 1.3 christos
2296 1.1 christos /* lookup full symbol table by address. */
2297 1.1 christos
2298 1.1 christos extern struct compunit_symtab *find_pc_compunit_symtab (CORE_ADDR);
2299 1.3 christos
2300 1.3 christos /* lookup full symbol table by address and section. */
2301 1.1 christos
2302 1.9 christos extern struct compunit_symtab *
2303 1.1 christos find_pc_sect_compunit_symtab (CORE_ADDR, struct obj_section *);
2304 1.10 christos
2305 1.1 christos extern bool find_pc_line_pc_range (CORE_ADDR, CORE_ADDR *, CORE_ADDR *);
2306 1.3 christos
2307 1.3 christos extern void reread_symbols (int from_tty);
2308 1.3 christos
2309 1.3 christos /* Look up a type named NAME in STRUCT_DOMAIN in the current language.
2310 1.11 christos The type returned must not be opaque -- i.e., must have at least one field
2311 1.11 christos defined. */
2312 1.3 christos
2313 1.11 christos extern struct type *lookup_transparent_type
2314 1.11 christos (const char *name, domain_search_flags flags = SEARCH_STRUCT_DOMAIN);
2315 1.1 christos
2316 1.1 christos extern struct type *basic_lookup_transparent_type
2317 1.1 christos (const char *name, domain_search_flags flags = SEARCH_STRUCT_DOMAIN);
2318 1.1 christos
2319 1.1 christos /* Macro for name of symbol to indicate a file compiled with gcc. */
2320 1.1 christos #ifndef GCC_COMPILED_FLAG_SYMBOL
2321 1.1 christos #define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled."
2322 1.1 christos #endif
2323 1.1 christos
2324 1.1 christos /* Macro for name of symbol to indicate a file compiled with gcc2. */
2325 1.1 christos #ifndef GCC2_COMPILED_FLAG_SYMBOL
2326 1.9 christos #define GCC2_COMPILED_FLAG_SYMBOL "gcc2_compiled."
2327 1.1 christos #endif
2328 1.1 christos
2329 1.1 christos extern bool in_gnu_ifunc_stub (CORE_ADDR pc);
2330 1.1 christos
2331 1.1 christos /* Functions for resolving STT_GNU_IFUNC symbols which are implemented only
2332 1.1 christos for ELF symbol files. */
2333 1.1 christos
2334 1.1 christos struct gnu_ifunc_fns
2335 1.1 christos {
2336 1.1 christos /* See elf_gnu_ifunc_resolve_addr for its real implementation. */
2337 1.9 christos CORE_ADDR (*gnu_ifunc_resolve_addr) (struct gdbarch *gdbarch, CORE_ADDR pc);
2338 1.1 christos
2339 1.1 christos /* See elf_gnu_ifunc_resolve_name for its real implementation. */
2340 1.1 christos bool (*gnu_ifunc_resolve_name) (const char *function_name,
2341 1.10 christos CORE_ADDR *function_address_p);
2342 1.1 christos
2343 1.1 christos /* See elf_gnu_ifunc_resolver_stop for its real implementation. */
2344 1.10 christos void (*gnu_ifunc_resolver_stop) (code_breakpoint *b);
2345 1.1 christos
2346 1.1 christos /* See elf_gnu_ifunc_resolver_return_stop for its real implementation. */
2347 1.1 christos void (*gnu_ifunc_resolver_return_stop) (code_breakpoint *b);
2348 1.1 christos };
2349 1.1 christos
2350 1.1 christos #define gnu_ifunc_resolve_addr gnu_ifunc_fns_p->gnu_ifunc_resolve_addr
2351 1.1 christos #define gnu_ifunc_resolve_name gnu_ifunc_fns_p->gnu_ifunc_resolve_name
2352 1.1 christos #define gnu_ifunc_resolver_stop gnu_ifunc_fns_p->gnu_ifunc_resolver_stop
2353 1.1 christos #define gnu_ifunc_resolver_return_stop \
2354 1.1 christos gnu_ifunc_fns_p->gnu_ifunc_resolver_return_stop
2355 1.11 christos
2356 1.1 christos extern const struct gnu_ifunc_fns *gnu_ifunc_fns_p;
2357 1.1 christos
2358 1.1 christos extern CORE_ADDR find_solib_trampoline_target (const frame_info_ptr &, CORE_ADDR);
2359 1.1 christos
2360 1.8 christos struct symtab_and_line
2361 1.1 christos {
2362 1.8 christos /* The program space of this sal. */
2363 1.8 christos struct program_space *pspace = NULL;
2364 1.8 christos
2365 1.8 christos struct symtab *symtab = NULL;
2366 1.1 christos struct symbol *symbol = NULL;
2367 1.1 christos struct obj_section *section = NULL;
2368 1.1 christos struct minimal_symbol *msymbol = NULL;
2369 1.8 christos /* Line number. Line numbers start at 1 and proceed through symtab->nlines.
2370 1.1 christos 0 is never a valid line number; it is used to indicate that line number
2371 1.8 christos information is not available. */
2372 1.8 christos int line = 0;
2373 1.8 christos
2374 1.8 christos CORE_ADDR pc = 0;
2375 1.1 christos CORE_ADDR end = 0;
2376 1.9 christos bool explicit_pc = false;
2377 1.9 christos bool explicit_line = false;
2378 1.9 christos
2379 1.9 christos /* If the line number information is valid, then this indicates if this
2380 1.1 christos line table entry had the is-stmt flag set or not. */
2381 1.8 christos bool is_stmt = false;
2382 1.3 christos
2383 1.3 christos /* The probe associated with this symtab_and_line. */
2384 1.8 christos probe *prob = NULL;
2385 1.1 christos /* If PROBE is not NULL, then this is the objfile in which the probe
2386 1.1 christos originated. */
2387 1.1 christos struct objfile *objfile = NULL;
2388 1.1 christos };
2389 1.1 christos
2390 1.1 christos
2391 1.1 christos
2393 1.1 christos /* Given a pc value, return line number it is in. Second arg nonzero means
2394 1.1 christos if pc is on the boundary use the previous statement's line number. */
2395 1.1 christos
2396 1.1 christos extern struct symtab_and_line find_pc_line (CORE_ADDR, int);
2397 1.1 christos
2398 1.1 christos /* Same function, but specify a section as well as an address. */
2399 1.11 christos
2400 1.11 christos extern struct symtab_and_line find_pc_sect_line (CORE_ADDR,
2401 1.11 christos struct obj_section *, int);
2402 1.11 christos
2403 1.11 christos /* Given PC, and assuming it is part of a range of addresses that is part of
2404 1.11 christos a line, go back through the linetable and find the starting PC of that
2405 1.11 christos line.
2406 1.11 christos
2407 1.11 christos For example, suppose we have 3 PC ranges for line X:
2408 1.11 christos
2409 1.11 christos Line X - [0x0 - 0x8]
2410 1.11 christos Line X - [0x8 - 0x10]
2411 1.11 christos Line X - [0x10 - 0x18]
2412 1.11 christos
2413 1.11 christos If we call the function with PC == 0x14, we want to return 0x0, as that is
2414 1.11 christos the starting PC of line X, and the ranges are contiguous.
2415 1.3 christos */
2416 1.3 christos
2417 1.3 christos extern std::optional<CORE_ADDR> find_line_range_start (CORE_ADDR pc);
2418 1.3 christos
2419 1.1 christos /* Wrapper around find_pc_line to just return the symtab. */
2420 1.1 christos
2421 1.9 christos extern struct symtab *find_pc_line_symtab (CORE_ADDR);
2422 1.1 christos
2423 1.9 christos /* Given a symtab and line number, return the pc there. */
2424 1.9 christos
2425 1.1 christos extern bool find_line_pc (struct symtab *, int, CORE_ADDR *);
2426 1.1 christos
2427 1.1 christos extern bool find_line_pc_range (struct symtab_and_line, CORE_ADDR *,
2428 1.8 christos CORE_ADDR *);
2429 1.8 christos
2430 1.8 christos extern void resolve_sal_pc (struct symtab_and_line *);
2431 1.8 christos
2432 1.8 christos /* The reason we're calling into a completion match list collector
2433 1.8 christos function. */
2434 1.8 christos enum class complete_symbol_mode
2435 1.8 christos {
2436 1.8 christos /* Completing an expression. */
2437 1.8 christos EXPRESSION,
2438 1.1 christos
2439 1.8 christos /* Completing a linespec. */
2440 1.8 christos LINESPEC,
2441 1.8 christos };
2442 1.8 christos
2443 1.8 christos extern void default_collect_symbol_completion_matches_break_on
2444 1.8 christos (completion_tracker &tracker,
2445 1.8 christos complete_symbol_mode mode,
2446 1.8 christos symbol_name_match_type name_match_type,
2447 1.8 christos const char *text, const char *word, const char *break_on,
2448 1.8 christos enum type_code code);
2449 1.8 christos extern void collect_symbol_completion_matches
2450 1.8 christos (completion_tracker &tracker,
2451 1.8 christos complete_symbol_mode mode,
2452 1.8 christos symbol_name_match_type name_match_type,
2453 1.1 christos const char *, const char *);
2454 1.8 christos extern void collect_symbol_completion_matches_type (completion_tracker &tracker,
2455 1.8 christos const char *, const char *,
2456 1.8 christos enum type_code);
2457 1.8 christos
2458 1.8 christos extern void collect_file_symbol_completion_matches
2459 1.1 christos (completion_tracker &tracker,
2460 1.8 christos complete_symbol_mode,
2461 1.8 christos symbol_name_match_type name_match_type,
2462 1.1 christos const char *, const char *, const char *);
2463 1.8 christos
2464 1.1 christos extern completion_list
2465 1.8 christos make_source_files_completion_list (const char *, const char *);
2466 1.1 christos
2467 1.8 christos /* Return whether SYM is a function/method, as opposed to a data symbol. */
2468 1.8 christos
2469 1.1 christos extern bool symbol_is_function_or_method (symbol *sym);
2470 1.8 christos
2471 1.1 christos /* Return whether MSYMBOL is a function/method, as opposed to a data
2472 1.8 christos symbol */
2473 1.8 christos
2474 1.1 christos extern bool symbol_is_function_or_method (minimal_symbol *msymbol);
2475 1.8 christos
2476 1.8 christos /* Return whether SYM should be skipped in completion mode MODE. In
2477 1.8 christos linespec mode, we're only interested in functions/methods. */
2478 1.8 christos
2479 1.8 christos template<typename Symbol>
2480 1.8 christos static bool
2481 1.8 christos completion_skip_symbol (complete_symbol_mode mode, Symbol *sym)
2482 1.1 christos {
2483 1.1 christos return (mode == complete_symbol_mode::LINESPEC
2484 1.1 christos && !symbol_is_function_or_method (sym));
2485 1.9 christos }
2486 1.1 christos
2487 1.9 christos /* symtab.c */
2488 1.1 christos
2489 1.8 christos bool matching_obj_sections (struct obj_section *, struct obj_section *);
2490 1.8 christos
2491 1.8 christos extern struct symtab *find_line_symtab (struct symtab *, int, int *, bool *);
2492 1.8 christos
2493 1.8 christos /* Given a function symbol SYM, find the symtab and line for the start
2494 1.8 christos of the function. If FUNFIRSTLINE is true, we want the first line
2495 1.8 christos of real code inside the function. */
2496 1.8 christos extern symtab_and_line find_function_start_sal (symbol *sym, bool
2497 1.8 christos funfirstline);
2498 1.8 christos
2499 1.8 christos /* Same, but start with a function address/section instead of a
2500 1.1 christos symbol. */
2501 1.1 christos extern symtab_and_line find_function_start_sal (CORE_ADDR func_addr,
2502 1.1 christos obj_section *section,
2503 1.1 christos bool funfirstline);
2504 1.1 christos
2505 1.1 christos extern void skip_prologue_sal (struct symtab_and_line *);
2506 1.1 christos
2507 1.1 christos /* symtab.c */
2508 1.11 christos
2509 1.11 christos extern CORE_ADDR skip_prologue_using_sal (struct gdbarch *gdbarch,
2510 1.11 christos CORE_ADDR func_addr);
2511 1.11 christos
2512 1.11 christos /* If SYM requires a section index, find it either via minimal symbols
2513 1.11 christos or examining OBJFILE's sections. Note that SYM's current address
2514 1.1 christos must not have any runtime offsets applied. */
2515 1.8 christos
2516 1.8 christos extern void fixup_symbol_section (struct symbol *sym,
2517 1.8 christos struct objfile *objfile);
2518 1.8 christos
2519 1.8 christos /* If MSYMBOL is an text symbol, look for a function debug symbol with
2520 1.8 christos the same address. Returns NULL if not found. This is necessary in
2521 1.8 christos case a function is an alias to some other function, because debug
2522 1.1 christos information is only emitted for the alias target function's
2523 1.1 christos definition, not for the alias. */
2524 1.9 christos extern symbol *find_function_alias_target (bound_minimal_symbol msymbol);
2525 1.9 christos
2526 1.1 christos /* Symbol searching */
2527 1.1 christos
2528 1.11 christos /* When using the symbol_searcher struct to search for symbols, a vector of
2529 1.8 christos the following structs is returned. */
2530 1.8 christos struct symbol_search
2531 1.8 christos {
2532 1.8 christos symbol_search (block_enum block_, struct symbol *symbol_)
2533 1.8 christos : block (block_),
2534 1.8 christos symbol (symbol_)
2535 1.8 christos {
2536 1.11 christos msymbol.minsym = nullptr;
2537 1.8 christos msymbol.objfile = nullptr;
2538 1.8 christos }
2539 1.8 christos
2540 1.8 christos symbol_search (block_enum block_, struct minimal_symbol *minsym,
2541 1.8 christos struct objfile *objfile)
2542 1.8 christos : block (block_),
2543 1.8 christos symbol (nullptr)
2544 1.8 christos {
2545 1.8 christos msymbol.minsym = minsym;
2546 1.8 christos msymbol.objfile = objfile;
2547 1.8 christos }
2548 1.8 christos
2549 1.8 christos bool operator< (const symbol_search &other) const
2550 1.8 christos {
2551 1.8 christos return compare_search_syms (*this, other) < 0;
2552 1.8 christos }
2553 1.8 christos
2554 1.8 christos bool operator== (const symbol_search &other) const
2555 1.11 christos {
2556 1.11 christos return compare_search_syms (*this, other) == 0;
2557 1.11 christos }
2558 1.1 christos
2559 1.1 christos /* The block in which the match was found. Either STATIC_BLOCK or
2560 1.1 christos GLOBAL_BLOCK. */
2561 1.3 christos block_enum block;
2562 1.1 christos
2563 1.1 christos /* Information describing what was found.
2564 1.1 christos
2565 1.1 christos If symbol is NOT NULL, then information was found for this match. */
2566 1.1 christos struct symbol *symbol;
2567 1.1 christos
2568 1.8 christos /* If msymbol is non-null, then a match was made on something for
2569 1.8 christos which only minimal_symbols exist. */
2570 1.8 christos struct bound_minimal_symbol msymbol;
2571 1.8 christos
2572 1.1 christos private:
2573 1.1 christos
2574 1.9 christos static int compare_search_syms (const symbol_search &sym_a,
2575 1.9 christos const symbol_search &sym_b);
2576 1.9 christos };
2577 1.9 christos
2578 1.9 christos /* In order to search for global symbols of a particular kind matching
2579 1.9 christos particular regular expressions, create an instance of this structure and
2580 1.9 christos call the SEARCH member function. */
2581 1.9 christos class global_symbol_searcher
2582 1.11 christos {
2583 1.9 christos public:
2584 1.9 christos
2585 1.9 christos /* Constructor. */
2586 1.9 christos global_symbol_searcher (domain_search_flags kind,
2587 1.9 christos const char *symbol_name_regexp)
2588 1.9 christos : m_kind (kind),
2589 1.9 christos m_symbol_name_regexp (symbol_name_regexp)
2590 1.9 christos {
2591 1.9 christos }
2592 1.9 christos
2593 1.9 christos /* Set the optional regexp that matches against the symbol type. */
2594 1.9 christos void set_symbol_type_regexp (const char *regexp)
2595 1.9 christos {
2596 1.9 christos m_symbol_type_regexp = regexp;
2597 1.9 christos }
2598 1.9 christos
2599 1.9 christos /* Set the flag to exclude minsyms from the search results. */
2600 1.9 christos void set_exclude_minsyms (bool exclude_minsyms)
2601 1.9 christos {
2602 1.9 christos m_exclude_minsyms = exclude_minsyms;
2603 1.9 christos }
2604 1.9 christos
2605 1.9 christos /* Set the maximum number of search results to be returned. */
2606 1.9 christos void set_max_search_results (size_t max_search_results)
2607 1.9 christos {
2608 1.9 christos m_max_search_results = max_search_results;
2609 1.9 christos }
2610 1.9 christos
2611 1.9 christos /* Search the symbols from all objfiles in the current program space
2612 1.9 christos looking for matches as defined by the current state of this object.
2613 1.9 christos
2614 1.9 christos Within each file the results are sorted locally; each symtab's global
2615 1.9 christos and static blocks are separately alphabetized. Duplicate entries are
2616 1.9 christos removed. */
2617 1.9 christos std::vector<symbol_search> search () const;
2618 1.9 christos
2619 1.9 christos /* The set of source files to search in for matching symbols. This is
2620 1.9 christos currently public so that it can be populated after this object has
2621 1.9 christos been constructed. */
2622 1.9 christos std::vector<const char *> filenames;
2623 1.10 christos
2624 1.9 christos private:
2625 1.9 christos /* The kind of symbols are we searching for.
2626 1.9 christos VARIABLES_DOMAIN - Search all symbols, excluding functions, type
2627 1.9 christos names, and constants (enums).
2628 1.11 christos FUNCTIONS_DOMAIN - Search all functions..
2629 1.9 christos TYPES_DOMAIN - Search all type names.
2630 1.9 christos MODULES_DOMAIN - Search all Fortran modules.
2631 1.9 christos ALL_DOMAIN - Not valid for this function. */
2632 1.9 christos domain_search_flags m_kind;
2633 1.9 christos
2634 1.9 christos /* Regular expression to match against the symbol name. */
2635 1.9 christos const char *m_symbol_name_regexp = nullptr;
2636 1.9 christos
2637 1.9 christos /* Regular expression to match against the symbol type. */
2638 1.9 christos const char *m_symbol_type_regexp = nullptr;
2639 1.9 christos
2640 1.9 christos /* When this flag is false then minsyms that match M_SYMBOL_REGEXP will
2641 1.9 christos be included in the results, otherwise they are excluded. */
2642 1.9 christos bool m_exclude_minsyms = false;
2643 1.9 christos
2644 1.9 christos /* Maximum number of search results. We currently impose a hard limit
2645 1.9 christos of SIZE_MAX, there is no "unlimited". */
2646 1.9 christos size_t m_max_search_results = SIZE_MAX;
2647 1.9 christos
2648 1.11 christos /* Expand symtabs in OBJFILE that match PREG, are of type M_KIND. Return
2649 1.9 christos true if any msymbols were seen that we should later consider adding to
2650 1.9 christos the results list. */
2651 1.9 christos bool expand_symtabs (objfile *objfile,
2652 1.9 christos const std::optional<compiled_regex> &preg) const;
2653 1.9 christos
2654 1.9 christos /* Add symbols from symtabs in OBJFILE that match PREG, and TREG, and are
2655 1.9 christos of type M_KIND, to the results set RESULTS_SET. Return false if we
2656 1.9 christos stop adding results early due to having already found too many results
2657 1.11 christos (based on M_MAX_SEARCH_RESULTS limit), otherwise return true.
2658 1.11 christos Returning true does not indicate that any results were added, just
2659 1.9 christos that we didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS. */
2660 1.9 christos bool add_matching_symbols (objfile *objfile,
2661 1.9 christos const std::optional<compiled_regex> &preg,
2662 1.9 christos const std::optional<compiled_regex> &treg,
2663 1.9 christos std::set<symbol_search> *result_set) const;
2664 1.9 christos
2665 1.9 christos /* Add msymbols from OBJFILE that match PREG and M_KIND, to the results
2666 1.9 christos vector RESULTS. Return false if we stop adding results early due to
2667 1.9 christos having already found too many results (based on max search results
2668 1.11 christos limit M_MAX_SEARCH_RESULTS), otherwise return true. Returning true
2669 1.9 christos does not indicate that any results were added, just that we didn't
2670 1.9 christos _not_ add a result due to reaching MAX_SEARCH_RESULTS. */
2671 1.9 christos bool add_matching_msymbols (objfile *objfile,
2672 1.11 christos const std::optional<compiled_regex> &preg,
2673 1.9 christos std::vector<symbol_search> *results) const;
2674 1.9 christos
2675 1.9 christos /* Return true if MSYMBOL is of type KIND. */
2676 1.9 christos static bool is_suitable_msymbol (const domain_search_flags kind,
2677 1.9 christos const minimal_symbol *msymbol);
2678 1.9 christos };
2679 1.9 christos
2680 1.9 christos /* When searching for Fortran symbols within modules (functions/variables)
2681 1.9 christos we return a vector of this type. The first item in the pair is the
2682 1.9 christos module symbol, and the second item is the symbol for the function or
2683 1.9 christos variable we found. */
2684 1.9 christos typedef std::pair<symbol_search, symbol_search> module_symbol_search;
2685 1.9 christos
2686 1.9 christos /* Searches the symbols to find function and variables symbols (depending
2687 1.9 christos on KIND) within Fortran modules. The MODULE_REGEXP matches against the
2688 1.9 christos name of the module, REGEXP matches against the name of the symbol within
2689 1.11 christos the module, and TYPE_REGEXP matches against the type of the symbol
2690 1.9 christos within the module. */
2691 1.9 christos extern std::vector<module_symbol_search> search_module_symbols
2692 1.9 christos (const char *module_regexp, const char *regexp,
2693 1.11 christos const char *type_regexp, domain_search_flags kind);
2694 1.9 christos
2695 1.11 christos /* Convert a global or static symbol SYM (based on BLOCK, which should be
2696 1.9 christos either GLOBAL_BLOCK or STATIC_BLOCK) into a string for use in 'info'
2697 1.8 christos type commands (e.g. 'info variables', 'info functions', etc). */
2698 1.8 christos
2699 1.1 christos extern std::string symbol_to_info_string (struct symbol *sym, int block);
2700 1.9 christos
2701 1.9 christos extern bool treg_matches_sym_type_name (const compiled_regex &treg,
2702 1.3 christos const struct symbol *sym);
2703 1.1 christos
2704 1.9 christos /* The name of the ``main'' function. */
2705 1.9 christos extern const char *main_name ();
2706 1.3 christos extern enum language main_language (void);
2707 1.3 christos
2708 1.9 christos /* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global or static blocks,
2709 1.6 christos as specified by BLOCK_INDEX.
2710 1.3 christos This searches MAIN_OBJFILE as well as any associated separate debug info
2711 1.6 christos objfiles of MAIN_OBJFILE.
2712 1.3 christos BLOCK_INDEX can be GLOBAL_BLOCK or STATIC_BLOCK.
2713 1.9 christos Upon success fixes up the symbol's section if necessary. */
2714 1.3 christos
2715 1.11 christos extern struct block_symbol
2716 1.1 christos lookup_global_symbol_from_objfile (struct objfile *main_objfile,
2717 1.1 christos enum block_enum block_index,
2718 1.1 christos const char *name,
2719 1.9 christos const domain_search_flags domain);
2720 1.1 christos
2721 1.1 christos /* Return 1 if the supplied producer string matches the ARM RealView
2722 1.1 christos compiler (armcc). */
2723 1.10 christos bool producer_is_realview (const char *producer);
2724 1.10 christos
2725 1.10 christos extern unsigned int symtab_create_debug;
2726 1.10 christos
2727 1.10 christos /* Print a "symtab-create" debug statement. */
2728 1.10 christos
2729 1.10 christos #define symtab_create_debug_printf(fmt, ...) \
2730 1.10 christos debug_prefixed_printf_cond (symtab_create_debug >= 1, "symtab-create", fmt, ##__VA_ARGS__)
2731 1.10 christos
2732 1.10 christos /* Print a verbose "symtab-create" debug statement, only if
2733 1.10 christos "set debug symtab-create" is set to 2 or higher. */
2734 1.3 christos
2735 1.3 christos #define symtab_create_debug_printf_v(fmt, ...) \
2736 1.10 christos debug_prefixed_printf_cond (symtab_create_debug >= 2, "symtab-create", fmt, ##__VA_ARGS__)
2737 1.10 christos
2738 1.10 christos extern unsigned int symbol_lookup_debug;
2739 1.10 christos
2740 1.10 christos /* Return true if symbol-lookup debug is turned on at all. */
2741 1.10 christos
2742 1.10 christos static inline bool
2743 1.10 christos symbol_lookup_debug_enabled ()
2744 1.10 christos {
2745 1.10 christos return symbol_lookup_debug > 0;
2746 1.10 christos }
2747 1.10 christos
2748 1.10 christos /* Return true if symbol-lookup debug is turned to verbose mode. */
2749 1.10 christos
2750 1.10 christos static inline bool
2751 1.10 christos symbol_lookup_debug_enabled_v ()
2752 1.10 christos {
2753 1.10 christos return symbol_lookup_debug > 1;
2754 1.10 christos }
2755 1.10 christos
2756 1.10 christos /* Print a "symbol-lookup" debug statement if symbol_lookup_debug is >= 1. */
2757 1.10 christos
2758 1.10 christos #define symbol_lookup_debug_printf(fmt, ...) \
2759 1.10 christos debug_prefixed_printf_cond (symbol_lookup_debug_enabled (), \
2760 1.10 christos "symbol-lookup", fmt, ##__VA_ARGS__)
2761 1.10 christos
2762 1.10 christos /* Print a "symbol-lookup" debug statement if symbol_lookup_debug is >= 2. */
2763 1.10 christos
2764 1.10 christos #define symbol_lookup_debug_printf_v(fmt, ...) \
2765 1.10 christos debug_prefixed_printf_cond (symbol_lookup_debug_enabled_v (), \
2766 1.10 christos "symbol-lookup", fmt, ##__VA_ARGS__)
2767 1.10 christos
2768 1.10 christos /* Print "symbol-lookup" enter/exit debug statements. */
2769 1.9 christos
2770 1.1 christos #define SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT \
2771 1.9 christos scoped_debug_enter_exit (symbol_lookup_debug_enabled, "symbol-lookup")
2772 1.9 christos
2773 1.1 christos extern bool basenames_may_differ;
2774 1.9 christos
2775 1.9 christos bool compare_filenames_for_search (const char *filename,
2776 1.6 christos const char *search_name);
2777 1.7 christos
2778 1.7 christos bool compare_glob_filenames_for_search (const char *filename,
2779 1.7 christos const char *search_name);
2780 1.7 christos
2781 1.7 christos bool iterate_over_some_symtabs (const char *name,
2782 1.1 christos const char *real_path,
2783 1.1 christos struct compunit_symtab *first,
2784 1.7 christos struct compunit_symtab *after_last,
2785 1.1 christos gdb::function_view<bool (symtab *)> callback);
2786 1.7 christos
2787 1.7 christos void iterate_over_symtabs (const char *name,
2788 1.11 christos gdb::function_view<bool (symtab *)> callback);
2789 1.7 christos
2790 1.7 christos
2791 1.7 christos std::vector<CORE_ADDR> find_pcs_for_symtab_line
2792 1.7 christos (struct symtab *symtab, int line, const linetable_entry **best_entry);
2793 1.7 christos
2794 1.7 christos /* Prototype for callbacks for LA_ITERATE_OVER_SYMBOLS. The callback
2795 1.8 christos is called once per matching symbol SYM. The callback should return
2796 1.1 christos true to indicate that LA_ITERATE_OVER_SYMBOLS should continue
2797 1.9 christos iterating, or false to indicate that the iteration should end. */
2798 1.9 christos
2799 1.9 christos typedef bool (symbol_found_callback_ftype) (struct block_symbol *bsym);
2800 1.9 christos
2801 1.9 christos /* Iterate over the symbols named NAME, matching DOMAIN, in BLOCK.
2802 1.9 christos
2803 1.9 christos For each symbol that matches, CALLBACK is called. The symbol is
2804 1.9 christos passed to the callback.
2805 1.9 christos
2806 1.9 christos If CALLBACK returns false, the iteration ends and this function
2807 1.8 christos returns false. Otherwise, the search continues, and the function
2808 1.11 christos eventually returns true. */
2809 1.7 christos
2810 1.7 christos bool iterate_over_symbols (const struct block *block,
2811 1.9 christos const lookup_name_info &name,
2812 1.9 christos const domain_search_flags domain,
2813 1.9 christos gdb::function_view<symbol_found_callback_ftype> callback);
2814 1.9 christos
2815 1.9 christos /* Like iterate_over_symbols, but if all calls to CALLBACK return
2816 1.9 christos true, then calls CALLBACK one additional time with a block_symbol
2817 1.9 christos that has a valid block but a NULL symbol. */
2818 1.11 christos
2819 1.9 christos bool iterate_over_symbols_terminated
2820 1.9 christos (const struct block *block,
2821 1.7 christos const lookup_name_info &name,
2822 1.7 christos const domain_search_flags domain,
2823 1.7 christos gdb::function_view<symbol_found_callback_ftype> callback);
2824 1.9 christos
2825 1.9 christos /* Storage type used by demangle_for_lookup. demangle_for_lookup
2826 1.7 christos either returns a const char * pointer that points to either of the
2827 1.7 christos fields of this type, or a pointer to the input NAME. This is done
2828 1.7 christos this way to avoid depending on the precise details of the storage
2829 1.7 christos for the string. */
2830 1.9 christos class demangle_result_storage
2831 1.9 christos {
2832 1.9 christos public:
2833 1.7 christos
2834 1.9 christos /* Swap the malloc storage to STR, and return a pointer to the
2835 1.9 christos beginning of the new string. */
2836 1.7 christos const char *set_malloc_ptr (gdb::unique_xmalloc_ptr<char> &&str)
2837 1.7 christos {
2838 1.7 christos m_malloc = std::move (str);
2839 1.7 christos return m_malloc.get ();
2840 1.7 christos }
2841 1.7 christos
2842 1.7 christos /* Set the malloc storage to now point at PTR. Any previous malloc
2843 1.7 christos storage is released. */
2844 1.7 christos const char *set_malloc_ptr (char *ptr)
2845 1.7 christos {
2846 1.7 christos m_malloc.reset (ptr);
2847 1.7 christos return ptr;
2848 1.7 christos }
2849 1.7 christos
2850 1.7 christos private:
2851 1.1 christos
2852 1.7 christos /* The storage. */
2853 1.7 christos gdb::unique_xmalloc_ptr<char> m_malloc;
2854 1.7 christos };
2855 1.1 christos
2856 1.8 christos const char *
2857 1.8 christos demangle_for_lookup (const char *name, enum language lang,
2858 1.8 christos demangle_result_storage &storage);
2859 1.9 christos
2860 1.9 christos /* Test to see if the symbol of language SYMBOL_LANGUAGE specified by
2861 1.9 christos SYMNAME (which is already demangled for C++ symbols) matches
2862 1.8 christos SYM_TEXT in the first SYM_TEXT_LEN characters. If so, add it to
2863 1.8 christos the current completion list and return true. Otherwise, return
2864 1.8 christos false. */
2865 1.8 christos bool completion_list_add_name (completion_tracker &tracker,
2866 1.8 christos language symbol_language,
2867 1.8 christos const char *symname,
2868 1.8 christos const lookup_name_info &lookup_name,
2869 1.8 christos const char *text, const char *word);
2870 1.8 christos
2871 1.8 christos /* A simple symbol searching class. */
2872 1.8 christos
2873 1.8 christos class symbol_searcher
2874 1.8 christos {
2875 1.8 christos public:
2876 1.8 christos /* Returns the symbols found for the search. */
2877 1.8 christos const std::vector<block_symbol> &
2878 1.8 christos matching_symbols () const
2879 1.8 christos {
2880 1.8 christos return m_symbols;
2881 1.8 christos }
2882 1.8 christos
2883 1.8 christos /* Returns the minimal symbols found for the search. */
2884 1.8 christos const std::vector<bound_minimal_symbol> &
2885 1.8 christos matching_msymbols () const
2886 1.8 christos {
2887 1.8 christos return m_minimal_symbols;
2888 1.8 christos }
2889 1.8 christos
2890 1.8 christos /* Search for all symbols named NAME in LANGUAGE with DOMAIN, restricting
2891 1.11 christos search to FILE_SYMTABS and SEARCH_PSPACE, both of which may be NULL
2892 1.8 christos to search all symtabs and program spaces. */
2893 1.8 christos void find_all_symbols (const std::string &name,
2894 1.8 christos const struct language_defn *language,
2895 1.8 christos domain_search_flags domain_search_flags,
2896 1.8 christos std::vector<symtab *> *search_symtabs,
2897 1.8 christos struct program_space *search_pspace);
2898 1.8 christos
2899 1.8 christos /* Reset this object to perform another search. */
2900 1.8 christos void reset ()
2901 1.8 christos {
2902 1.8 christos m_symbols.clear ();
2903 1.8 christos m_minimal_symbols.clear ();
2904 1.8 christos }
2905 1.8 christos
2906 1.8 christos private:
2907 1.8 christos /* Matching debug symbols. */
2908 1.8 christos std::vector<block_symbol> m_symbols;
2909 1.8 christos
2910 1.10 christos /* Matching non-debug symbols. */
2911 1.10 christos std::vector<bound_minimal_symbol> m_minimal_symbols;
2912 1.10 christos };
2913 1.10 christos
2914 1.10 christos /* Class used to encapsulate the filename filtering for the "info sources"
2915 1.10 christos command. */
2916 1.10 christos
2917 1.10 christos struct info_sources_filter
2918 1.10 christos {
2919 1.10 christos /* If filename filtering is being used (see M_C_REGEXP) then which part
2920 1.10 christos of the filename is being filtered against? */
2921 1.10 christos enum class match_on
2922 1.10 christos {
2923 1.10 christos /* Match against the full filename. */
2924 1.10 christos FULLNAME,
2925 1.10 christos
2926 1.10 christos /* Match only against the directory part of the full filename. */
2927 1.10 christos DIRNAME,
2928 1.10 christos
2929 1.10 christos /* Match only against the basename part of the full filename. */
2930 1.10 christos BASENAME
2931 1.10 christos };
2932 1.10 christos
2933 1.10 christos /* Create a filter of MATCH_TYPE using regular expression REGEXP. If
2934 1.10 christos REGEXP is nullptr then all files will match the filter and MATCH_TYPE
2935 1.10 christos is ignored.
2936 1.10 christos
2937 1.10 christos The string pointed too by REGEXP must remain live and unchanged for
2938 1.10 christos this lifetime of this object as the object only retains a copy of the
2939 1.10 christos pointer. */
2940 1.10 christos info_sources_filter (match_on match_type, const char *regexp);
2941 1.10 christos
2942 1.10 christos DISABLE_COPY_AND_ASSIGN (info_sources_filter);
2943 1.10 christos
2944 1.10 christos /* Does FULLNAME match the filter defined by this object, return true if
2945 1.10 christos it does, otherwise, return false. If there is no filtering defined
2946 1.10 christos then this function will always return true. */
2947 1.10 christos bool matches (const char *fullname) const;
2948 1.10 christos
2949 1.10 christos private:
2950 1.10 christos
2951 1.10 christos /* The type of filtering in place. */
2952 1.10 christos match_on m_match_type;
2953 1.10 christos
2954 1.10 christos /* Points to the original regexp used to create this filter. */
2955 1.11 christos const char *m_regexp;
2956 1.10 christos
2957 1.10 christos /* A compiled version of M_REGEXP. This object is only given a value if
2958 1.10 christos M_REGEXP is not nullptr and is not the empty string. */
2959 1.10 christos std::optional<compiled_regex> m_c_regexp;
2960 1.10 christos };
2961 1.10 christos
2962 1.10 christos /* Perform the core of the 'info sources' command.
2963 1.10 christos
2964 1.10 christos FILTER is used to perform regular expression based filtering on the
2965 1.10 christos source files that will be displayed.
2966 1.10 christos
2967 1.10 christos Output is written to UIOUT in CLI or MI style as appropriate. */
2968 1.10 christos
2969 1.11 christos extern void info_sources_worker (struct ui_out *uiout,
2970 1.11 christos bool group_by_objfile,
2971 1.11 christos const info_sources_filter &filter);
2972 1.11 christos
2973 1.11 christos /* This function returns the address at which the function epilogue begins,
2974 1.11 christos according to the linetable.
2975 1.11 christos
2976 1.11 christos Returns an empty optional if EPILOGUE_BEGIN is never set in the
2977 1.1 christos linetable. */
2978
2979 std::optional<CORE_ADDR> find_epilogue_using_linetable (CORE_ADDR func_addr);
2980
2981 #endif /* !defined(SYMTAB_H) */
2982