Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Symbol table definitions for GDB. |
1bac305b | 2 | |
42a4f53d | 3 | Copyright (C) 1986-2019 Free Software Foundation, Inc. |
c906108c | 4 | |
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 9 | the Free Software Foundation; either version 3 of the License, or |
c5aa993b | 10 | (at your option) any later version. |
c906108c | 11 | |
c5aa993b JM |
12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
c906108c | 16 | |
c5aa993b | 17 | You should have received a copy of the GNU General Public License |
a9762ec7 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c SS |
19 | |
20 | #if !defined (SYMTAB_H) | |
21 | #define SYMTAB_H 1 | |
22 | ||
a014b87a | 23 | #include <array> |
67d89901 | 24 | #include <vector> |
b5ec771e | 25 | #include <string> |
268a13a5 | 26 | #include "gdbsupport/gdb_vecs.h" |
2f68a895 | 27 | #include "gdbtypes.h" |
468c0cbb | 28 | #include "gdb_obstack.h" |
12615cba | 29 | #include "gdb_regex.h" |
268a13a5 TT |
30 | #include "gdbsupport/enum-flags.h" |
31 | #include "gdbsupport/function-view.h" | |
32 | #include "gdbsupport/gdb_optional.h" | |
31edb802 | 33 | #include "gdbsupport/gdb_string_view.h" |
268a13a5 | 34 | #include "gdbsupport/next-iterator.h" |
eb3ff9a5 | 35 | #include "completer.h" |
f8eba3c6 | 36 | |
5f8a3188 | 37 | /* Opaque declarations. */ |
da3331ec AC |
38 | struct ui_file; |
39 | struct frame_info; | |
40 | struct symbol; | |
5f8a3188 | 41 | struct obstack; |
6a2f5abf | 42 | struct objfile; |
fe898f56 DC |
43 | struct block; |
44 | struct blockvector; | |
4c2df51b DJ |
45 | struct axs_value; |
46 | struct agent_expr; | |
6c95b8df | 47 | struct program_space; |
66a17cb6 | 48 | struct language_defn; |
4357ac6c | 49 | struct common_block; |
06096720 AB |
50 | struct obj_section; |
51 | struct cmd_list_element; | |
935676c9 | 52 | class probe; |
b5ec771e PA |
53 | struct lookup_name_info; |
54 | ||
55 | /* How to match a lookup name against a symbol search name. */ | |
56 | enum class symbol_name_match_type | |
57 | { | |
58 | /* Wild matching. Matches unqualified symbol names in all | |
59 | namespace/module/packages, etc. */ | |
60 | WILD, | |
61 | ||
62 | /* Full matching. The lookup name indicates a fully-qualified name, | |
63 | and only matches symbol search names in the specified | |
64 | namespace/module/package. */ | |
65 | FULL, | |
66 | ||
de63c46b PA |
67 | /* Search name matching. This is like FULL, but the search name did |
68 | not come from the user; instead it is already a search name | |
69 | retrieved from a SYMBOL_SEARCH_NAME/MSYMBOL_SEARCH_NAME call. | |
70 | For Ada, this avoids re-encoding an already-encoded search name | |
71 | (which would potentially incorrectly lowercase letters in the | |
72 | linkage/search name that should remain uppercase). For C++, it | |
73 | avoids trying to demangle a name we already know is | |
74 | demangled. */ | |
75 | SEARCH_NAME, | |
76 | ||
b5ec771e PA |
77 | /* Expression matching. The same as FULL matching in most |
78 | languages. The same as WILD matching in Ada. */ | |
79 | EXPRESSION, | |
80 | }; | |
81 | ||
82 | /* Hash the given symbol search name according to LANGUAGE's | |
83 | rules. */ | |
84 | extern unsigned int search_name_hash (enum language language, | |
85 | const char *search_name); | |
86 | ||
87 | /* Ada-specific bits of a lookup_name_info object. This is lazily | |
88 | constructed on demand. */ | |
89 | ||
90 | class ada_lookup_name_info final | |
91 | { | |
92 | public: | |
93 | /* Construct. */ | |
94 | explicit ada_lookup_name_info (const lookup_name_info &lookup_name); | |
95 | ||
96 | /* Compare SYMBOL_SEARCH_NAME with our lookup name, using MATCH_TYPE | |
97 | as name match type. Returns true if there's a match, false | |
98 | otherwise. If non-NULL, store the matching results in MATCH. */ | |
99 | bool matches (const char *symbol_search_name, | |
100 | symbol_name_match_type match_type, | |
a207cff2 | 101 | completion_match_result *comp_match_res) const; |
b5ec771e PA |
102 | |
103 | /* The Ada-encoded lookup name. */ | |
104 | const std::string &lookup_name () const | |
105 | { return m_encoded_name; } | |
106 | ||
107 | /* Return true if we're supposed to be doing a wild match look | |
108 | up. */ | |
109 | bool wild_match_p () const | |
110 | { return m_wild_match_p; } | |
111 | ||
112 | /* Return true if we're looking up a name inside package | |
113 | Standard. */ | |
114 | bool standard_p () const | |
115 | { return m_standard_p; } | |
116 | ||
c63d3e8d PA |
117 | /* Return true if doing a verbatim match. */ |
118 | bool verbatim_p () const | |
119 | { return m_verbatim_p; } | |
120 | ||
121 | private: | |
b5ec771e PA |
122 | /* The Ada-encoded lookup name. */ |
123 | std::string m_encoded_name; | |
124 | ||
125 | /* Whether the user-provided lookup name was Ada encoded. If so, | |
126 | then return encoded names in the 'matches' method's 'completion | |
127 | match result' output. */ | |
128 | bool m_encoded_p : 1; | |
129 | ||
130 | /* True if really doing wild matching. Even if the user requests | |
131 | wild matching, some cases require full matching. */ | |
132 | bool m_wild_match_p : 1; | |
133 | ||
134 | /* True if doing a verbatim match. This is true if the decoded | |
135 | version of the symbol name is wrapped in '<'/'>'. This is an | |
136 | escape hatch users can use to look up symbols the Ada encoding | |
137 | does not understand. */ | |
138 | bool m_verbatim_p : 1; | |
139 | ||
140 | /* True if the user specified a symbol name that is inside package | |
141 | Standard. Symbol names inside package Standard are handled | |
142 | specially. We always do a non-wild match of the symbol name | |
143 | without the "standard__" prefix, and only search static and | |
144 | global symbols. This was primarily introduced in order to allow | |
145 | the user to specifically access the standard exceptions using, | |
146 | for instance, Standard.Constraint_Error when Constraint_Error is | |
147 | ambiguous (due to the user defining its own Constraint_Error | |
148 | entity inside its program). */ | |
149 | bool m_standard_p : 1; | |
150 | }; | |
151 | ||
152 | /* Language-specific bits of a lookup_name_info object, for languages | |
153 | that do name searching using demangled names (C++/D/Go). This is | |
154 | lazily constructed on demand. */ | |
155 | ||
156 | struct demangle_for_lookup_info final | |
157 | { | |
158 | public: | |
159 | demangle_for_lookup_info (const lookup_name_info &lookup_name, | |
160 | language lang); | |
161 | ||
162 | /* The demangled lookup name. */ | |
163 | const std::string &lookup_name () const | |
164 | { return m_demangled_name; } | |
165 | ||
166 | private: | |
167 | /* The demangled lookup name. */ | |
168 | std::string m_demangled_name; | |
169 | }; | |
170 | ||
171 | /* Object that aggregates all information related to a symbol lookup | |
172 | name. I.e., the name that is matched against the symbol's search | |
173 | name. Caches per-language information so that it doesn't require | |
174 | recomputing it for every symbol comparison, like for example the | |
175 | Ada encoded name and the symbol's name hash for a given language. | |
176 | The object is conceptually immutable once constructed, and thus has | |
177 | no setters. This is to prevent some code path from tweaking some | |
178 | property of the lookup name for some local reason and accidentally | |
179 | altering the results of any continuing search(es). | |
180 | lookup_name_info objects are generally passed around as a const | |
181 | reference to reinforce that. (They're not passed around by value | |
182 | because they're not small.) */ | |
183 | class lookup_name_info final | |
184 | { | |
185 | public: | |
186 | /* Create a new object. */ | |
187 | lookup_name_info (std::string name, | |
188 | symbol_name_match_type match_type, | |
c62446b1 PA |
189 | bool completion_mode = false, |
190 | bool ignore_parameters = false) | |
b5ec771e PA |
191 | : m_match_type (match_type), |
192 | m_completion_mode (completion_mode), | |
c62446b1 | 193 | m_ignore_parameters (ignore_parameters), |
b5ec771e PA |
194 | m_name (std::move (name)) |
195 | {} | |
196 | ||
197 | /* Getters. See description of each corresponding field. */ | |
198 | symbol_name_match_type match_type () const { return m_match_type; } | |
199 | bool completion_mode () const { return m_completion_mode; } | |
200 | const std::string &name () const { return m_name; } | |
c62446b1 PA |
201 | const bool ignore_parameters () const { return m_ignore_parameters; } |
202 | ||
203 | /* Return a version of this lookup name that is usable with | |
204 | comparisons against symbols have no parameter info, such as | |
205 | psymbols and GDB index symbols. */ | |
206 | lookup_name_info make_ignore_params () const | |
207 | { | |
208 | return lookup_name_info (m_name, m_match_type, m_completion_mode, | |
209 | true /* ignore params */); | |
210 | } | |
b5ec771e PA |
211 | |
212 | /* Get the search name hash for searches in language LANG. */ | |
213 | unsigned int search_name_hash (language lang) const | |
214 | { | |
215 | /* Only compute each language's hash once. */ | |
216 | if (!m_demangled_hashes_p[lang]) | |
217 | { | |
218 | m_demangled_hashes[lang] | |
219 | = ::search_name_hash (lang, language_lookup_name (lang).c_str ()); | |
220 | m_demangled_hashes_p[lang] = true; | |
221 | } | |
222 | return m_demangled_hashes[lang]; | |
223 | } | |
224 | ||
225 | /* Get the search name for searches in language LANG. */ | |
226 | const std::string &language_lookup_name (language lang) const | |
227 | { | |
228 | switch (lang) | |
229 | { | |
230 | case language_ada: | |
231 | return ada ().lookup_name (); | |
232 | case language_cplus: | |
233 | return cplus ().lookup_name (); | |
234 | case language_d: | |
235 | return d ().lookup_name (); | |
236 | case language_go: | |
237 | return go ().lookup_name (); | |
238 | default: | |
239 | return m_name; | |
240 | } | |
241 | } | |
242 | ||
243 | /* Get the Ada-specific lookup info. */ | |
244 | const ada_lookup_name_info &ada () const | |
245 | { | |
246 | maybe_init (m_ada); | |
247 | return *m_ada; | |
248 | } | |
249 | ||
250 | /* Get the C++-specific lookup info. */ | |
251 | const demangle_for_lookup_info &cplus () const | |
252 | { | |
253 | maybe_init (m_cplus, language_cplus); | |
254 | return *m_cplus; | |
255 | } | |
256 | ||
257 | /* Get the D-specific lookup info. */ | |
258 | const demangle_for_lookup_info &d () const | |
259 | { | |
260 | maybe_init (m_d, language_d); | |
261 | return *m_d; | |
262 | } | |
263 | ||
264 | /* Get the Go-specific lookup info. */ | |
265 | const demangle_for_lookup_info &go () const | |
266 | { | |
267 | maybe_init (m_go, language_go); | |
268 | return *m_go; | |
269 | } | |
270 | ||
271 | /* Get a reference to a lookup_name_info object that matches any | |
272 | symbol name. */ | |
273 | static const lookup_name_info &match_any (); | |
274 | ||
275 | private: | |
276 | /* Initialize FIELD, if not initialized yet. */ | |
277 | template<typename Field, typename... Args> | |
278 | void maybe_init (Field &field, Args&&... args) const | |
279 | { | |
280 | if (!field) | |
281 | field.emplace (*this, std::forward<Args> (args)...); | |
282 | } | |
283 | ||
284 | /* The lookup info as passed to the ctor. */ | |
285 | symbol_name_match_type m_match_type; | |
286 | bool m_completion_mode; | |
c62446b1 | 287 | bool m_ignore_parameters; |
b5ec771e PA |
288 | std::string m_name; |
289 | ||
290 | /* Language-specific info. These fields are filled lazily the first | |
291 | time a lookup is done in the corresponding language. They're | |
292 | mutable because lookup_name_info objects are typically passed | |
293 | around by const reference (see intro), and they're conceptually | |
294 | "cache" that can always be reconstructed from the non-mutable | |
295 | fields. */ | |
296 | mutable gdb::optional<ada_lookup_name_info> m_ada; | |
297 | mutable gdb::optional<demangle_for_lookup_info> m_cplus; | |
298 | mutable gdb::optional<demangle_for_lookup_info> m_d; | |
299 | mutable gdb::optional<demangle_for_lookup_info> m_go; | |
300 | ||
301 | /* The demangled hashes. Stored in an array with one entry for each | |
302 | possible language. The second array records whether we've | |
303 | already computed the each language's hash. (These are separate | |
304 | arrays instead of a single array of optional<unsigned> to avoid | |
305 | alignment padding). */ | |
306 | mutable std::array<unsigned int, nr_languages> m_demangled_hashes; | |
307 | mutable std::array<bool, nr_languages> m_demangled_hashes_p {}; | |
308 | }; | |
309 | ||
310 | /* Comparison function for completion symbol lookup. | |
311 | ||
312 | Returns true if the symbol name matches against LOOKUP_NAME. | |
313 | ||
314 | SYMBOL_SEARCH_NAME should be a symbol's "search" name. | |
315 | ||
a207cff2 PA |
316 | On success and if non-NULL, COMP_MATCH_RES->match is set to point |
317 | to the symbol name as should be presented to the user as a | |
318 | completion match list element. In most languages, this is the same | |
319 | as the symbol's search name, but in some, like Ada, the display | |
320 | name is dynamically computed within the comparison routine. | |
321 | ||
322 | Also, on success and if non-NULL, COMP_MATCH_RES->match_for_lcd | |
323 | points the part of SYMBOL_SEARCH_NAME that was considered to match | |
324 | LOOKUP_NAME. E.g., in C++, in linespec/wild mode, if the symbol is | |
325 | "foo::function()" and LOOKUP_NAME is "function(", MATCH_FOR_LCD | |
326 | points to "function()" inside SYMBOL_SEARCH_NAME. */ | |
b5ec771e PA |
327 | typedef bool (symbol_name_matcher_ftype) |
328 | (const char *symbol_search_name, | |
329 | const lookup_name_info &lookup_name, | |
a207cff2 | 330 | completion_match_result *comp_match_res); |
c906108c | 331 | |
a7f19c79 MC |
332 | /* Some of the structures in this file are space critical. |
333 | The space-critical structures are: | |
334 | ||
335 | struct general_symbol_info | |
336 | struct symbol | |
337 | struct partial_symbol | |
338 | ||
5bccb4d1 | 339 | These structures are laid out to encourage good packing. |
a7f19c79 MC |
340 | They use ENUM_BITFIELD and short int fields, and they order the |
341 | structure members so that fields less than a word are next | |
c378eb4e | 342 | to each other so they can be packed together. */ |
a7f19c79 MC |
343 | |
344 | /* Rearranged: used ENUM_BITFIELD and rearranged field order in | |
345 | all the space critical structures (plus struct minimal_symbol). | |
346 | Memory usage dropped from 99360768 bytes to 90001408 bytes. | |
347 | I measured this with before-and-after tests of | |
348 | "HEAD-old-gdb -readnow HEAD-old-gdb" and | |
349 | "HEAD-new-gdb -readnow HEAD-old-gdb" on native i686-pc-linux-gnu, | |
350 | red hat linux 8, with LD_LIBRARY_PATH=/usr/lib/debug, | |
351 | typing "maint space 1" at the first command prompt. | |
352 | ||
353 | Here is another measurement (from andrew c): | |
354 | # no /usr/lib/debug, just plain glibc, like a normal user | |
355 | gdb HEAD-old-gdb | |
356 | (gdb) break internal_error | |
357 | (gdb) run | |
358 | (gdb) maint internal-error | |
359 | (gdb) backtrace | |
360 | (gdb) maint space 1 | |
361 | ||
362 | gdb gdb_6_0_branch 2003-08-19 space used: 8896512 | |
363 | gdb HEAD 2003-08-19 space used: 8904704 | |
364 | gdb HEAD 2003-08-21 space used: 8396800 (+symtab.h) | |
365 | gdb HEAD 2003-08-21 space used: 8265728 (+gdbtypes.h) | |
366 | ||
367 | The third line shows the savings from the optimizations in symtab.h. | |
368 | The fourth line shows the savings from the optimizations in | |
369 | gdbtypes.h. Both optimizations are in gdb HEAD now. | |
370 | ||
371 | --chastain 2003-08-21 */ | |
372 | ||
c906108c SS |
373 | /* Define a structure for the information that is common to all symbol types, |
374 | including minimal symbols, partial symbols, and full symbols. In a | |
375 | multilanguage environment, some language specific information may need to | |
c378eb4e | 376 | be recorded along with each symbol. */ |
c906108c | 377 | |
c378eb4e | 378 | /* This structure is space critical. See space comments at the top. */ |
c906108c SS |
379 | |
380 | struct general_symbol_info | |
17c5ed2c | 381 | { |
22abf04a | 382 | /* Name of the symbol. This is a required field. Storage for the |
4a146b47 EZ |
383 | name is allocated on the objfile_obstack for the associated |
384 | objfile. For languages like C++ that make a distinction between | |
385 | the mangled name and demangled name, this is the mangled | |
386 | name. */ | |
c906108c | 387 | |
0d5cff50 | 388 | const char *name; |
c906108c | 389 | |
17c5ed2c DC |
390 | /* Value of the symbol. Which member of this union to use, and what |
391 | it means, depends on what kind of symbol this is and its | |
392 | SYMBOL_CLASS. See comments there for more details. All of these | |
393 | are in host byte order (though what they point to might be in | |
394 | target byte order, e.g. LOC_CONST_BYTES). */ | |
c906108c | 395 | |
17c5ed2c DC |
396 | union |
397 | { | |
12df843f | 398 | LONGEST ivalue; |
c906108c | 399 | |
3977b71f | 400 | const struct block *block; |
c906108c | 401 | |
d47a1bc1 | 402 | const gdb_byte *bytes; |
c906108c | 403 | |
17c5ed2c | 404 | CORE_ADDR address; |
c906108c | 405 | |
5a352474 | 406 | /* A common block. Used with LOC_COMMON_BLOCK. */ |
4357ac6c | 407 | |
17a40b44 | 408 | const struct common_block *common_block; |
4357ac6c | 409 | |
c378eb4e | 410 | /* For opaque typedef struct chain. */ |
c906108c | 411 | |
17c5ed2c DC |
412 | struct symbol *chain; |
413 | } | |
414 | value; | |
c906108c | 415 | |
17c5ed2c | 416 | /* Since one and only one language can apply, wrap the language specific |
29df156d | 417 | information inside a union. */ |
c906108c | 418 | |
17c5ed2c DC |
419 | union |
420 | { | |
f85f34ed TT |
421 | /* A pointer to an obstack that can be used for storage associated |
422 | with this symbol. This is only used by Ada, and only when the | |
423 | 'ada_mangled' field is zero. */ | |
424 | struct obstack *obstack; | |
425 | ||
afa16725 | 426 | /* This is used by languages which wish to store a demangled name. |
9c37b5ae | 427 | currently used by Ada, C++, and Objective C. */ |
615b3f62 | 428 | const char *demangled_name; |
17c5ed2c DC |
429 | } |
430 | language_specific; | |
c5aa993b | 431 | |
17c5ed2c DC |
432 | /* Record the source code language that applies to this symbol. |
433 | This is used to select one of the fields from the language specific | |
c378eb4e | 434 | union above. */ |
c5aa993b | 435 | |
51cdc993 | 436 | ENUM_BITFIELD(language) language : LANGUAGE_BITS; |
c5aa993b | 437 | |
a04a15f5 | 438 | /* This is only used by Ada. If set, then the 'demangled_name' field |
f85f34ed TT |
439 | of language_specific is valid. Otherwise, the 'obstack' field is |
440 | valid. */ | |
441 | unsigned int ada_mangled : 1; | |
442 | ||
17c5ed2c DC |
443 | /* Which section is this symbol in? This is an index into |
444 | section_offsets for this objfile. Negative means that the symbol | |
e27d198c | 445 | does not get relocated relative to a section. */ |
c5aa993b | 446 | |
17c5ed2c | 447 | short section; |
17c5ed2c | 448 | }; |
c906108c | 449 | |
3573abe1 CB |
450 | /* This struct is size-critical (see comment at the top), so this assert |
451 | makes sure the size doesn't change accidentally. Be careful when | |
452 | purposely increasing the size. */ | |
453 | gdb_static_assert ((sizeof (void *) == 8 && sizeof (general_symbol_info) == 32) | |
ade7beea CB |
454 | || (sizeof (void *) == 4 |
455 | && sizeof (general_symbol_info) == 20)); | |
3573abe1 | 456 | |
cfc594ee TT |
457 | extern void symbol_set_demangled_name (struct general_symbol_info *, |
458 | const char *, | |
ccde22c0 | 459 | struct obstack *); |
b250c185 | 460 | |
0d5cff50 DE |
461 | extern const char *symbol_get_demangled_name |
462 | (const struct general_symbol_info *); | |
b250c185 | 463 | |
714835d5 | 464 | extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *); |
c906108c | 465 | |
4b610737 TT |
466 | /* Return the address of SYM. The MAYBE_COPIED flag must be set on |
467 | SYM. If SYM appears in the main program's minimal symbols, then | |
468 | that minsym's address is returned; otherwise, SYM's address is | |
469 | returned. This should generally only be used via the | |
470 | SYMBOL_VALUE_ADDRESS macro. */ | |
471 | ||
472 | extern CORE_ADDR get_symbol_address (const struct symbol *sym); | |
473 | ||
468c0cbb | 474 | /* Note that these macros only work with symbol, not partial_symbol. */ |
88cda038 | 475 | |
468c0cbb | 476 | #define SYMBOL_VALUE(symbol) (symbol)->value.ivalue |
4b610737 TT |
477 | #define SYMBOL_VALUE_ADDRESS(symbol) \ |
478 | (((symbol)->maybe_copied) ? get_symbol_address (symbol) \ | |
468c0cbb | 479 | : ((symbol)->value.address)) |
38583298 | 480 | #define SET_SYMBOL_VALUE_ADDRESS(symbol, new_value) \ |
468c0cbb CB |
481 | ((symbol)->value.address = (new_value)) |
482 | #define SYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes | |
483 | #define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->value.common_block | |
484 | #define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block | |
485 | #define SYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain | |
486 | #define SYMBOL_LANGUAGE(symbol) (symbol)->language | |
487 | #define SYMBOL_SECTION(symbol) (symbol)->section | |
e27d198c | 488 | #define SYMBOL_OBJ_SECTION(objfile, symbol) \ |
468c0cbb CB |
489 | (((symbol)->section >= 0) \ |
490 | ? (&(((objfile)->sections)[(symbol)->section])) \ | |
e27d198c | 491 | : NULL) |
c906108c | 492 | |
89aad1f9 | 493 | /* Initializes the language dependent portion of a symbol |
c378eb4e | 494 | depending upon the language for the symbol. */ |
f85f34ed | 495 | #define SYMBOL_SET_LANGUAGE(symbol,language,obstack) \ |
468c0cbb | 496 | (symbol_set_language ((symbol), (language), (obstack))) |
33e5013e | 497 | extern void symbol_set_language (struct general_symbol_info *symbol, |
f85f34ed TT |
498 | enum language language, |
499 | struct obstack *obstack); | |
c906108c | 500 | |
3567439c DJ |
501 | /* Set just the linkage name of a symbol; do not try to demangle |
502 | it. Used for constructs which do not have a mangled name, | |
503 | e.g. struct tags. Unlike SYMBOL_SET_NAMES, linkage_name must | |
1c9e8358 TT |
504 | be terminated and either already on the objfile's obstack or |
505 | permanently allocated. */ | |
3567439c | 506 | #define SYMBOL_SET_LINKAGE_NAME(symbol,linkage_name) \ |
468c0cbb | 507 | (symbol)->name = (linkage_name) |
3567439c DJ |
508 | |
509 | /* Set the linkage and natural names of a symbol, by demangling | |
0c921b21 CB |
510 | the linkage name. If linkage_name may not be nullterminated, |
511 | copy_name must be set to true. */ | |
31edb802 | 512 | #define SYMBOL_SET_NAMES(symbol,linkage_name,copy_name,objfile) \ |
468c0cbb | 513 | symbol_set_names ((symbol), linkage_name, copy_name, \ |
1d94a5a3 | 514 | (objfile)->per_bfd) |
2de7ced7 | 515 | extern void symbol_set_names (struct general_symbol_info *symbol, |
31edb802 | 516 | gdb::string_view linkage_name, bool copy_name, |
1d94a5a3 | 517 | struct objfile_per_bfd_storage *per_bfd); |
2de7ced7 | 518 | |
22abf04a DC |
519 | /* Now come lots of name accessor macros. Short version as to when to |
520 | use which: Use SYMBOL_NATURAL_NAME to refer to the name of the | |
521 | symbol in the original source code. Use SYMBOL_LINKAGE_NAME if you | |
522 | want to know what the linker thinks the symbol's name is. Use | |
523 | SYMBOL_PRINT_NAME for output. Use SYMBOL_DEMANGLED_NAME if you | |
524 | specifically need to know whether SYMBOL_NATURAL_NAME and | |
3567439c | 525 | SYMBOL_LINKAGE_NAME are different. */ |
22abf04a DC |
526 | |
527 | /* Return SYMBOL's "natural" name, i.e. the name that it was called in | |
528 | the original source code. In languages like C++ where symbols may | |
529 | be mangled for ease of manipulation by the linker, this is the | |
530 | demangled name. */ | |
531 | ||
532 | #define SYMBOL_NATURAL_NAME(symbol) \ | |
468c0cbb | 533 | (symbol_natural_name ((symbol))) |
0d5cff50 DE |
534 | extern const char *symbol_natural_name |
535 | (const struct general_symbol_info *symbol); | |
22abf04a DC |
536 | |
537 | /* Return SYMBOL's name from the point of view of the linker. In | |
538 | languages like C++ where symbols may be mangled for ease of | |
539 | manipulation by the linker, this is the mangled name; otherwise, | |
3567439c | 540 | it's the same as SYMBOL_NATURAL_NAME. */ |
22abf04a | 541 | |
468c0cbb | 542 | #define SYMBOL_LINKAGE_NAME(symbol) (symbol)->name |
22abf04a | 543 | |
9cc0d196 | 544 | /* Return the demangled name for a symbol based on the language for |
c378eb4e | 545 | that symbol. If no demangled name exists, return NULL. */ |
9cc0d196 | 546 | #define SYMBOL_DEMANGLED_NAME(symbol) \ |
468c0cbb | 547 | (symbol_demangled_name ((symbol))) |
0d5cff50 DE |
548 | extern const char *symbol_demangled_name |
549 | (const struct general_symbol_info *symbol); | |
c906108c | 550 | |
de5ad195 DC |
551 | /* Macro that returns a version of the name of a symbol that is |
552 | suitable for output. In C++ this is the "demangled" form of the | |
553 | name if demangle is on and the "mangled" form of the name if | |
554 | demangle is off. In other languages this is just the symbol name. | |
555 | The result should never be NULL. Don't use this for internal | |
50f182aa DE |
556 | purposes (e.g. storing in a hashtable): it's only suitable for output. |
557 | ||
468c0cbb | 558 | N.B. symbol may be anything inheriting from general_symbol_info, |
50f182aa | 559 | e.g., struct symbol or struct minimal_symbol. */ |
de5ad195 DC |
560 | |
561 | #define SYMBOL_PRINT_NAME(symbol) \ | |
22abf04a | 562 | (demangle ? SYMBOL_NATURAL_NAME (symbol) : SYMBOL_LINKAGE_NAME (symbol)) |
491144b5 | 563 | extern bool demangle; |
c906108c | 564 | |
c378eb4e | 565 | /* Macro that returns the name to be used when sorting and searching symbols. |
9c37b5ae | 566 | In C++, we search for the demangled form of a name, |
4725b721 PH |
567 | and so sort symbols accordingly. In Ada, however, we search by mangled |
568 | name. If there is no distinct demangled name, then SYMBOL_SEARCH_NAME | |
c378eb4e | 569 | returns the same value (same pointer) as SYMBOL_LINKAGE_NAME. */ |
4725b721 | 570 | #define SYMBOL_SEARCH_NAME(symbol) \ |
468c0cbb | 571 | (symbol_search_name (symbol)) |
b5ec771e | 572 | extern const char *symbol_search_name (const struct general_symbol_info *ginfo); |
4725b721 | 573 | |
b5ec771e PA |
574 | /* Return true if NAME matches the "search" name of SYMBOL, according |
575 | to the symbol's language. */ | |
576 | #define SYMBOL_MATCHES_SEARCH_NAME(symbol, name) \ | |
468c0cbb | 577 | symbol_matches_search_name ((symbol), (name)) |
b5ec771e PA |
578 | |
579 | /* Helper for SYMBOL_MATCHES_SEARCH_NAME that works with both symbols | |
580 | and psymbols. */ | |
581 | extern bool symbol_matches_search_name | |
582 | (const struct general_symbol_info *gsymbol, | |
583 | const lookup_name_info &name); | |
4725b721 | 584 | |
5ffa0793 PA |
585 | /* Compute the hash of the given symbol search name of a symbol of |
586 | language LANGUAGE. */ | |
587 | extern unsigned int search_name_hash (enum language language, | |
588 | const char *search_name); | |
589 | ||
87193939 MC |
590 | /* Classification types for a minimal symbol. These should be taken as |
591 | "advisory only", since if gdb can't easily figure out a | |
592 | classification it simply selects mst_unknown. It may also have to | |
593 | guess when it can't figure out which is a better match between two | |
594 | types (mst_data versus mst_bss) for example. Since the minimal | |
595 | symbol info is sometimes derived from the BFD library's view of a | |
c378eb4e | 596 | file, we need to live with what information bfd supplies. */ |
87193939 MC |
597 | |
598 | enum minimal_symbol_type | |
599 | { | |
600 | mst_unknown = 0, /* Unknown type, the default */ | |
601 | mst_text, /* Generally executable instructions */ | |
f50776aa PA |
602 | |
603 | /* A GNU ifunc symbol, in the .text section. GDB uses to know | |
604 | whether the user is setting a breakpoint on a GNU ifunc function, | |
605 | and thus GDB needs to actually set the breakpoint on the target | |
606 | function. It is also used to know whether the program stepped | |
607 | into an ifunc resolver -- the resolver may get a separate | |
608 | symbol/alias under a different name, but it'll have the same | |
609 | address as the ifunc symbol. */ | |
610 | mst_text_gnu_ifunc, /* Executable code returning address | |
611 | of executable code */ | |
612 | ||
613 | /* A GNU ifunc function descriptor symbol, in a data section | |
614 | (typically ".opd"). Seen on architectures that use function | |
615 | descriptors, like PPC64/ELFv1. In this case, this symbol's value | |
616 | is the address of the descriptor. There'll be a corresponding | |
617 | mst_text_gnu_ifunc synthetic symbol for the text/entry | |
618 | address. */ | |
619 | mst_data_gnu_ifunc, /* Executable code returning address | |
0875794a | 620 | of executable code */ |
f50776aa | 621 | |
0875794a | 622 | mst_slot_got_plt, /* GOT entries for .plt sections */ |
87193939 MC |
623 | mst_data, /* Generally initialized data */ |
624 | mst_bss, /* Generally uninitialized data */ | |
625 | mst_abs, /* Generally absolute (nonrelocatable) */ | |
626 | /* GDB uses mst_solib_trampoline for the start address of a shared | |
627 | library trampoline entry. Breakpoints for shared library functions | |
628 | are put there if the shared library is not yet loaded. | |
629 | After the shared library is loaded, lookup_minimal_symbol will | |
630 | prefer the minimal symbol from the shared library (usually | |
631 | a mst_text symbol) over the mst_solib_trampoline symbol, and the | |
632 | breakpoints will be moved to their true address in the shared | |
633 | library via breakpoint_re_set. */ | |
634 | mst_solib_trampoline, /* Shared library trampoline code */ | |
635 | /* For the mst_file* types, the names are only guaranteed to be unique | |
636 | within a given .o file. */ | |
637 | mst_file_text, /* Static version of mst_text */ | |
638 | mst_file_data, /* Static version of mst_data */ | |
51cdc993 DE |
639 | mst_file_bss, /* Static version of mst_bss */ |
640 | nr_minsym_types | |
87193939 MC |
641 | }; |
642 | ||
51cdc993 DE |
643 | /* The number of enum minimal_symbol_type values, with some padding for |
644 | reasonable growth. */ | |
645 | #define MINSYM_TYPE_BITS 4 | |
646 | gdb_static_assert (nr_minsym_types <= (1 << MINSYM_TYPE_BITS)); | |
647 | ||
c906108c SS |
648 | /* Define a simple structure used to hold some very basic information about |
649 | all defined global symbols (text, data, bss, abs, etc). The only required | |
650 | information is the general_symbol_info. | |
651 | ||
652 | In many cases, even if a file was compiled with no special options for | |
653 | debugging at all, as long as was not stripped it will contain sufficient | |
654 | information to build a useful minimal symbol table using this structure. | |
655 | Even when a file contains enough debugging information to build a full | |
656 | symbol table, these minimal symbols are still useful for quickly mapping | |
657 | between names and addresses, and vice versa. They are also sometimes | |
c378eb4e | 658 | used to figure out what full symbol table entries need to be read in. */ |
c906108c | 659 | |
eefba3da | 660 | struct minimal_symbol : public general_symbol_info |
17c5ed2c | 661 | { |
8763cede | 662 | /* Size of this symbol. dbx_end_psymtab in dbxread.c uses this |
f594e5e9 MC |
663 | information to calculate the end of the partial symtab based on the |
664 | address of the last symbol plus the size of the last symbol. */ | |
665 | ||
666 | unsigned long size; | |
667 | ||
17c5ed2c | 668 | /* Which source file is this symbol in? Only relevant for mst_file_*. */ |
04aba065 | 669 | const char *filename; |
c906108c | 670 | |
87193939 | 671 | /* Classification type for this minimal symbol. */ |
17c5ed2c | 672 | |
51cdc993 | 673 | ENUM_BITFIELD(minimal_symbol_type) type : MINSYM_TYPE_BITS; |
17c5ed2c | 674 | |
422d65e7 DE |
675 | /* Non-zero if this symbol was created by gdb. |
676 | Such symbols do not appear in the output of "info var|fun". */ | |
677 | unsigned int created_by_gdb : 1; | |
678 | ||
b887350f TT |
679 | /* Two flag bits provided for the use of the target. */ |
680 | unsigned int target_flag_1 : 1; | |
681 | unsigned int target_flag_2 : 1; | |
682 | ||
d9eaeb59 JB |
683 | /* Nonzero iff the size of the minimal symbol has been set. |
684 | Symbol size information can sometimes not be determined, because | |
685 | the object file format may not carry that piece of information. */ | |
686 | unsigned int has_size : 1; | |
687 | ||
4b610737 TT |
688 | /* For data symbols only, if this is set, then the symbol might be |
689 | subject to copy relocation. In this case, a minimal symbol | |
690 | matching the symbol's linkage name is first looked for in the | |
691 | main objfile. If found, then that address is used; otherwise the | |
692 | address in this symbol is used. */ | |
693 | ||
694 | unsigned maybe_copied : 1; | |
695 | ||
17c5ed2c DC |
696 | /* Minimal symbols with the same hash key are kept on a linked |
697 | list. This is the link. */ | |
698 | ||
699 | struct minimal_symbol *hash_next; | |
700 | ||
701 | /* Minimal symbols are stored in two different hash tables. This is | |
702 | the `next' pointer for the demangled hash table. */ | |
703 | ||
704 | struct minimal_symbol *demangled_hash_next; | |
1ed9f74e | 705 | |
eefba3da | 706 | /* True if this symbol is of some data type. */ |
1ed9f74e PW |
707 | |
708 | bool data_p () const; | |
709 | ||
710 | /* True if MSYMBOL is of some text type. */ | |
711 | ||
712 | bool text_p () const; | |
17c5ed2c | 713 | }; |
c906108c | 714 | |
4b610737 TT |
715 | /* Return the address of MINSYM, which comes from OBJF. The |
716 | MAYBE_COPIED flag must be set on MINSYM. If MINSYM appears in the | |
717 | main program's minimal symbols, then that minsym's address is | |
718 | returned; otherwise, MINSYM's address is returned. This should | |
719 | generally only be used via the MSYMBOL_VALUE_ADDRESS macro. */ | |
720 | ||
721 | extern CORE_ADDR get_msymbol_address (struct objfile *objf, | |
722 | const struct minimal_symbol *minsym); | |
723 | ||
b887350f TT |
724 | #define MSYMBOL_TARGET_FLAG_1(msymbol) (msymbol)->target_flag_1 |
725 | #define MSYMBOL_TARGET_FLAG_2(msymbol) (msymbol)->target_flag_2 | |
d9eaeb59 JB |
726 | #define MSYMBOL_SIZE(msymbol) ((msymbol)->size + 0) |
727 | #define SET_MSYMBOL_SIZE(msymbol, sz) \ | |
728 | do \ | |
729 | { \ | |
730 | (msymbol)->size = sz; \ | |
731 | (msymbol)->has_size = 1; \ | |
732 | } while (0) | |
733 | #define MSYMBOL_HAS_SIZE(msymbol) ((msymbol)->has_size + 0) | |
c906108c | 734 | #define MSYMBOL_TYPE(msymbol) (msymbol)->type |
c906108c | 735 | |
eefba3da | 736 | #define MSYMBOL_VALUE(symbol) (symbol)->value.ivalue |
77e371c0 | 737 | /* The unrelocated address of the minimal symbol. */ |
eefba3da | 738 | #define MSYMBOL_VALUE_RAW_ADDRESS(symbol) ((symbol)->value.address + 0) |
2273f0ac TT |
739 | /* The relocated address of the minimal symbol, using the section |
740 | offsets from OBJFILE. */ | |
77e371c0 | 741 | #define MSYMBOL_VALUE_ADDRESS(objfile, symbol) \ |
4b610737 TT |
742 | (((symbol)->maybe_copied) ? get_msymbol_address (objfile, symbol) \ |
743 | : ((symbol)->value.address \ | |
744 | + ANOFFSET ((objfile)->section_offsets, ((symbol)->section)))) | |
77e371c0 TT |
745 | /* For a bound minsym, we can easily compute the address directly. */ |
746 | #define BMSYMBOL_VALUE_ADDRESS(symbol) \ | |
747 | MSYMBOL_VALUE_ADDRESS ((symbol).objfile, (symbol).minsym) | |
748 | #define SET_MSYMBOL_VALUE_ADDRESS(symbol, new_value) \ | |
eefba3da TT |
749 | ((symbol)->value.address = (new_value)) |
750 | #define MSYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes | |
751 | #define MSYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block | |
752 | #define MSYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain | |
753 | #define MSYMBOL_LANGUAGE(symbol) (symbol)->language | |
754 | #define MSYMBOL_SECTION(symbol) (symbol)->section | |
efd66ac6 | 755 | #define MSYMBOL_OBJ_SECTION(objfile, symbol) \ |
eefba3da TT |
756 | (((symbol)->section >= 0) \ |
757 | ? (&(((objfile)->sections)[(symbol)->section])) \ | |
efd66ac6 TT |
758 | : NULL) |
759 | ||
760 | #define MSYMBOL_NATURAL_NAME(symbol) \ | |
eefba3da TT |
761 | (symbol_natural_name (symbol)) |
762 | #define MSYMBOL_LINKAGE_NAME(symbol) (symbol)->name | |
efd66ac6 TT |
763 | #define MSYMBOL_PRINT_NAME(symbol) \ |
764 | (demangle ? MSYMBOL_NATURAL_NAME (symbol) : MSYMBOL_LINKAGE_NAME (symbol)) | |
765 | #define MSYMBOL_DEMANGLED_NAME(symbol) \ | |
eefba3da | 766 | (symbol_demangled_name (symbol)) |
efd66ac6 | 767 | #define MSYMBOL_SEARCH_NAME(symbol) \ |
eefba3da | 768 | (symbol_search_name (symbol)) |
efd66ac6 | 769 | |
c35384fb TT |
770 | #include "minsyms.h" |
771 | ||
c906108c | 772 | \f |
c5aa993b | 773 | |
c906108c SS |
774 | /* Represent one symbol name; a variable, constant, function or typedef. */ |
775 | ||
176620f1 | 776 | /* Different name domains for symbols. Looking up a symbol specifies a |
c378eb4e | 777 | domain and ignores symbol definitions in other name domains. */ |
c906108c | 778 | |
87193939 | 779 | typedef enum domain_enum_tag |
17c5ed2c | 780 | { |
176620f1 | 781 | /* UNDEF_DOMAIN is used when a domain has not been discovered or |
17c5ed2c | 782 | none of the following apply. This usually indicates an error either |
c378eb4e | 783 | in the symbol information or in gdb's handling of symbols. */ |
c906108c | 784 | |
176620f1 | 785 | UNDEF_DOMAIN, |
c906108c | 786 | |
176620f1 | 787 | /* VAR_DOMAIN is the usual domain. In C, this contains variables, |
c378eb4e | 788 | function names, typedef names and enum type values. */ |
c906108c | 789 | |
176620f1 | 790 | VAR_DOMAIN, |
c906108c | 791 | |
176620f1 | 792 | /* STRUCT_DOMAIN is used in C to hold struct, union and enum type names. |
17c5ed2c | 793 | Thus, if `struct foo' is used in a C program, it produces a symbol named |
c378eb4e | 794 | `foo' in the STRUCT_DOMAIN. */ |
c906108c | 795 | |
176620f1 | 796 | STRUCT_DOMAIN, |
c906108c | 797 | |
530e8392 KB |
798 | /* MODULE_DOMAIN is used in Fortran to hold module type names. */ |
799 | ||
800 | MODULE_DOMAIN, | |
801 | ||
0f5238ed | 802 | /* LABEL_DOMAIN may be used for names of labels (for gotos). */ |
c906108c | 803 | |
4357ac6c TT |
804 | LABEL_DOMAIN, |
805 | ||
5a352474 JK |
806 | /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. |
807 | They also always use LOC_COMMON_BLOCK. */ | |
51cdc993 DE |
808 | COMMON_BLOCK_DOMAIN, |
809 | ||
810 | /* This must remain last. */ | |
811 | NR_DOMAINS | |
8903c50d | 812 | } domain_enum; |
c906108c | 813 | |
c01feb36 DE |
814 | /* The number of bits in a symbol used to represent the domain. */ |
815 | ||
51cdc993 DE |
816 | #define SYMBOL_DOMAIN_BITS 3 |
817 | gdb_static_assert (NR_DOMAINS <= (1 << SYMBOL_DOMAIN_BITS)); | |
c01feb36 | 818 | |
20c681d1 DE |
819 | extern const char *domain_name (domain_enum); |
820 | ||
e8930875 JK |
821 | /* Searching domains, used for `search_symbols'. Element numbers are |
822 | hardcoded in GDB, check all enum uses before changing it. */ | |
c906108c | 823 | |
8903c50d TT |
824 | enum search_domain |
825 | { | |
bd2e94ce TT |
826 | /* Everything in VAR_DOMAIN minus FUNCTIONS_DOMAIN and |
827 | TYPES_DOMAIN. */ | |
e8930875 | 828 | VARIABLES_DOMAIN = 0, |
c906108c | 829 | |
c378eb4e | 830 | /* All functions -- for some reason not methods, though. */ |
e8930875 | 831 | FUNCTIONS_DOMAIN = 1, |
c906108c | 832 | |
17c5ed2c | 833 | /* All defined types */ |
e8930875 | 834 | TYPES_DOMAIN = 2, |
7b08b9eb | 835 | |
59c35742 AB |
836 | /* All modules. */ |
837 | MODULES_DOMAIN = 3, | |
838 | ||
7b08b9eb | 839 | /* Any type. */ |
59c35742 | 840 | ALL_DOMAIN = 4 |
8903c50d | 841 | }; |
c906108c | 842 | |
20c681d1 DE |
843 | extern const char *search_domain_name (enum search_domain); |
844 | ||
c906108c SS |
845 | /* An address-class says where to find the value of a symbol. */ |
846 | ||
847 | enum address_class | |
17c5ed2c | 848 | { |
c378eb4e | 849 | /* Not used; catches errors. */ |
c5aa993b | 850 | |
17c5ed2c | 851 | LOC_UNDEF, |
c906108c | 852 | |
c378eb4e | 853 | /* Value is constant int SYMBOL_VALUE, host byteorder. */ |
c906108c | 854 | |
17c5ed2c | 855 | LOC_CONST, |
c906108c | 856 | |
c378eb4e | 857 | /* Value is at fixed address SYMBOL_VALUE_ADDRESS. */ |
c906108c | 858 | |
17c5ed2c | 859 | LOC_STATIC, |
c906108c | 860 | |
768a979c UW |
861 | /* Value is in register. SYMBOL_VALUE is the register number |
862 | in the original debug format. SYMBOL_REGISTER_OPS holds a | |
863 | function that can be called to transform this into the | |
864 | actual register number this represents in a specific target | |
865 | architecture (gdbarch). | |
2a2d4dc3 AS |
866 | |
867 | For some symbol formats (stabs, for some compilers at least), | |
868 | the compiler generates two symbols, an argument and a register. | |
869 | In some cases we combine them to a single LOC_REGISTER in symbol | |
870 | reading, but currently not for all cases (e.g. it's passed on the | |
871 | stack and then loaded into a register). */ | |
c906108c | 872 | |
17c5ed2c | 873 | LOC_REGISTER, |
c906108c | 874 | |
17c5ed2c | 875 | /* It's an argument; the value is at SYMBOL_VALUE offset in arglist. */ |
c906108c | 876 | |
17c5ed2c | 877 | LOC_ARG, |
c906108c | 878 | |
17c5ed2c | 879 | /* Value address is at SYMBOL_VALUE offset in arglist. */ |
c906108c | 880 | |
17c5ed2c | 881 | LOC_REF_ARG, |
c906108c | 882 | |
2a2d4dc3 | 883 | /* Value is in specified register. Just like LOC_REGISTER except the |
17c5ed2c | 884 | register holds the address of the argument instead of the argument |
c378eb4e | 885 | itself. This is currently used for the passing of structs and unions |
17c5ed2c DC |
886 | on sparc and hppa. It is also used for call by reference where the |
887 | address is in a register, at least by mipsread.c. */ | |
c906108c | 888 | |
17c5ed2c | 889 | LOC_REGPARM_ADDR, |
c906108c | 890 | |
17c5ed2c | 891 | /* Value is a local variable at SYMBOL_VALUE offset in stack frame. */ |
c906108c | 892 | |
17c5ed2c | 893 | LOC_LOCAL, |
c906108c | 894 | |
176620f1 EZ |
895 | /* Value not used; definition in SYMBOL_TYPE. Symbols in the domain |
896 | STRUCT_DOMAIN all have this class. */ | |
c906108c | 897 | |
17c5ed2c | 898 | LOC_TYPEDEF, |
c906108c | 899 | |
c378eb4e | 900 | /* Value is address SYMBOL_VALUE_ADDRESS in the code. */ |
c906108c | 901 | |
17c5ed2c | 902 | LOC_LABEL, |
c906108c | 903 | |
17c5ed2c DC |
904 | /* In a symbol table, value is SYMBOL_BLOCK_VALUE of a `struct block'. |
905 | In a partial symbol table, SYMBOL_VALUE_ADDRESS is the start address | |
c378eb4e | 906 | of the block. Function names have this class. */ |
c906108c | 907 | |
17c5ed2c | 908 | LOC_BLOCK, |
c906108c | 909 | |
17c5ed2c DC |
910 | /* Value is a constant byte-sequence pointed to by SYMBOL_VALUE_BYTES, in |
911 | target byte order. */ | |
c906108c | 912 | |
17c5ed2c | 913 | LOC_CONST_BYTES, |
c906108c | 914 | |
17c5ed2c DC |
915 | /* Value is at fixed address, but the address of the variable has |
916 | to be determined from the minimal symbol table whenever the | |
917 | variable is referenced. | |
918 | This happens if debugging information for a global symbol is | |
919 | emitted and the corresponding minimal symbol is defined | |
920 | in another object file or runtime common storage. | |
921 | The linker might even remove the minimal symbol if the global | |
922 | symbol is never referenced, in which case the symbol remains | |
de40b933 JK |
923 | unresolved. |
924 | ||
925 | GDB would normally find the symbol in the minimal symbol table if it will | |
926 | not find it in the full symbol table. But a reference to an external | |
927 | symbol in a local block shadowing other definition requires full symbol | |
928 | without possibly having its address available for LOC_STATIC. Testcase | |
5382cfab PW |
929 | is provided as `gdb.dwarf2/dw2-unresolved.exp'. |
930 | ||
931 | This is also used for thread local storage (TLS) variables. In this case, | |
932 | the address of the TLS variable must be determined when the variable is | |
933 | referenced, from the MSYMBOL_VALUE_RAW_ADDRESS, which is the offset | |
934 | of the TLS variable in the thread local storage of the shared | |
935 | library/object. */ | |
c906108c | 936 | |
17c5ed2c | 937 | LOC_UNRESOLVED, |
c906108c | 938 | |
17c5ed2c DC |
939 | /* The variable does not actually exist in the program. |
940 | The value is ignored. */ | |
c906108c | 941 | |
17c5ed2c | 942 | LOC_OPTIMIZED_OUT, |
c906108c | 943 | |
4c2df51b | 944 | /* The variable's address is computed by a set of location |
768a979c | 945 | functions (see "struct symbol_computed_ops" below). */ |
4c2df51b | 946 | LOC_COMPUTED, |
5a352474 JK |
947 | |
948 | /* The variable uses general_symbol_info->value->common_block field. | |
949 | It also always uses COMMON_BLOCK_DOMAIN. */ | |
950 | LOC_COMMON_BLOCK, | |
f1e6e072 TT |
951 | |
952 | /* Not used, just notes the boundary of the enum. */ | |
953 | LOC_FINAL_VALUE | |
4c2df51b DJ |
954 | }; |
955 | ||
51cdc993 DE |
956 | /* The number of bits needed for values in enum address_class, with some |
957 | padding for reasonable growth, and room for run-time registered address | |
958 | classes. See symtab.c:MAX_SYMBOL_IMPLS. | |
959 | This is a #define so that we can have a assertion elsewhere to | |
960 | verify that we have reserved enough space for synthetic address | |
961 | classes. */ | |
962 | #define SYMBOL_ACLASS_BITS 5 | |
963 | gdb_static_assert (LOC_FINAL_VALUE <= (1 << SYMBOL_ACLASS_BITS)); | |
964 | ||
768a979c | 965 | /* The methods needed to implement LOC_COMPUTED. These methods can |
a67af2b9 AC |
966 | use the symbol's .aux_value for additional per-symbol information. |
967 | ||
968 | At present this is only used to implement location expressions. */ | |
969 | ||
768a979c | 970 | struct symbol_computed_ops |
4c2df51b DJ |
971 | { |
972 | ||
973 | /* Return the value of the variable SYMBOL, relative to the stack | |
974 | frame FRAME. If the variable has been optimized out, return | |
975 | zero. | |
976 | ||
0b31a4bc TT |
977 | Iff `read_needs_frame (SYMBOL)' is not SYMBOL_NEEDS_FRAME, then |
978 | FRAME may be zero. */ | |
4c2df51b DJ |
979 | |
980 | struct value *(*read_variable) (struct symbol * symbol, | |
981 | struct frame_info * frame); | |
982 | ||
e18b2753 JK |
983 | /* Read variable SYMBOL like read_variable at (callee) FRAME's function |
984 | entry. SYMBOL should be a function parameter, otherwise | |
985 | NO_ENTRY_VALUE_ERROR will be thrown. */ | |
986 | struct value *(*read_variable_at_entry) (struct symbol *symbol, | |
987 | struct frame_info *frame); | |
988 | ||
0b31a4bc TT |
989 | /* Find the "symbol_needs_kind" value for the given symbol. This |
990 | value determines whether reading the symbol needs memory (e.g., a | |
991 | global variable), just registers (a thread-local), or a frame (a | |
992 | local variable). */ | |
993 | enum symbol_needs_kind (*get_symbol_read_needs) (struct symbol * symbol); | |
4c2df51b DJ |
994 | |
995 | /* Write to STREAM a natural-language description of the location of | |
08922a10 SS |
996 | SYMBOL, in the context of ADDR. */ |
997 | void (*describe_location) (struct symbol * symbol, CORE_ADDR addr, | |
998 | struct ui_file * stream); | |
4c2df51b | 999 | |
f1e6e072 TT |
1000 | /* Non-zero if this symbol's address computation is dependent on PC. */ |
1001 | unsigned char location_has_loclist; | |
1002 | ||
4c2df51b DJ |
1003 | /* Tracepoint support. Append bytecodes to the tracepoint agent |
1004 | expression AX that push the address of the object SYMBOL. Set | |
1005 | VALUE appropriately. Note --- for objects in registers, this | |
1006 | needn't emit any code; as long as it sets VALUE properly, then | |
1007 | the caller will generate the right code in the process of | |
1008 | treating this as an lvalue or rvalue. */ | |
1009 | ||
40f4af28 SM |
1010 | void (*tracepoint_var_ref) (struct symbol *symbol, struct agent_expr *ax, |
1011 | struct axs_value *value); | |
bb2ec1b3 TT |
1012 | |
1013 | /* Generate C code to compute the location of SYMBOL. The C code is | |
1014 | emitted to STREAM. GDBARCH is the current architecture and PC is | |
1015 | the PC at which SYMBOL's location should be evaluated. | |
1016 | REGISTERS_USED is a vector indexed by register number; the | |
1017 | generator function should set an element in this vector if the | |
1018 | corresponding register is needed by the location computation. | |
1019 | The generated C code must assign the location to a local | |
1020 | variable; this variable's name is RESULT_NAME. */ | |
1021 | ||
d82b3862 | 1022 | void (*generate_c_location) (struct symbol *symbol, string_file *stream, |
bb2ec1b3 TT |
1023 | struct gdbarch *gdbarch, |
1024 | unsigned char *registers_used, | |
1025 | CORE_ADDR pc, const char *result_name); | |
1026 | ||
17c5ed2c | 1027 | }; |
c906108c | 1028 | |
f1e6e072 TT |
1029 | /* The methods needed to implement LOC_BLOCK for inferior functions. |
1030 | These methods can use the symbol's .aux_value for additional | |
1031 | per-symbol information. */ | |
1032 | ||
1033 | struct symbol_block_ops | |
1034 | { | |
1035 | /* Fill in *START and *LENGTH with DWARF block data of function | |
1036 | FRAMEFUNC valid for inferior context address PC. Set *LENGTH to | |
1037 | zero if such location is not valid for PC; *START is left | |
1038 | uninitialized in such case. */ | |
1039 | void (*find_frame_base_location) (struct symbol *framefunc, CORE_ADDR pc, | |
1040 | const gdb_byte **start, size_t *length); | |
63e43d3a PMR |
1041 | |
1042 | /* Return the frame base address. FRAME is the frame for which we want to | |
1043 | compute the base address while FRAMEFUNC is the symbol for the | |
1044 | corresponding function. Return 0 on failure (FRAMEFUNC may not hold the | |
1045 | information we need). | |
1046 | ||
1047 | This method is designed to work with static links (nested functions | |
1048 | handling). Static links are function properties whose evaluation returns | |
1049 | the frame base address for the enclosing frame. However, there are | |
1050 | multiple definitions for "frame base": the content of the frame base | |
1051 | register, the CFA as defined by DWARF unwinding information, ... | |
1052 | ||
1053 | So this specific method is supposed to compute the frame base address such | |
30baf67b | 1054 | as for nested functions, the static link computes the same address. For |
63e43d3a PMR |
1055 | instance, considering DWARF debugging information, the static link is |
1056 | computed with DW_AT_static_link and this method must be used to compute | |
1057 | the corresponding DW_AT_frame_base attribute. */ | |
1058 | CORE_ADDR (*get_frame_base) (struct symbol *framefunc, | |
1059 | struct frame_info *frame); | |
f1e6e072 TT |
1060 | }; |
1061 | ||
768a979c UW |
1062 | /* Functions used with LOC_REGISTER and LOC_REGPARM_ADDR. */ |
1063 | ||
1064 | struct symbol_register_ops | |
1065 | { | |
1066 | int (*register_number) (struct symbol *symbol, struct gdbarch *gdbarch); | |
1067 | }; | |
1068 | ||
f1e6e072 TT |
1069 | /* Objects of this type are used to find the address class and the |
1070 | various computed ops vectors of a symbol. */ | |
1071 | ||
1072 | struct symbol_impl | |
1073 | { | |
1074 | enum address_class aclass; | |
1075 | ||
1076 | /* Used with LOC_COMPUTED. */ | |
1077 | const struct symbol_computed_ops *ops_computed; | |
1078 | ||
1079 | /* Used with LOC_BLOCK. */ | |
1080 | const struct symbol_block_ops *ops_block; | |
1081 | ||
1082 | /* Used with LOC_REGISTER and LOC_REGPARM_ADDR. */ | |
1083 | const struct symbol_register_ops *ops_register; | |
1084 | }; | |
1085 | ||
cf724bc9 TT |
1086 | /* struct symbol has some subclasses. This enum is used to |
1087 | differentiate between them. */ | |
1088 | ||
1089 | enum symbol_subclass_kind | |
1090 | { | |
1091 | /* Plain struct symbol. */ | |
1092 | SYMBOL_NONE, | |
1093 | ||
1094 | /* struct template_symbol. */ | |
1095 | SYMBOL_TEMPLATE, | |
1096 | ||
1097 | /* struct rust_vtable_symbol. */ | |
1098 | SYMBOL_RUST_VTABLE | |
1099 | }; | |
1100 | ||
c378eb4e | 1101 | /* This structure is space critical. See space comments at the top. */ |
a7f19c79 | 1102 | |
468c0cbb | 1103 | struct symbol : public general_symbol_info, public allocate_on_obstack |
17c5ed2c | 1104 | { |
468c0cbb CB |
1105 | symbol () |
1106 | /* Class-initialization of bitfields is only allowed in C++20. */ | |
1107 | : domain (UNDEF_DOMAIN), | |
1108 | aclass_index (0), | |
1109 | is_objfile_owned (0), | |
1110 | is_argument (0), | |
1111 | is_inlined (0), | |
1112 | maybe_copied (0), | |
1113 | subclass (SYMBOL_NONE) | |
1114 | { | |
1115 | /* We can't use an initializer list for members of a base class, and | |
1116 | general_symbol_info needs to stay a POD type. */ | |
1117 | name = nullptr; | |
1118 | value.ivalue = 0; | |
1119 | language_specific.obstack = nullptr; | |
1120 | language = language_unknown; | |
1121 | ada_mangled = 0; | |
1122 | section = 0; | |
1123 | } | |
c906108c | 1124 | |
17c5ed2c | 1125 | /* Data type of value */ |
c906108c | 1126 | |
468c0cbb | 1127 | struct type *type = nullptr; |
c906108c | 1128 | |
1994afbf | 1129 | /* The owner of this symbol. |
e2ada9cb | 1130 | Which one to use is defined by symbol.is_objfile_owned. */ |
1994afbf DE |
1131 | |
1132 | union | |
1133 | { | |
1134 | /* The symbol table containing this symbol. This is the file associated | |
1135 | with LINE. It can be NULL during symbols read-in but it is never NULL | |
1136 | during normal operation. */ | |
468c0cbb | 1137 | struct symtab *symtab = nullptr; |
1994afbf DE |
1138 | |
1139 | /* For types defined by the architecture. */ | |
1140 | struct gdbarch *arch; | |
1141 | } owner; | |
cb1df416 | 1142 | |
176620f1 | 1143 | /* Domain code. */ |
c906108c | 1144 | |
c01feb36 | 1145 | ENUM_BITFIELD(domain_enum_tag) domain : SYMBOL_DOMAIN_BITS; |
c906108c | 1146 | |
f1e6e072 TT |
1147 | /* Address class. This holds an index into the 'symbol_impls' |
1148 | table. The actual enum address_class value is stored there, | |
1149 | alongside any per-class ops vectors. */ | |
c906108c | 1150 | |
f1e6e072 | 1151 | unsigned int aclass_index : SYMBOL_ACLASS_BITS; |
c906108c | 1152 | |
1994afbf | 1153 | /* If non-zero then symbol is objfile-owned, use owner.symtab. |
468c0cbb | 1154 | Otherwise symbol is arch-owned, use owner.arch. */ |
1994afbf DE |
1155 | |
1156 | unsigned int is_objfile_owned : 1; | |
1157 | ||
2a2d4dc3 AS |
1158 | /* Whether this is an argument. */ |
1159 | ||
1160 | unsigned is_argument : 1; | |
1161 | ||
edb3359d DJ |
1162 | /* Whether this is an inlined function (class LOC_BLOCK only). */ |
1163 | unsigned is_inlined : 1; | |
1164 | ||
4b610737 TT |
1165 | /* For LOC_STATIC only, if this is set, then the symbol might be |
1166 | subject to copy relocation. In this case, a minimal symbol | |
1167 | matching the symbol's linkage name is first looked for in the | |
1168 | main objfile. If found, then that address is used; otherwise the | |
1169 | address in this symbol is used. */ | |
1170 | ||
1171 | unsigned maybe_copied : 1; | |
1172 | ||
cf724bc9 | 1173 | /* The concrete type of this symbol. */ |
71a3c369 | 1174 | |
cf724bc9 | 1175 | ENUM_BITFIELD (symbol_subclass_kind) subclass : 2; |
71a3c369 | 1176 | |
edb3359d DJ |
1177 | /* Line number of this symbol's definition, except for inlined |
1178 | functions. For an inlined function (class LOC_BLOCK and | |
1179 | SYMBOL_INLINED set) this is the line number of the function's call | |
1180 | site. Inlined function symbols are not definitions, and they are | |
1181 | never found by symbol table lookup. | |
1994afbf | 1182 | If this symbol is arch-owned, LINE shall be zero. |
edb3359d DJ |
1183 | |
1184 | FIXME: Should we really make the assumption that nobody will try | |
1185 | to debug files longer than 64K lines? What about machine | |
1186 | generated programs? */ | |
c906108c | 1187 | |
468c0cbb | 1188 | unsigned short line = 0; |
c906108c | 1189 | |
10f4ecb8 UW |
1190 | /* An arbitrary data pointer, allowing symbol readers to record |
1191 | additional information on a per-symbol basis. Note that this data | |
1192 | must be allocated using the same obstack as the symbol itself. */ | |
1cd36e54 DE |
1193 | /* So far it is only used by: |
1194 | LOC_COMPUTED: to find the location information | |
1195 | LOC_BLOCK (DWARF2 function): information used internally by the | |
1196 | DWARF 2 code --- specifically, the location expression for the frame | |
10f4ecb8 UW |
1197 | base for this function. */ |
1198 | /* FIXME drow/2003-02-21: For the LOC_BLOCK case, it might be better | |
1199 | to add a magic symbol to the block containing this information, | |
1200 | or to have a generic debug info annotation slot for symbols. */ | |
1201 | ||
468c0cbb | 1202 | void *aux_value = nullptr; |
c906108c | 1203 | |
468c0cbb | 1204 | struct symbol *hash_next = nullptr; |
17c5ed2c | 1205 | }; |
c906108c | 1206 | |
3573abe1 CB |
1207 | /* This struct is size-critical (see comment at the top), so this assert |
1208 | makes sure the size doesn't change accidentally. Be careful when | |
1209 | purposely increasing the size. */ | |
1210 | gdb_static_assert ((sizeof (void *) == 8 && sizeof (symbol) == 72) | |
1211 | || (sizeof (void *) == 4 && sizeof (symbol) == 40)); | |
1212 | ||
d12307c1 PMR |
1213 | /* Several lookup functions return both a symbol and the block in which the |
1214 | symbol is found. This structure is used in these cases. */ | |
1215 | ||
1216 | struct block_symbol | |
1217 | { | |
1218 | /* The symbol that was found, or NULL if no symbol was found. */ | |
1219 | struct symbol *symbol; | |
1220 | ||
1221 | /* If SYMBOL is not NULL, then this is the block in which the symbol is | |
1222 | defined. */ | |
1223 | const struct block *block; | |
1224 | }; | |
1225 | ||
f1e6e072 | 1226 | extern const struct symbol_impl *symbol_impls; |
c906108c | 1227 | |
1994afbf DE |
1228 | /* Note: There is no accessor macro for symbol.owner because it is |
1229 | "private". */ | |
1230 | ||
176620f1 | 1231 | #define SYMBOL_DOMAIN(symbol) (symbol)->domain |
f1e6e072 TT |
1232 | #define SYMBOL_IMPL(symbol) (symbol_impls[(symbol)->aclass_index]) |
1233 | #define SYMBOL_ACLASS_INDEX(symbol) (symbol)->aclass_index | |
1234 | #define SYMBOL_CLASS(symbol) (SYMBOL_IMPL (symbol).aclass) | |
1994afbf | 1235 | #define SYMBOL_OBJFILE_OWNED(symbol) ((symbol)->is_objfile_owned) |
2a2d4dc3 | 1236 | #define SYMBOL_IS_ARGUMENT(symbol) (symbol)->is_argument |
edb3359d | 1237 | #define SYMBOL_INLINED(symbol) (symbol)->is_inlined |
34eaf542 | 1238 | #define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \ |
cf724bc9 | 1239 | (((symbol)->subclass) == SYMBOL_TEMPLATE) |
c906108c SS |
1240 | #define SYMBOL_TYPE(symbol) (symbol)->type |
1241 | #define SYMBOL_LINE(symbol) (symbol)->line | |
f1e6e072 TT |
1242 | #define SYMBOL_COMPUTED_OPS(symbol) (SYMBOL_IMPL (symbol).ops_computed) |
1243 | #define SYMBOL_BLOCK_OPS(symbol) (SYMBOL_IMPL (symbol).ops_block) | |
1244 | #define SYMBOL_REGISTER_OPS(symbol) (SYMBOL_IMPL (symbol).ops_register) | |
10f4ecb8 | 1245 | #define SYMBOL_LOCATION_BATON(symbol) (symbol)->aux_value |
34eaf542 | 1246 | |
f1e6e072 TT |
1247 | extern int register_symbol_computed_impl (enum address_class, |
1248 | const struct symbol_computed_ops *); | |
1249 | ||
1250 | extern int register_symbol_block_impl (enum address_class aclass, | |
1251 | const struct symbol_block_ops *ops); | |
1252 | ||
1253 | extern int register_symbol_register_impl (enum address_class, | |
1254 | const struct symbol_register_ops *); | |
1255 | ||
08be3fe3 DE |
1256 | /* Return the OBJFILE of SYMBOL. |
1257 | It is an error to call this if symbol.is_objfile_owned is false, which | |
1258 | only happens for architecture-provided types. */ | |
1259 | ||
1260 | extern struct objfile *symbol_objfile (const struct symbol *symbol); | |
1261 | ||
1262 | /* Return the ARCH of SYMBOL. */ | |
1263 | ||
1264 | extern struct gdbarch *symbol_arch (const struct symbol *symbol); | |
1265 | ||
1266 | /* Return the SYMTAB of SYMBOL. | |
1267 | It is an error to call this if symbol.is_objfile_owned is false, which | |
1268 | only happens for architecture-provided types. */ | |
1269 | ||
1270 | extern struct symtab *symbol_symtab (const struct symbol *symbol); | |
1271 | ||
1272 | /* Set the symtab of SYMBOL to SYMTAB. | |
1273 | It is an error to call this if symbol.is_objfile_owned is false, which | |
1274 | only happens for architecture-provided types. */ | |
1275 | ||
1276 | extern void symbol_set_symtab (struct symbol *symbol, struct symtab *symtab); | |
1277 | ||
34eaf542 | 1278 | /* An instance of this type is used to represent a C++ template |
68e745e3 TT |
1279 | function. A symbol is really of this type iff |
1280 | SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION is true. */ | |
34eaf542 | 1281 | |
68e745e3 | 1282 | struct template_symbol : public symbol |
34eaf542 | 1283 | { |
34eaf542 | 1284 | /* The number of template arguments. */ |
468c0cbb | 1285 | int n_template_arguments = 0; |
34eaf542 TT |
1286 | |
1287 | /* The template arguments. This is an array with | |
1288 | N_TEMPLATE_ARGUMENTS elements. */ | |
468c0cbb | 1289 | struct symbol **template_arguments = nullptr; |
34eaf542 TT |
1290 | }; |
1291 | ||
71a3c369 TT |
1292 | /* A symbol that represents a Rust virtual table object. */ |
1293 | ||
1294 | struct rust_vtable_symbol : public symbol | |
1295 | { | |
1296 | /* The concrete type for which this vtable was created; that is, in | |
1297 | "impl Trait for Type", this is "Type". */ | |
468c0cbb | 1298 | struct type *concrete_type = nullptr; |
71a3c369 TT |
1299 | }; |
1300 | ||
c906108c | 1301 | \f |
c906108c SS |
1302 | /* Each item represents a line-->pc (or the reverse) mapping. This is |
1303 | somewhat more wasteful of space than one might wish, but since only | |
1304 | the files which are actually debugged are read in to core, we don't | |
1305 | waste much space. */ | |
1306 | ||
1307 | struct linetable_entry | |
17c5ed2c DC |
1308 | { |
1309 | int line; | |
1310 | CORE_ADDR pc; | |
1311 | }; | |
c906108c SS |
1312 | |
1313 | /* The order of entries in the linetable is significant. They should | |
1314 | be sorted by increasing values of the pc field. If there is more than | |
1315 | one entry for a given pc, then I'm not sure what should happen (and | |
1316 | I not sure whether we currently handle it the best way). | |
1317 | ||
1318 | Example: a C for statement generally looks like this | |
1319 | ||
c5aa993b JM |
1320 | 10 0x100 - for the init/test part of a for stmt. |
1321 | 20 0x200 | |
1322 | 30 0x300 | |
1323 | 10 0x400 - for the increment part of a for stmt. | |
c906108c | 1324 | |
e8717518 FF |
1325 | If an entry has a line number of zero, it marks the start of a PC |
1326 | range for which no line number information is available. It is | |
1327 | acceptable, though wasteful of table space, for such a range to be | |
1328 | zero length. */ | |
c906108c SS |
1329 | |
1330 | struct linetable | |
17c5ed2c DC |
1331 | { |
1332 | int nitems; | |
c906108c | 1333 | |
17c5ed2c DC |
1334 | /* Actually NITEMS elements. If you don't like this use of the |
1335 | `struct hack', you can shove it up your ANSI (seriously, if the | |
1336 | committee tells us how to do it, we can probably go along). */ | |
1337 | struct linetable_entry item[1]; | |
1338 | }; | |
c906108c | 1339 | |
c906108c SS |
1340 | /* How to relocate the symbols from each section in a symbol file. |
1341 | Each struct contains an array of offsets. | |
1342 | The ordering and meaning of the offsets is file-type-dependent; | |
1343 | typically it is indexed by section numbers or symbol types or | |
1344 | something like that. | |
1345 | ||
1346 | To give us flexibility in changing the internal representation | |
1347 | of these offsets, the ANOFFSET macro must be used to insert and | |
1348 | extract offset values in the struct. */ | |
1349 | ||
1350 | struct section_offsets | |
17c5ed2c | 1351 | { |
c378eb4e | 1352 | CORE_ADDR offsets[1]; /* As many as needed. */ |
17c5ed2c | 1353 | }; |
c906108c | 1354 | |
a4c8257b | 1355 | #define ANOFFSET(secoff, whichone) \ |
3e43a32a MS |
1356 | ((whichone == -1) \ |
1357 | ? (internal_error (__FILE__, __LINE__, \ | |
1358 | _("Section index is uninitialized")), -1) \ | |
1359 | : secoff->offsets[whichone]) | |
c906108c | 1360 | |
b29c9944 JB |
1361 | /* The size of a section_offsets table for N sections. */ |
1362 | #define SIZEOF_N_SECTION_OFFSETS(n) \ | |
c906108c | 1363 | (sizeof (struct section_offsets) \ |
b29c9944 JB |
1364 | + sizeof (((struct section_offsets *) 0)->offsets) * ((n)-1)) |
1365 | ||
c378eb4e | 1366 | /* Each source file or header is represented by a struct symtab. |
43f3e411 | 1367 | The name "symtab" is historical, another name for it is "filetab". |
c906108c SS |
1368 | These objects are chained through the `next' field. */ |
1369 | ||
1370 | struct symtab | |
17c5ed2c | 1371 | { |
b7236fbe DE |
1372 | /* Unordered chain of all filetabs in the compunit, with the exception |
1373 | that the "main" source file is the first entry in the list. */ | |
c906108c | 1374 | |
17c5ed2c | 1375 | struct symtab *next; |
c906108c | 1376 | |
43f3e411 | 1377 | /* Backlink to containing compunit symtab. */ |
c906108c | 1378 | |
43f3e411 | 1379 | struct compunit_symtab *compunit_symtab; |
c906108c | 1380 | |
17c5ed2c DC |
1381 | /* Table mapping core addresses to line numbers for this file. |
1382 | Can be NULL if none. Never shared between different symtabs. */ | |
c906108c | 1383 | |
17c5ed2c | 1384 | struct linetable *linetable; |
c906108c | 1385 | |
4e04028d | 1386 | /* Name of this source file. This pointer is never NULL. */ |
c906108c | 1387 | |
21ea9eec | 1388 | const char *filename; |
c906108c | 1389 | |
17c5ed2c | 1390 | /* Language of this source file. */ |
c906108c | 1391 | |
17c5ed2c | 1392 | enum language language; |
c906108c | 1393 | |
43f3e411 DE |
1394 | /* Full name of file as found by searching the source path. |
1395 | NULL if not yet known. */ | |
1396 | ||
1397 | char *fullname; | |
1398 | }; | |
1399 | ||
1400 | #define SYMTAB_COMPUNIT(symtab) ((symtab)->compunit_symtab) | |
1401 | #define SYMTAB_LINETABLE(symtab) ((symtab)->linetable) | |
1402 | #define SYMTAB_LANGUAGE(symtab) ((symtab)->language) | |
1403 | #define SYMTAB_BLOCKVECTOR(symtab) \ | |
1404 | COMPUNIT_BLOCKVECTOR (SYMTAB_COMPUNIT (symtab)) | |
1405 | #define SYMTAB_OBJFILE(symtab) \ | |
1406 | COMPUNIT_OBJFILE (SYMTAB_COMPUNIT (symtab)) | |
1407 | #define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace) | |
1408 | #define SYMTAB_DIRNAME(symtab) \ | |
1409 | COMPUNIT_DIRNAME (SYMTAB_COMPUNIT (symtab)) | |
1410 | ||
43f3e411 DE |
1411 | /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well |
1412 | as the list of all source files (what gdb has historically associated with | |
1413 | the term "symtab"). | |
1414 | Additional information is recorded here that is common to all symtabs in a | |
1415 | compilation unit (DWARF or otherwise). | |
1416 | ||
1417 | Example: | |
1418 | For the case of a program built out of these files: | |
1419 | ||
1420 | foo.c | |
1421 | foo1.h | |
1422 | foo2.h | |
1423 | bar.c | |
1424 | foo1.h | |
1425 | bar.h | |
1426 | ||
1427 | This is recorded as: | |
1428 | ||
1429 | objfile -> foo.c(cu) -> bar.c(cu) -> NULL | |
1430 | | | | |
1431 | v v | |
1432 | foo.c bar.c | |
1433 | | | | |
1434 | v v | |
1435 | foo1.h foo1.h | |
1436 | | | | |
1437 | v v | |
1438 | foo2.h bar.h | |
1439 | | | | |
1440 | v v | |
1441 | NULL NULL | |
1442 | ||
1443 | where "foo.c(cu)" and "bar.c(cu)" are struct compunit_symtab objects, | |
1444 | and the files foo.c, etc. are struct symtab objects. */ | |
1445 | ||
1446 | struct compunit_symtab | |
1447 | { | |
1448 | /* Unordered chain of all compunit symtabs of this objfile. */ | |
1449 | struct compunit_symtab *next; | |
1450 | ||
1451 | /* Object file from which this symtab information was read. */ | |
1452 | struct objfile *objfile; | |
1453 | ||
1454 | /* Name of the symtab. | |
1455 | This is *not* intended to be a usable filename, and is | |
1456 | for debugging purposes only. */ | |
1457 | const char *name; | |
1458 | ||
1459 | /* Unordered list of file symtabs, except that by convention the "main" | |
1460 | source file (e.g., .c, .cc) is guaranteed to be first. | |
1461 | Each symtab is a file, either the "main" source file (e.g., .c, .cc) | |
1462 | or header (e.g., .h). */ | |
1463 | struct symtab *filetabs; | |
1464 | ||
1465 | /* Last entry in FILETABS list. | |
1466 | Subfiles are added to the end of the list so they accumulate in order, | |
1467 | with the main source subfile living at the front. | |
1468 | The main reason is so that the main source file symtab is at the head | |
1469 | of the list, and the rest appear in order for debugging convenience. */ | |
1470 | struct symtab *last_filetab; | |
1471 | ||
1472 | /* Non-NULL string that identifies the format of the debugging information, | |
1473 | such as "stabs", "dwarf 1", "dwarf 2", "coff", etc. This is mostly useful | |
17c5ed2c | 1474 | for automated testing of gdb but may also be information that is |
c378eb4e | 1475 | useful to the user. */ |
554d387d | 1476 | const char *debugformat; |
c906108c | 1477 | |
43f3e411 | 1478 | /* String of producer version information, or NULL if we don't know. */ |
554d387d | 1479 | const char *producer; |
c906108c | 1480 | |
43f3e411 DE |
1481 | /* Directory in which it was compiled, or NULL if we don't know. */ |
1482 | const char *dirname; | |
c906108c | 1483 | |
43f3e411 DE |
1484 | /* List of all symbol scope blocks for this symtab. It is shared among |
1485 | all symtabs in a given compilation unit. */ | |
1486 | const struct blockvector *blockvector; | |
c906108c | 1487 | |
43f3e411 DE |
1488 | /* Section in objfile->section_offsets for the blockvector and |
1489 | the linetable. Probably always SECT_OFF_TEXT. */ | |
1490 | int block_line_section; | |
c906108c | 1491 | |
43f3e411 DE |
1492 | /* Symtab has been compiled with both optimizations and debug info so that |
1493 | GDB may stop skipping prologues as variables locations are valid already | |
1494 | at function entry points. */ | |
1495 | unsigned int locations_valid : 1; | |
c906108c | 1496 | |
43f3e411 DE |
1497 | /* DWARF unwinder for this CU is valid even for epilogues (PC at the return |
1498 | instruction). This is supported by GCC since 4.5.0. */ | |
1499 | unsigned int epilogue_unwind_valid : 1; | |
8e3b41a9 | 1500 | |
43f3e411 | 1501 | /* struct call_site entries for this compilation unit or NULL. */ |
8e3b41a9 | 1502 | htab_t call_site_htab; |
b5b04b5b | 1503 | |
43f3e411 DE |
1504 | /* The macro table for this symtab. Like the blockvector, this |
1505 | is shared between different symtabs in a given compilation unit. | |
1506 | It's debatable whether it *should* be shared among all the symtabs in | |
1507 | the given compilation unit, but it currently is. */ | |
1508 | struct macro_table *macro_table; | |
1509 | ||
b5b04b5b | 1510 | /* If non-NULL, then this points to a NULL-terminated vector of |
43f3e411 DE |
1511 | included compunits. When searching the static or global |
1512 | block of this compunit, the corresponding block of all | |
1513 | included compunits will also be searched. Note that this | |
b5b04b5b TT |
1514 | list must be flattened -- the symbol reader is responsible for |
1515 | ensuring that this vector contains the transitive closure of all | |
43f3e411 DE |
1516 | included compunits. */ |
1517 | struct compunit_symtab **includes; | |
b5b04b5b | 1518 | |
43f3e411 DE |
1519 | /* If this is an included compunit, this points to one includer |
1520 | of the table. This user is considered the canonical compunit | |
1521 | containing this one. An included compunit may itself be | |
b5b04b5b | 1522 | included by another. */ |
43f3e411 | 1523 | struct compunit_symtab *user; |
17c5ed2c | 1524 | }; |
c906108c | 1525 | |
43f3e411 DE |
1526 | #define COMPUNIT_OBJFILE(cust) ((cust)->objfile) |
1527 | #define COMPUNIT_FILETABS(cust) ((cust)->filetabs) | |
1528 | #define COMPUNIT_DEBUGFORMAT(cust) ((cust)->debugformat) | |
1529 | #define COMPUNIT_PRODUCER(cust) ((cust)->producer) | |
1530 | #define COMPUNIT_DIRNAME(cust) ((cust)->dirname) | |
1531 | #define COMPUNIT_BLOCKVECTOR(cust) ((cust)->blockvector) | |
1532 | #define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section) | |
1533 | #define COMPUNIT_LOCATIONS_VALID(cust) ((cust)->locations_valid) | |
1534 | #define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid) | |
1535 | #define COMPUNIT_CALL_SITE_HTAB(cust) ((cust)->call_site_htab) | |
1536 | #define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table) | |
ec94af83 | 1537 | |
5accd1a0 TT |
1538 | /* A range adapter to allowing iterating over all the file tables |
1539 | within a compunit. */ | |
db0fec5c | 1540 | |
5accd1a0 TT |
1541 | struct compunit_filetabs : public next_adapter<struct symtab> |
1542 | { | |
1543 | compunit_filetabs (struct compunit_symtab *cu) | |
1544 | : next_adapter<struct symtab> (cu->filetabs) | |
1545 | { | |
1546 | } | |
1547 | }; | |
43f3e411 DE |
1548 | |
1549 | /* Return the primary symtab of CUST. */ | |
1550 | ||
1551 | extern struct symtab * | |
1552 | compunit_primary_filetab (const struct compunit_symtab *cust); | |
1553 | ||
1554 | /* Return the language of CUST. */ | |
1555 | ||
1556 | extern enum language compunit_language (const struct compunit_symtab *cust); | |
1557 | ||
c906108c | 1558 | \f |
c5aa993b | 1559 | |
c906108c | 1560 | /* The virtual function table is now an array of structures which have the |
a960f249 | 1561 | form { int16 offset, delta; void *pfn; }. |
c906108c SS |
1562 | |
1563 | In normal virtual function tables, OFFSET is unused. | |
1564 | DELTA is the amount which is added to the apparent object's base | |
1565 | address in order to point to the actual object to which the | |
1566 | virtual function should be applied. | |
1567 | PFN is a pointer to the virtual function. | |
1568 | ||
c378eb4e | 1569 | Note that this macro is g++ specific (FIXME). */ |
c5aa993b | 1570 | |
c906108c SS |
1571 | #define VTBL_FNADDR_OFFSET 2 |
1572 | ||
c378eb4e | 1573 | /* External variables and functions for the objects described above. */ |
c906108c | 1574 | |
c378eb4e | 1575 | /* True if we are nested inside psymtab_to_symtab. */ |
c906108c SS |
1576 | |
1577 | extern int currently_reading_symtab; | |
1578 | ||
c906108c SS |
1579 | /* symtab.c lookup functions */ |
1580 | ||
7fc830e2 MK |
1581 | extern const char multiple_symbols_ask[]; |
1582 | extern const char multiple_symbols_all[]; | |
1583 | extern const char multiple_symbols_cancel[]; | |
717d2f5a JB |
1584 | |
1585 | const char *multiple_symbols_select_mode (void); | |
1586 | ||
ececd218 CB |
1587 | bool symbol_matches_domain (enum language symbol_language, |
1588 | domain_enum symbol_domain, | |
1589 | domain_enum domain); | |
4186eb54 | 1590 | |
c378eb4e | 1591 | /* lookup a symbol table by source file name. */ |
c906108c | 1592 | |
1f8cc6db | 1593 | extern struct symtab *lookup_symtab (const char *); |
c906108c | 1594 | |
1993b719 TT |
1595 | /* An object of this type is passed as the 'is_a_field_of_this' |
1596 | argument to lookup_symbol and lookup_symbol_in_language. */ | |
1597 | ||
1598 | struct field_of_this_result | |
1599 | { | |
1600 | /* The type in which the field was found. If this is NULL then the | |
1601 | symbol was not found in 'this'. If non-NULL, then one of the | |
1602 | other fields will be non-NULL as well. */ | |
1603 | ||
1604 | struct type *type; | |
1605 | ||
1606 | /* If the symbol was found as an ordinary field of 'this', then this | |
1607 | is non-NULL and points to the particular field. */ | |
1608 | ||
1609 | struct field *field; | |
1610 | ||
cf901d3b | 1611 | /* If the symbol was found as a function field of 'this', then this |
1993b719 TT |
1612 | is non-NULL and points to the particular field. */ |
1613 | ||
1614 | struct fn_fieldlist *fn_field; | |
1615 | }; | |
1616 | ||
cf901d3b DE |
1617 | /* Find the definition for a specified symbol name NAME |
1618 | in domain DOMAIN in language LANGUAGE, visible from lexical block BLOCK | |
1619 | if non-NULL or from global/static blocks if BLOCK is NULL. | |
1620 | Returns the struct symbol pointer, or NULL if no symbol is found. | |
1621 | C++: if IS_A_FIELD_OF_THIS is non-NULL on entry, check to see if | |
1622 | NAME is a field of the current implied argument `this'. If so fill in the | |
1623 | fields of IS_A_FIELD_OF_THIS, otherwise the fields are set to NULL. | |
cf901d3b | 1624 | The symbol's section is fixed up if necessary. */ |
53c5240f | 1625 | |
d12307c1 PMR |
1626 | extern struct block_symbol |
1627 | lookup_symbol_in_language (const char *, | |
1628 | const struct block *, | |
1629 | const domain_enum, | |
1630 | enum language, | |
1631 | struct field_of_this_result *); | |
53c5240f | 1632 | |
cf901d3b | 1633 | /* Same as lookup_symbol_in_language, but using the current language. */ |
c906108c | 1634 | |
d12307c1 PMR |
1635 | extern struct block_symbol lookup_symbol (const char *, |
1636 | const struct block *, | |
1637 | const domain_enum, | |
1638 | struct field_of_this_result *); | |
c906108c | 1639 | |
de63c46b PA |
1640 | /* Find the definition for a specified symbol search name in domain |
1641 | DOMAIN, visible from lexical block BLOCK if non-NULL or from | |
1642 | global/static blocks if BLOCK is NULL. The passed-in search name | |
1643 | should not come from the user; instead it should already be a | |
1644 | search name as retrieved from a | |
1645 | SYMBOL_SEARCH_NAME/MSYMBOL_SEARCH_NAME call. See definition of | |
1646 | symbol_name_match_type::SEARCH_NAME. Returns the struct symbol | |
1647 | pointer, or NULL if no symbol is found. The symbol's section is | |
1648 | fixed up if necessary. */ | |
1649 | ||
1650 | extern struct block_symbol lookup_symbol_search_name (const char *search_name, | |
1651 | const struct block *block, | |
1652 | domain_enum domain); | |
1653 | ||
5f9a71c3 | 1654 | /* A default version of lookup_symbol_nonlocal for use by languages |
cf901d3b DE |
1655 | that can't think of anything better to do. |
1656 | This implements the C lookup rules. */ | |
5f9a71c3 | 1657 | |
d12307c1 | 1658 | extern struct block_symbol |
f606139a DE |
1659 | basic_lookup_symbol_nonlocal (const struct language_defn *langdef, |
1660 | const char *, | |
1661 | const struct block *, | |
1662 | const domain_enum); | |
5f9a71c3 DC |
1663 | |
1664 | /* Some helper functions for languages that need to write their own | |
1665 | lookup_symbol_nonlocal functions. */ | |
1666 | ||
1667 | /* Lookup a symbol in the static block associated to BLOCK, if there | |
cf901d3b | 1668 | is one; do nothing if BLOCK is NULL or a global block. |
d12307c1 | 1669 | Upon success fixes up the symbol's section if necessary. */ |
5f9a71c3 | 1670 | |
d12307c1 PMR |
1671 | extern struct block_symbol |
1672 | lookup_symbol_in_static_block (const char *name, | |
1673 | const struct block *block, | |
1674 | const domain_enum domain); | |
5f9a71c3 | 1675 | |
08724ab7 | 1676 | /* Search all static file-level symbols for NAME from DOMAIN. |
d12307c1 | 1677 | Upon success fixes up the symbol's section if necessary. */ |
08724ab7 | 1678 | |
d12307c1 PMR |
1679 | extern struct block_symbol lookup_static_symbol (const char *name, |
1680 | const domain_enum domain); | |
08724ab7 | 1681 | |
cf901d3b | 1682 | /* Lookup a symbol in all files' global blocks. |
67be31e5 DE |
1683 | |
1684 | If BLOCK is non-NULL then it is used for two things: | |
1685 | 1) If a target-specific lookup routine for libraries exists, then use the | |
1686 | routine for the objfile of BLOCK, and | |
1687 | 2) The objfile of BLOCK is used to assist in determining the search order | |
1688 | if the target requires it. | |
1689 | See gdbarch_iterate_over_objfiles_in_search_order. | |
1690 | ||
d12307c1 | 1691 | Upon success fixes up the symbol's section if necessary. */ |
5f9a71c3 | 1692 | |
d12307c1 PMR |
1693 | extern struct block_symbol |
1694 | lookup_global_symbol (const char *name, | |
1695 | const struct block *block, | |
1696 | const domain_enum domain); | |
5f9a71c3 | 1697 | |
d1a2d36d | 1698 | /* Lookup a symbol in block BLOCK. |
d12307c1 | 1699 | Upon success fixes up the symbol's section if necessary. */ |
5f9a71c3 | 1700 | |
d12307c1 PMR |
1701 | extern struct symbol * |
1702 | lookup_symbol_in_block (const char *name, | |
de63c46b | 1703 | symbol_name_match_type match_type, |
d12307c1 PMR |
1704 | const struct block *block, |
1705 | const domain_enum domain); | |
5f9a71c3 | 1706 | |
cf901d3b DE |
1707 | /* Look up the `this' symbol for LANG in BLOCK. Return the symbol if |
1708 | found, or NULL if not found. */ | |
1709 | ||
d12307c1 PMR |
1710 | extern struct block_symbol |
1711 | lookup_language_this (const struct language_defn *lang, | |
1712 | const struct block *block); | |
66a17cb6 | 1713 | |
cf901d3b | 1714 | /* Lookup a [struct, union, enum] by name, within a specified block. */ |
c906108c | 1715 | |
270140bd | 1716 | extern struct type *lookup_struct (const char *, const struct block *); |
c906108c | 1717 | |
270140bd | 1718 | extern struct type *lookup_union (const char *, const struct block *); |
c906108c | 1719 | |
270140bd | 1720 | extern struct type *lookup_enum (const char *, const struct block *); |
c906108c | 1721 | |
c906108c SS |
1722 | /* from blockframe.c: */ |
1723 | ||
cd2bb709 PA |
1724 | /* lookup the function symbol corresponding to the address. The |
1725 | return value will not be an inlined function; the containing | |
1726 | function will be returned instead. */ | |
c906108c | 1727 | |
a14ed312 | 1728 | extern struct symbol *find_pc_function (CORE_ADDR); |
c906108c | 1729 | |
cd2bb709 PA |
1730 | /* lookup the function corresponding to the address and section. The |
1731 | return value will not be an inlined function; the containing | |
1732 | function will be returned instead. */ | |
c906108c | 1733 | |
714835d5 | 1734 | extern struct symbol *find_pc_sect_function (CORE_ADDR, struct obj_section *); |
c5aa993b | 1735 | |
cd2bb709 PA |
1736 | /* lookup the function symbol corresponding to the address and |
1737 | section. The return value will be the closest enclosing function, | |
1738 | which might be an inline function. */ | |
1739 | ||
1740 | extern struct symbol *find_pc_sect_containing_function | |
1741 | (CORE_ADDR pc, struct obj_section *section); | |
1742 | ||
71a3c369 TT |
1743 | /* Find the symbol at the given address. Returns NULL if no symbol |
1744 | found. Only exact matches for ADDRESS are considered. */ | |
1745 | ||
1746 | extern struct symbol *find_symbol_at_address (CORE_ADDR); | |
1747 | ||
fc811edd KB |
1748 | /* Finds the "function" (text symbol) that is smaller than PC but |
1749 | greatest of all of the potential text symbols in SECTION. Sets | |
1750 | *NAME and/or *ADDRESS conditionally if that pointer is non-null. | |
1751 | If ENDADDR is non-null, then set *ENDADDR to be the end of the | |
1752 | function (exclusive). If the optional parameter BLOCK is non-null, | |
1753 | then set *BLOCK to the address of the block corresponding to the | |
1754 | function symbol, if such a symbol could be found during the lookup; | |
1755 | nullptr is used as a return value for *BLOCK if no block is found. | |
1756 | This function either succeeds or fails (not halfway succeeds). If | |
1757 | it succeeds, it sets *NAME, *ADDRESS, and *ENDADDR to real | |
ececd218 CB |
1758 | information and returns true. If it fails, it sets *NAME, *ADDRESS |
1759 | and *ENDADDR to zero and returns false. | |
fc811edd KB |
1760 | |
1761 | If the function in question occupies non-contiguous ranges, | |
1762 | *ADDRESS and *ENDADDR are (subject to the conditions noted above) set | |
1763 | to the start and end of the range in which PC is found. Thus | |
1764 | *ADDRESS <= PC < *ENDADDR with no intervening gaps (in which ranges | |
1765 | from other functions might be found). | |
1766 | ||
1767 | This property allows find_pc_partial_function to be used (as it had | |
1768 | been prior to the introduction of non-contiguous range support) by | |
1769 | various tdep files for finding a start address and limit address | |
1770 | for prologue analysis. This still isn't ideal, however, because we | |
1771 | probably shouldn't be doing prologue analysis (in which | |
1772 | instructions are scanned to determine frame size and stack layout) | |
1773 | for any range that doesn't contain the entry pc. Moreover, a good | |
1774 | argument can be made that prologue analysis ought to be performed | |
1775 | starting from the entry pc even when PC is within some other range. | |
1776 | This might suggest that *ADDRESS and *ENDADDR ought to be set to the | |
1777 | limits of the entry pc range, but that will cause the | |
1778 | *ADDRESS <= PC < *ENDADDR condition to be violated; many of the | |
59adbf5d KB |
1779 | callers of find_pc_partial_function expect this condition to hold. |
1780 | ||
1781 | Callers which require the start and/or end addresses for the range | |
1782 | containing the entry pc should instead call | |
1783 | find_function_entry_range_from_pc. */ | |
fc811edd | 1784 | |
ececd218 CB |
1785 | extern bool find_pc_partial_function (CORE_ADDR pc, const char **name, |
1786 | CORE_ADDR *address, CORE_ADDR *endaddr, | |
1787 | const struct block **block = nullptr); | |
c906108c | 1788 | |
59adbf5d KB |
1789 | /* Like find_pc_partial_function, above, but *ADDRESS and *ENDADDR are |
1790 | set to start and end addresses of the range containing the entry pc. | |
1791 | ||
1792 | Note that it is not necessarily the case that (for non-NULL ADDRESS | |
1793 | and ENDADDR arguments) the *ADDRESS <= PC < *ENDADDR condition will | |
1794 | hold. | |
1795 | ||
1796 | See comment for find_pc_partial_function, above, for further | |
1797 | explanation. */ | |
1798 | ||
1799 | extern bool find_function_entry_range_from_pc (CORE_ADDR pc, | |
1800 | const char **name, | |
1801 | CORE_ADDR *address, | |
1802 | CORE_ADDR *endaddr); | |
1803 | ||
8388016d PA |
1804 | /* Return the type of a function with its first instruction exactly at |
1805 | the PC address. Return NULL otherwise. */ | |
1806 | ||
1807 | extern struct type *find_function_type (CORE_ADDR pc); | |
1808 | ||
1809 | /* See if we can figure out the function's actual type from the type | |
1810 | that the resolver returns. RESOLVER_FUNADDR is the address of the | |
1811 | ifunc resolver. */ | |
1812 | ||
1813 | extern struct type *find_gnu_ifunc_target_type (CORE_ADDR resolver_funaddr); | |
1814 | ||
ca31ab1d PA |
1815 | /* Find the GNU ifunc minimal symbol that matches SYM. */ |
1816 | extern bound_minimal_symbol find_gnu_ifunc (const symbol *sym); | |
1817 | ||
a14ed312 | 1818 | extern void clear_pc_function_cache (void); |
c906108c | 1819 | |
2097ae25 | 1820 | /* Expand symtab containing PC, SECTION if not already expanded. */ |
c906108c | 1821 | |
2097ae25 | 1822 | extern void expand_symtab_containing_pc (CORE_ADDR, struct obj_section *); |
c906108c | 1823 | |
c378eb4e | 1824 | /* lookup full symbol table by address. */ |
c906108c | 1825 | |
43f3e411 | 1826 | extern struct compunit_symtab *find_pc_compunit_symtab (CORE_ADDR); |
c906108c | 1827 | |
c378eb4e | 1828 | /* lookup full symbol table by address and section. */ |
c906108c | 1829 | |
43f3e411 DE |
1830 | extern struct compunit_symtab * |
1831 | find_pc_sect_compunit_symtab (CORE_ADDR, struct obj_section *); | |
c906108c | 1832 | |
ececd218 | 1833 | extern bool find_pc_line_pc_range (CORE_ADDR, CORE_ADDR *, CORE_ADDR *); |
c906108c | 1834 | |
a14ed312 | 1835 | extern void reread_symbols (void); |
c906108c | 1836 | |
cf901d3b DE |
1837 | /* Look up a type named NAME in STRUCT_DOMAIN in the current language. |
1838 | The type returned must not be opaque -- i.e., must have at least one field | |
1839 | defined. */ | |
1840 | ||
a14ed312 | 1841 | extern struct type *lookup_transparent_type (const char *); |
c906108c | 1842 | |
cf901d3b | 1843 | extern struct type *basic_lookup_transparent_type (const char *); |
c906108c | 1844 | |
c378eb4e | 1845 | /* Macro for name of symbol to indicate a file compiled with gcc. */ |
c906108c SS |
1846 | #ifndef GCC_COMPILED_FLAG_SYMBOL |
1847 | #define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled." | |
1848 | #endif | |
1849 | ||
c378eb4e | 1850 | /* Macro for name of symbol to indicate a file compiled with gcc2. */ |
c906108c SS |
1851 | #ifndef GCC2_COMPILED_FLAG_SYMBOL |
1852 | #define GCC2_COMPILED_FLAG_SYMBOL "gcc2_compiled." | |
1853 | #endif | |
1854 | ||
ececd218 | 1855 | extern bool in_gnu_ifunc_stub (CORE_ADDR pc); |
0875794a | 1856 | |
07be84bf JK |
1857 | /* Functions for resolving STT_GNU_IFUNC symbols which are implemented only |
1858 | for ELF symbol files. */ | |
1859 | ||
1860 | struct gnu_ifunc_fns | |
1861 | { | |
1862 | /* See elf_gnu_ifunc_resolve_addr for its real implementation. */ | |
1863 | CORE_ADDR (*gnu_ifunc_resolve_addr) (struct gdbarch *gdbarch, CORE_ADDR pc); | |
1864 | ||
1865 | /* See elf_gnu_ifunc_resolve_name for its real implementation. */ | |
ececd218 | 1866 | bool (*gnu_ifunc_resolve_name) (const char *function_name, |
07be84bf | 1867 | CORE_ADDR *function_address_p); |
0e30163f JK |
1868 | |
1869 | /* See elf_gnu_ifunc_resolver_stop for its real implementation. */ | |
1870 | void (*gnu_ifunc_resolver_stop) (struct breakpoint *b); | |
1871 | ||
1872 | /* See elf_gnu_ifunc_resolver_return_stop for its real implementation. */ | |
1873 | void (*gnu_ifunc_resolver_return_stop) (struct breakpoint *b); | |
07be84bf JK |
1874 | }; |
1875 | ||
1876 | #define gnu_ifunc_resolve_addr gnu_ifunc_fns_p->gnu_ifunc_resolve_addr | |
1877 | #define gnu_ifunc_resolve_name gnu_ifunc_fns_p->gnu_ifunc_resolve_name | |
0e30163f JK |
1878 | #define gnu_ifunc_resolver_stop gnu_ifunc_fns_p->gnu_ifunc_resolver_stop |
1879 | #define gnu_ifunc_resolver_return_stop \ | |
1880 | gnu_ifunc_fns_p->gnu_ifunc_resolver_return_stop | |
07be84bf JK |
1881 | |
1882 | extern const struct gnu_ifunc_fns *gnu_ifunc_fns_p; | |
1883 | ||
52f729a7 | 1884 | extern CORE_ADDR find_solib_trampoline_target (struct frame_info *, CORE_ADDR); |
c906108c | 1885 | |
c906108c | 1886 | struct symtab_and_line |
17c5ed2c | 1887 | { |
6c95b8df | 1888 | /* The program space of this sal. */ |
51abb421 | 1889 | struct program_space *pspace = NULL; |
6c95b8df | 1890 | |
51abb421 | 1891 | struct symtab *symtab = NULL; |
06871ae8 | 1892 | struct symbol *symbol = NULL; |
51abb421 | 1893 | struct obj_section *section = NULL; |
3467ec66 | 1894 | struct minimal_symbol *msymbol = NULL; |
17c5ed2c DC |
1895 | /* Line number. Line numbers start at 1 and proceed through symtab->nlines. |
1896 | 0 is never a valid line number; it is used to indicate that line number | |
1897 | information is not available. */ | |
51abb421 | 1898 | int line = 0; |
17c5ed2c | 1899 | |
51abb421 PA |
1900 | CORE_ADDR pc = 0; |
1901 | CORE_ADDR end = 0; | |
1902 | bool explicit_pc = false; | |
1903 | bool explicit_line = false; | |
55aa24fb SDJ |
1904 | |
1905 | /* The probe associated with this symtab_and_line. */ | |
935676c9 | 1906 | probe *prob = NULL; |
729662a5 TT |
1907 | /* If PROBE is not NULL, then this is the objfile in which the probe |
1908 | originated. */ | |
51abb421 | 1909 | struct objfile *objfile = NULL; |
17c5ed2c | 1910 | }; |
c906108c | 1911 | |
c5aa993b | 1912 | \f |
c906108c | 1913 | |
c906108c SS |
1914 | /* Given a pc value, return line number it is in. Second arg nonzero means |
1915 | if pc is on the boundary use the previous statement's line number. */ | |
1916 | ||
a14ed312 | 1917 | extern struct symtab_and_line find_pc_line (CORE_ADDR, int); |
c906108c | 1918 | |
c378eb4e | 1919 | /* Same function, but specify a section as well as an address. */ |
c906108c | 1920 | |
714835d5 UW |
1921 | extern struct symtab_and_line find_pc_sect_line (CORE_ADDR, |
1922 | struct obj_section *, int); | |
c906108c | 1923 | |
34248c3a DE |
1924 | /* Wrapper around find_pc_line to just return the symtab. */ |
1925 | ||
1926 | extern struct symtab *find_pc_line_symtab (CORE_ADDR); | |
1927 | ||
c906108c SS |
1928 | /* Given a symtab and line number, return the pc there. */ |
1929 | ||
ececd218 | 1930 | extern bool find_line_pc (struct symtab *, int, CORE_ADDR *); |
c906108c | 1931 | |
ececd218 CB |
1932 | extern bool find_line_pc_range (struct symtab_and_line, CORE_ADDR *, |
1933 | CORE_ADDR *); | |
c906108c | 1934 | |
a14ed312 | 1935 | extern void resolve_sal_pc (struct symtab_and_line *); |
c906108c | 1936 | |
f176c4b5 | 1937 | /* solib.c */ |
c906108c | 1938 | |
a14ed312 | 1939 | extern void clear_solib (void); |
c906108c | 1940 | |
c6756f62 PA |
1941 | /* The reason we're calling into a completion match list collector |
1942 | function. */ | |
1943 | enum class complete_symbol_mode | |
1944 | { | |
1945 | /* Completing an expression. */ | |
1946 | EXPRESSION, | |
1947 | ||
1948 | /* Completing a linespec. */ | |
1949 | LINESPEC, | |
1950 | }; | |
1951 | ||
eb3ff9a5 PA |
1952 | extern void default_collect_symbol_completion_matches_break_on |
1953 | (completion_tracker &tracker, | |
c6756f62 | 1954 | complete_symbol_mode mode, |
b5ec771e | 1955 | symbol_name_match_type name_match_type, |
eb3ff9a5 | 1956 | const char *text, const char *word, const char *break_on, |
2f68a895 | 1957 | enum type_code code); |
eb3ff9a5 PA |
1958 | extern void default_collect_symbol_completion_matches |
1959 | (completion_tracker &tracker, | |
c6756f62 | 1960 | complete_symbol_mode, |
b5ec771e | 1961 | symbol_name_match_type name_match_type, |
eb3ff9a5 PA |
1962 | const char *, |
1963 | const char *, | |
1964 | enum type_code); | |
b5ec771e PA |
1965 | extern void collect_symbol_completion_matches |
1966 | (completion_tracker &tracker, | |
1967 | complete_symbol_mode mode, | |
1968 | symbol_name_match_type name_match_type, | |
1969 | const char *, const char *); | |
eb3ff9a5 PA |
1970 | extern void collect_symbol_completion_matches_type (completion_tracker &tracker, |
1971 | const char *, const char *, | |
2f68a895 | 1972 | enum type_code); |
c906108c | 1973 | |
b5ec771e PA |
1974 | extern void collect_file_symbol_completion_matches |
1975 | (completion_tracker &tracker, | |
1976 | complete_symbol_mode, | |
1977 | symbol_name_match_type name_match_type, | |
1978 | const char *, const char *, const char *); | |
c94fdfd0 | 1979 | |
eb3ff9a5 PA |
1980 | extern completion_list |
1981 | make_source_files_completion_list (const char *, const char *); | |
c94fdfd0 | 1982 | |
f9d67a22 PA |
1983 | /* Return whether SYM is a function/method, as opposed to a data symbol. */ |
1984 | ||
1985 | extern bool symbol_is_function_or_method (symbol *sym); | |
1986 | ||
1987 | /* Return whether MSYMBOL is a function/method, as opposed to a data | |
1988 | symbol */ | |
1989 | ||
1990 | extern bool symbol_is_function_or_method (minimal_symbol *msymbol); | |
1991 | ||
1992 | /* Return whether SYM should be skipped in completion mode MODE. In | |
1993 | linespec mode, we're only interested in functions/methods. */ | |
1994 | ||
1995 | template<typename Symbol> | |
1996 | static bool | |
1997 | completion_skip_symbol (complete_symbol_mode mode, Symbol *sym) | |
1998 | { | |
1999 | return (mode == complete_symbol_mode::LINESPEC | |
2000 | && !symbol_is_function_or_method (sym)); | |
2001 | } | |
2002 | ||
c906108c SS |
2003 | /* symtab.c */ |
2004 | ||
ececd218 | 2005 | bool matching_obj_sections (struct obj_section *, struct obj_section *); |
94277a38 | 2006 | |
ececd218 | 2007 | extern struct symtab *find_line_symtab (struct symtab *, int, int *, bool *); |
50641945 | 2008 | |
42ddae10 PA |
2009 | /* Given a function symbol SYM, find the symtab and line for the start |
2010 | of the function. If FUNFIRSTLINE is true, we want the first line | |
2011 | of real code inside the function. */ | |
2012 | extern symtab_and_line find_function_start_sal (symbol *sym, bool | |
2013 | funfirstline); | |
2014 | ||
2015 | /* Same, but start with a function address/section instead of a | |
2016 | symbol. */ | |
2017 | extern symtab_and_line find_function_start_sal (CORE_ADDR func_addr, | |
2018 | obj_section *section, | |
2019 | bool funfirstline); | |
50641945 | 2020 | |
059acae7 UW |
2021 | extern void skip_prologue_sal (struct symtab_and_line *); |
2022 | ||
c906108c SS |
2023 | /* symtab.c */ |
2024 | ||
d80b854b UW |
2025 | extern CORE_ADDR skip_prologue_using_sal (struct gdbarch *gdbarch, |
2026 | CORE_ADDR func_addr); | |
634aa483 | 2027 | |
a14ed312 KB |
2028 | extern struct symbol *fixup_symbol_section (struct symbol *, |
2029 | struct objfile *); | |
c906108c | 2030 | |
bf223d3e PA |
2031 | /* If MSYMBOL is an text symbol, look for a function debug symbol with |
2032 | the same address. Returns NULL if not found. This is necessary in | |
2033 | case a function is an alias to some other function, because debug | |
2034 | information is only emitted for the alias target function's | |
2035 | definition, not for the alias. */ | |
2036 | extern symbol *find_function_alias_target (bound_minimal_symbol msymbol); | |
2037 | ||
c906108c | 2038 | /* Symbol searching */ |
5c04624b DE |
2039 | /* Note: struct symbol_search, search_symbols, et.al. are declared here, |
2040 | instead of making them local to symtab.c, for gdbtk's sake. */ | |
c906108c | 2041 | |
b9c04fb2 TT |
2042 | /* When using search_symbols, a vector of the following structs is |
2043 | returned. */ | |
c906108c | 2044 | struct symbol_search |
17c5ed2c | 2045 | { |
b9c04fb2 TT |
2046 | symbol_search (int block_, struct symbol *symbol_) |
2047 | : block (block_), | |
2048 | symbol (symbol_) | |
2049 | { | |
2050 | msymbol.minsym = nullptr; | |
2051 | msymbol.objfile = nullptr; | |
2052 | } | |
2053 | ||
2054 | symbol_search (int block_, struct minimal_symbol *minsym, | |
2055 | struct objfile *objfile) | |
2056 | : block (block_), | |
2057 | symbol (nullptr) | |
2058 | { | |
2059 | msymbol.minsym = minsym; | |
2060 | msymbol.objfile = objfile; | |
2061 | } | |
2062 | ||
2063 | bool operator< (const symbol_search &other) const | |
2064 | { | |
2065 | return compare_search_syms (*this, other) < 0; | |
2066 | } | |
2067 | ||
2068 | bool operator== (const symbol_search &other) const | |
2069 | { | |
2070 | return compare_search_syms (*this, other) == 0; | |
2071 | } | |
2072 | ||
c378eb4e MS |
2073 | /* The block in which the match was found. Could be, for example, |
2074 | STATIC_BLOCK or GLOBAL_BLOCK. */ | |
17c5ed2c | 2075 | int block; |
c906108c | 2076 | |
17c5ed2c | 2077 | /* Information describing what was found. |
c906108c | 2078 | |
d01060f0 | 2079 | If symbol is NOT NULL, then information was found for this match. */ |
17c5ed2c | 2080 | struct symbol *symbol; |
c906108c | 2081 | |
17c5ed2c | 2082 | /* If msymbol is non-null, then a match was made on something for |
c378eb4e | 2083 | which only minimal_symbols exist. */ |
7c7b6655 | 2084 | struct bound_minimal_symbol msymbol; |
c906108c | 2085 | |
b9c04fb2 TT |
2086 | private: |
2087 | ||
2088 | static int compare_search_syms (const symbol_search &sym_a, | |
2089 | const symbol_search &sym_b); | |
17c5ed2c | 2090 | }; |
c906108c | 2091 | |
b9c04fb2 | 2092 | extern std::vector<symbol_search> search_symbols (const char *, |
12615cba PW |
2093 | enum search_domain, |
2094 | const char *, | |
2095 | int, | |
4acfdd20 AB |
2096 | const char **, |
2097 | bool); | |
165f8965 AB |
2098 | |
2099 | /* When searching for Fortran symbols within modules (functions/variables) | |
2100 | we return a vector of this type. The first item in the pair is the | |
2101 | module symbol, and the second item is the symbol for the function or | |
2102 | variable we found. */ | |
2103 | typedef std::pair<symbol_search, symbol_search> module_symbol_search; | |
2104 | ||
2105 | /* Searches the symbols to find function and variables symbols (depending | |
2106 | on KIND) within Fortran modules. The MODULE_REGEXP matches against the | |
2107 | name of the module, REGEXP matches against the name of the symbol within | |
2108 | the module, and TYPE_REGEXP matches against the type of the symbol | |
2109 | within the module. */ | |
2110 | extern std::vector<module_symbol_search> search_module_symbols | |
2111 | (const char *module_regexp, const char *regexp, | |
2112 | const char *type_regexp, search_domain kind); | |
2113 | ||
12615cba PW |
2114 | extern bool treg_matches_sym_type_name (const compiled_regex &treg, |
2115 | const struct symbol *sym); | |
c906108c | 2116 | |
cd215b2e TT |
2117 | /* The name of the ``main'' function. */ |
2118 | extern const char *main_name (); | |
9e6c82ad | 2119 | extern enum language main_language (void); |
51cc5b07 | 2120 | |
442853af CB |
2121 | /* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global or static blocks, |
2122 | as specified by BLOCK_INDEX. | |
cf901d3b DE |
2123 | This searches MAIN_OBJFILE as well as any associated separate debug info |
2124 | objfiles of MAIN_OBJFILE. | |
442853af | 2125 | BLOCK_INDEX can be GLOBAL_BLOCK or STATIC_BLOCK. |
d12307c1 | 2126 | Upon success fixes up the symbol's section if necessary. */ |
cf901d3b | 2127 | |
d12307c1 | 2128 | extern struct block_symbol |
efad9b6a | 2129 | lookup_global_symbol_from_objfile (struct objfile *main_objfile, |
442853af | 2130 | enum block_enum block_index, |
cf901d3b DE |
2131 | const char *name, |
2132 | const domain_enum domain); | |
3a40aaa0 | 2133 | |
a6c727b2 DJ |
2134 | /* Return 1 if the supplied producer string matches the ARM RealView |
2135 | compiler (armcc). */ | |
ececd218 | 2136 | bool producer_is_realview (const char *producer); |
3a40aaa0 | 2137 | |
ccefe4c4 TT |
2138 | void fixup_section (struct general_symbol_info *ginfo, |
2139 | CORE_ADDR addr, struct objfile *objfile); | |
2140 | ||
cf901d3b DE |
2141 | /* Look up objfile containing BLOCK. */ |
2142 | ||
c0201579 JK |
2143 | struct objfile *lookup_objfile_from_block (const struct block *block); |
2144 | ||
db0fec5c | 2145 | extern unsigned int symtab_create_debug; |
45cfd468 | 2146 | |
cc485e62 DE |
2147 | extern unsigned int symbol_lookup_debug; |
2148 | ||
491144b5 | 2149 | extern bool basenames_may_differ; |
c011a4f4 | 2150 | |
ececd218 CB |
2151 | bool compare_filenames_for_search (const char *filename, |
2152 | const char *search_name); | |
4aac40c8 | 2153 | |
ececd218 CB |
2154 | bool compare_glob_filenames_for_search (const char *filename, |
2155 | const char *search_name); | |
cce0e923 | 2156 | |
14bc53a8 PA |
2157 | bool iterate_over_some_symtabs (const char *name, |
2158 | const char *real_path, | |
2159 | struct compunit_symtab *first, | |
2160 | struct compunit_symtab *after_last, | |
2161 | gdb::function_view<bool (symtab *)> callback); | |
f8eba3c6 TT |
2162 | |
2163 | void iterate_over_symtabs (const char *name, | |
14bc53a8 PA |
2164 | gdb::function_view<bool (symtab *)> callback); |
2165 | ||
f8eba3c6 | 2166 | |
67d89901 TT |
2167 | std::vector<CORE_ADDR> find_pcs_for_symtab_line |
2168 | (struct symtab *symtab, int line, struct linetable_entry **best_entry); | |
f8eba3c6 | 2169 | |
14bc53a8 PA |
2170 | /* Prototype for callbacks for LA_ITERATE_OVER_SYMBOLS. The callback |
2171 | is called once per matching symbol SYM. The callback should return | |
2172 | true to indicate that LA_ITERATE_OVER_SYMBOLS should continue | |
2173 | iterating, or false to indicate that the iteration should end. */ | |
8e704927 | 2174 | |
7e41c8db | 2175 | typedef bool (symbol_found_callback_ftype) (struct block_symbol *bsym); |
8e704927 | 2176 | |
6969f124 TT |
2177 | /* Iterate over the symbols named NAME, matching DOMAIN, in BLOCK. |
2178 | ||
2179 | For each symbol that matches, CALLBACK is called. The symbol is | |
2180 | passed to the callback. | |
2181 | ||
2182 | If CALLBACK returns false, the iteration ends and this function | |
2183 | returns false. Otherwise, the search continues, and the function | |
2184 | eventually returns true. */ | |
2185 | ||
2186 | bool iterate_over_symbols (const struct block *block, | |
b5ec771e | 2187 | const lookup_name_info &name, |
f8eba3c6 | 2188 | const domain_enum domain, |
14bc53a8 | 2189 | gdb::function_view<symbol_found_callback_ftype> callback); |
f8eba3c6 | 2190 | |
6a3dbf1b TT |
2191 | /* Like iterate_over_symbols, but if all calls to CALLBACK return |
2192 | true, then calls CALLBACK one additional time with a block_symbol | |
2193 | that has a valid block but a NULL symbol. */ | |
2194 | ||
2195 | bool iterate_over_symbols_terminated | |
2196 | (const struct block *block, | |
2197 | const lookup_name_info &name, | |
2198 | const domain_enum domain, | |
2199 | gdb::function_view<symbol_found_callback_ftype> callback); | |
2200 | ||
2f408ecb PA |
2201 | /* Storage type used by demangle_for_lookup. demangle_for_lookup |
2202 | either returns a const char * pointer that points to either of the | |
2203 | fields of this type, or a pointer to the input NAME. This is done | |
2204 | this way because the underlying functions that demangle_for_lookup | |
2205 | calls either return a std::string (e.g., cp_canonicalize_string) or | |
2206 | a malloc'ed buffer (libiberty's demangled), and we want to avoid | |
2207 | unnecessary reallocation/string copying. */ | |
2208 | class demangle_result_storage | |
2209 | { | |
2210 | public: | |
2211 | ||
2212 | /* Swap the std::string storage with STR, and return a pointer to | |
2213 | the beginning of the new string. */ | |
2214 | const char *swap_string (std::string &str) | |
2215 | { | |
2216 | std::swap (m_string, str); | |
2217 | return m_string.c_str (); | |
2218 | } | |
2219 | ||
2220 | /* Set the malloc storage to now point at PTR. Any previous malloc | |
2221 | storage is released. */ | |
2222 | const char *set_malloc_ptr (char *ptr) | |
2223 | { | |
2224 | m_malloc.reset (ptr); | |
2225 | return ptr; | |
2226 | } | |
2227 | ||
2228 | private: | |
2229 | ||
2230 | /* The storage. */ | |
2231 | std::string m_string; | |
2232 | gdb::unique_xmalloc_ptr<char> m_malloc; | |
2233 | }; | |
2234 | ||
2235 | const char * | |
2236 | demangle_for_lookup (const char *name, enum language lang, | |
2237 | demangle_result_storage &storage); | |
f8eba3c6 | 2238 | |
e623cf5d TT |
2239 | struct symbol *allocate_symbol (struct objfile *); |
2240 | ||
38bf1463 | 2241 | void initialize_objfile_symbol (struct symbol *); |
e623cf5d TT |
2242 | |
2243 | struct template_symbol *allocate_template_symbol (struct objfile *); | |
2244 | ||
b5ec771e PA |
2245 | /* Test to see if the symbol of language SYMBOL_LANGUAGE specified by |
2246 | SYMNAME (which is already demangled for C++ symbols) matches | |
2247 | SYM_TEXT in the first SYM_TEXT_LEN characters. If so, add it to | |
2248 | the current completion list. */ | |
2249 | void completion_list_add_name (completion_tracker &tracker, | |
2250 | language symbol_language, | |
2251 | const char *symname, | |
2252 | const lookup_name_info &lookup_name, | |
b5ec771e PA |
2253 | const char *text, const char *word); |
2254 | ||
fcaad03c KS |
2255 | /* A simple symbol searching class. */ |
2256 | ||
2257 | class symbol_searcher | |
2258 | { | |
2259 | public: | |
2260 | /* Returns the symbols found for the search. */ | |
2261 | const std::vector<block_symbol> & | |
2262 | matching_symbols () const | |
2263 | { | |
2264 | return m_symbols; | |
2265 | } | |
2266 | ||
2267 | /* Returns the minimal symbols found for the search. */ | |
2268 | const std::vector<bound_minimal_symbol> & | |
2269 | matching_msymbols () const | |
2270 | { | |
2271 | return m_minimal_symbols; | |
2272 | } | |
2273 | ||
2274 | /* Search for all symbols named NAME in LANGUAGE with DOMAIN, restricting | |
2275 | search to FILE_SYMTABS and SEARCH_PSPACE, both of which may be NULL | |
2276 | to search all symtabs and program spaces. */ | |
2277 | void find_all_symbols (const std::string &name, | |
2278 | const struct language_defn *language, | |
2279 | enum search_domain search_domain, | |
2280 | std::vector<symtab *> *search_symtabs, | |
2281 | struct program_space *search_pspace); | |
2282 | ||
2283 | /* Reset this object to perform another search. */ | |
2284 | void reset () | |
2285 | { | |
2286 | m_symbols.clear (); | |
2287 | m_minimal_symbols.clear (); | |
2288 | } | |
2289 | ||
2290 | private: | |
2291 | /* Matching debug symbols. */ | |
2292 | std::vector<block_symbol> m_symbols; | |
2293 | ||
2294 | /* Matching non-debug symbols. */ | |
2295 | std::vector<bound_minimal_symbol> m_minimal_symbols; | |
2296 | }; | |
2297 | ||
c906108c | 2298 | #endif /* !defined(SYMTAB_H) */ |