symtab.h revision 1.1 1 1.1 christos /* Symbol table definitions for GDB.
2 1.1 christos
3 1.1 christos Copyright (C) 1986-2014 Free Software Foundation, Inc.
4 1.1 christos
5 1.1 christos This file is part of GDB.
6 1.1 christos
7 1.1 christos This program is free software; you can redistribute it and/or modify
8 1.1 christos it under the terms of the GNU General Public License as published by
9 1.1 christos the Free Software Foundation; either version 3 of the License, or
10 1.1 christos (at your option) any later version.
11 1.1 christos
12 1.1 christos This program is distributed in the hope that it will be useful,
13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 1.1 christos GNU General Public License for more details.
16 1.1 christos
17 1.1 christos You should have received a copy of the GNU General Public License
18 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 1.1 christos
20 1.1 christos #if !defined (SYMTAB_H)
21 1.1 christos #define SYMTAB_H 1
22 1.1 christos
23 1.1 christos #include "vec.h"
24 1.1 christos #include "gdb_vecs.h"
25 1.1 christos #include "gdbtypes.h"
26 1.1 christos
27 1.1 christos /* Opaque declarations. */
28 1.1 christos struct ui_file;
29 1.1 christos struct frame_info;
30 1.1 christos struct symbol;
31 1.1 christos struct obstack;
32 1.1 christos struct objfile;
33 1.1 christos struct block;
34 1.1 christos struct blockvector;
35 1.1 christos struct axs_value;
36 1.1 christos struct agent_expr;
37 1.1 christos struct program_space;
38 1.1 christos struct language_defn;
39 1.1 christos struct probe;
40 1.1 christos struct common_block;
41 1.1 christos
42 1.1 christos /* Some of the structures in this file are space critical.
43 1.1 christos The space-critical structures are:
44 1.1 christos
45 1.1 christos struct general_symbol_info
46 1.1 christos struct symbol
47 1.1 christos struct partial_symbol
48 1.1 christos
49 1.1 christos These structures are laid out to encourage good packing.
50 1.1 christos They use ENUM_BITFIELD and short int fields, and they order the
51 1.1 christos structure members so that fields less than a word are next
52 1.1 christos to each other so they can be packed together. */
53 1.1 christos
54 1.1 christos /* Rearranged: used ENUM_BITFIELD and rearranged field order in
55 1.1 christos all the space critical structures (plus struct minimal_symbol).
56 1.1 christos Memory usage dropped from 99360768 bytes to 90001408 bytes.
57 1.1 christos I measured this with before-and-after tests of
58 1.1 christos "HEAD-old-gdb -readnow HEAD-old-gdb" and
59 1.1 christos "HEAD-new-gdb -readnow HEAD-old-gdb" on native i686-pc-linux-gnu,
60 1.1 christos red hat linux 8, with LD_LIBRARY_PATH=/usr/lib/debug,
61 1.1 christos typing "maint space 1" at the first command prompt.
62 1.1 christos
63 1.1 christos Here is another measurement (from andrew c):
64 1.1 christos # no /usr/lib/debug, just plain glibc, like a normal user
65 1.1 christos gdb HEAD-old-gdb
66 1.1 christos (gdb) break internal_error
67 1.1 christos (gdb) run
68 1.1 christos (gdb) maint internal-error
69 1.1 christos (gdb) backtrace
70 1.1 christos (gdb) maint space 1
71 1.1 christos
72 1.1 christos gdb gdb_6_0_branch 2003-08-19 space used: 8896512
73 1.1 christos gdb HEAD 2003-08-19 space used: 8904704
74 1.1 christos gdb HEAD 2003-08-21 space used: 8396800 (+symtab.h)
75 1.1 christos gdb HEAD 2003-08-21 space used: 8265728 (+gdbtypes.h)
76 1.1 christos
77 1.1 christos The third line shows the savings from the optimizations in symtab.h.
78 1.1 christos The fourth line shows the savings from the optimizations in
79 1.1 christos gdbtypes.h. Both optimizations are in gdb HEAD now.
80 1.1 christos
81 1.1 christos --chastain 2003-08-21 */
82 1.1 christos
83 1.1 christos /* Struct for storing C++ specific information. Allocated when needed. */
84 1.1 christos
85 1.1 christos struct cplus_specific
86 1.1 christos {
87 1.1 christos const char *demangled_name;
88 1.1 christos };
89 1.1 christos
90 1.1 christos /* Define a structure for the information that is common to all symbol types,
91 1.1 christos including minimal symbols, partial symbols, and full symbols. In a
92 1.1 christos multilanguage environment, some language specific information may need to
93 1.1 christos be recorded along with each symbol. */
94 1.1 christos
95 1.1 christos /* This structure is space critical. See space comments at the top. */
96 1.1 christos
97 1.1 christos struct general_symbol_info
98 1.1 christos {
99 1.1 christos /* Name of the symbol. This is a required field. Storage for the
100 1.1 christos name is allocated on the objfile_obstack for the associated
101 1.1 christos objfile. For languages like C++ that make a distinction between
102 1.1 christos the mangled name and demangled name, this is the mangled
103 1.1 christos name. */
104 1.1 christos
105 1.1 christos const char *name;
106 1.1 christos
107 1.1 christos /* Value of the symbol. Which member of this union to use, and what
108 1.1 christos it means, depends on what kind of symbol this is and its
109 1.1 christos SYMBOL_CLASS. See comments there for more details. All of these
110 1.1 christos are in host byte order (though what they point to might be in
111 1.1 christos target byte order, e.g. LOC_CONST_BYTES). */
112 1.1 christos
113 1.1 christos union
114 1.1 christos {
115 1.1 christos LONGEST ivalue;
116 1.1 christos
117 1.1 christos struct block *block;
118 1.1 christos
119 1.1 christos const gdb_byte *bytes;
120 1.1 christos
121 1.1 christos CORE_ADDR address;
122 1.1 christos
123 1.1 christos /* A common block. Used with LOC_COMMON_BLOCK. */
124 1.1 christos
125 1.1 christos struct common_block *common_block;
126 1.1 christos
127 1.1 christos /* For opaque typedef struct chain. */
128 1.1 christos
129 1.1 christos struct symbol *chain;
130 1.1 christos }
131 1.1 christos value;
132 1.1 christos
133 1.1 christos /* Since one and only one language can apply, wrap the language specific
134 1.1 christos information inside a union. */
135 1.1 christos
136 1.1 christos union
137 1.1 christos {
138 1.1 christos /* A pointer to an obstack that can be used for storage associated
139 1.1 christos with this symbol. This is only used by Ada, and only when the
140 1.1 christos 'ada_mangled' field is zero. */
141 1.1 christos struct obstack *obstack;
142 1.1 christos
143 1.1 christos /* This is used by languages which wish to store a demangled name.
144 1.1 christos currently used by Ada, Java, and Objective C. */
145 1.1 christos struct mangled_lang
146 1.1 christos {
147 1.1 christos const char *demangled_name;
148 1.1 christos }
149 1.1 christos mangled_lang;
150 1.1 christos
151 1.1 christos struct cplus_specific *cplus_specific;
152 1.1 christos }
153 1.1 christos language_specific;
154 1.1 christos
155 1.1 christos /* Record the source code language that applies to this symbol.
156 1.1 christos This is used to select one of the fields from the language specific
157 1.1 christos union above. */
158 1.1 christos
159 1.1 christos ENUM_BITFIELD(language) language : 8;
160 1.1 christos
161 1.1 christos /* This is only used by Ada. If set, then the 'mangled_lang' field
162 1.1 christos of language_specific is valid. Otherwise, the 'obstack' field is
163 1.1 christos valid. */
164 1.1 christos unsigned int ada_mangled : 1;
165 1.1 christos
166 1.1 christos /* Which section is this symbol in? This is an index into
167 1.1 christos section_offsets for this objfile. Negative means that the symbol
168 1.1 christos does not get relocated relative to a section. */
169 1.1 christos
170 1.1 christos short section;
171 1.1 christos };
172 1.1 christos
173 1.1 christos extern void symbol_set_demangled_name (struct general_symbol_info *,
174 1.1 christos const char *,
175 1.1 christos struct obstack *);
176 1.1 christos
177 1.1 christos extern const char *symbol_get_demangled_name
178 1.1 christos (const struct general_symbol_info *);
179 1.1 christos
180 1.1 christos extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
181 1.1 christos
182 1.1 christos /* Note that all the following SYMBOL_* macros are used with the
183 1.1 christos SYMBOL argument being either a partial symbol, a minimal symbol or
184 1.1 christos a full symbol. All three types have a ginfo field. In particular
185 1.1 christos the SYMBOL_SET_LANGUAGE, SYMBOL_DEMANGLED_NAME, etc.
186 1.1 christos macros cannot be entirely substituted by
187 1.1 christos functions, unless the callers are changed to pass in the ginfo
188 1.1 christos field only, instead of the SYMBOL parameter. */
189 1.1 christos
190 1.1 christos #define SYMBOL_VALUE(symbol) (symbol)->ginfo.value.ivalue
191 1.1 christos #define SYMBOL_VALUE_ADDRESS(symbol) (symbol)->ginfo.value.address
192 1.1 christos #define SYMBOL_VALUE_BYTES(symbol) (symbol)->ginfo.value.bytes
193 1.1 christos #define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->ginfo.value.common_block
194 1.1 christos #define SYMBOL_BLOCK_VALUE(symbol) (symbol)->ginfo.value.block
195 1.1 christos #define SYMBOL_VALUE_CHAIN(symbol) (symbol)->ginfo.value.chain
196 1.1 christos #define SYMBOL_LANGUAGE(symbol) (symbol)->ginfo.language
197 1.1 christos #define SYMBOL_SECTION(symbol) (symbol)->ginfo.section
198 1.1 christos #define SYMBOL_OBJ_SECTION(objfile, symbol) \
199 1.1 christos (((symbol)->ginfo.section >= 0) \
200 1.1 christos ? (&(((objfile)->sections)[(symbol)->ginfo.section])) \
201 1.1 christos : NULL)
202 1.1 christos
203 1.1 christos /* Initializes the language dependent portion of a symbol
204 1.1 christos depending upon the language for the symbol. */
205 1.1 christos #define SYMBOL_SET_LANGUAGE(symbol,language,obstack) \
206 1.1 christos (symbol_set_language (&(symbol)->ginfo, (language), (obstack)))
207 1.1 christos extern void symbol_set_language (struct general_symbol_info *symbol,
208 1.1 christos enum language language,
209 1.1 christos struct obstack *obstack);
210 1.1 christos
211 1.1 christos /* Set just the linkage name of a symbol; do not try to demangle
212 1.1 christos it. Used for constructs which do not have a mangled name,
213 1.1 christos e.g. struct tags. Unlike SYMBOL_SET_NAMES, linkage_name must
214 1.1 christos be terminated and either already on the objfile's obstack or
215 1.1 christos permanently allocated. */
216 1.1 christos #define SYMBOL_SET_LINKAGE_NAME(symbol,linkage_name) \
217 1.1 christos (symbol)->ginfo.name = (linkage_name)
218 1.1 christos
219 1.1 christos /* Set the linkage and natural names of a symbol, by demangling
220 1.1 christos the linkage name. */
221 1.1 christos #define SYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile) \
222 1.1 christos symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name, objfile)
223 1.1 christos extern void symbol_set_names (struct general_symbol_info *symbol,
224 1.1 christos const char *linkage_name, int len, int copy_name,
225 1.1 christos struct objfile *objfile);
226 1.1 christos
227 1.1 christos /* Now come lots of name accessor macros. Short version as to when to
228 1.1 christos use which: Use SYMBOL_NATURAL_NAME to refer to the name of the
229 1.1 christos symbol in the original source code. Use SYMBOL_LINKAGE_NAME if you
230 1.1 christos want to know what the linker thinks the symbol's name is. Use
231 1.1 christos SYMBOL_PRINT_NAME for output. Use SYMBOL_DEMANGLED_NAME if you
232 1.1 christos specifically need to know whether SYMBOL_NATURAL_NAME and
233 1.1 christos SYMBOL_LINKAGE_NAME are different. */
234 1.1 christos
235 1.1 christos /* Return SYMBOL's "natural" name, i.e. the name that it was called in
236 1.1 christos the original source code. In languages like C++ where symbols may
237 1.1 christos be mangled for ease of manipulation by the linker, this is the
238 1.1 christos demangled name. */
239 1.1 christos
240 1.1 christos #define SYMBOL_NATURAL_NAME(symbol) \
241 1.1 christos (symbol_natural_name (&(symbol)->ginfo))
242 1.1 christos extern const char *symbol_natural_name
243 1.1 christos (const struct general_symbol_info *symbol);
244 1.1 christos
245 1.1 christos /* Return SYMBOL's name from the point of view of the linker. In
246 1.1 christos languages like C++ where symbols may be mangled for ease of
247 1.1 christos manipulation by the linker, this is the mangled name; otherwise,
248 1.1 christos it's the same as SYMBOL_NATURAL_NAME. */
249 1.1 christos
250 1.1 christos #define SYMBOL_LINKAGE_NAME(symbol) (symbol)->ginfo.name
251 1.1 christos
252 1.1 christos /* Return the demangled name for a symbol based on the language for
253 1.1 christos that symbol. If no demangled name exists, return NULL. */
254 1.1 christos #define SYMBOL_DEMANGLED_NAME(symbol) \
255 1.1 christos (symbol_demangled_name (&(symbol)->ginfo))
256 1.1 christos extern const char *symbol_demangled_name
257 1.1 christos (const struct general_symbol_info *symbol);
258 1.1 christos
259 1.1 christos /* Macro that returns a version of the name of a symbol that is
260 1.1 christos suitable for output. In C++ this is the "demangled" form of the
261 1.1 christos name if demangle is on and the "mangled" form of the name if
262 1.1 christos demangle is off. In other languages this is just the symbol name.
263 1.1 christos The result should never be NULL. Don't use this for internal
264 1.1 christos purposes (e.g. storing in a hashtable): it's only suitable for output.
265 1.1 christos
266 1.1 christos N.B. symbol may be anything with a ginfo member,
267 1.1 christos e.g., struct symbol or struct minimal_symbol. */
268 1.1 christos
269 1.1 christos #define SYMBOL_PRINT_NAME(symbol) \
270 1.1 christos (demangle ? SYMBOL_NATURAL_NAME (symbol) : SYMBOL_LINKAGE_NAME (symbol))
271 1.1 christos extern int demangle;
272 1.1 christos
273 1.1 christos /* Macro that returns the name to be used when sorting and searching symbols.
274 1.1 christos In C++, Chill, and Java, we search for the demangled form of a name,
275 1.1 christos and so sort symbols accordingly. In Ada, however, we search by mangled
276 1.1 christos name. If there is no distinct demangled name, then SYMBOL_SEARCH_NAME
277 1.1 christos returns the same value (same pointer) as SYMBOL_LINKAGE_NAME. */
278 1.1 christos #define SYMBOL_SEARCH_NAME(symbol) \
279 1.1 christos (symbol_search_name (&(symbol)->ginfo))
280 1.1 christos extern const char *symbol_search_name (const struct general_symbol_info *);
281 1.1 christos
282 1.1 christos /* Return non-zero if NAME matches the "search" name of SYMBOL.
283 1.1 christos Whitespace and trailing parentheses are ignored.
284 1.1 christos See strcmp_iw for details about its behavior. */
285 1.1 christos #define SYMBOL_MATCHES_SEARCH_NAME(symbol, name) \
286 1.1 christos (strcmp_iw (SYMBOL_SEARCH_NAME (symbol), (name)) == 0)
287 1.1 christos
288 1.1 christos /* Classification types for a minimal symbol. These should be taken as
289 1.1 christos "advisory only", since if gdb can't easily figure out a
290 1.1 christos classification it simply selects mst_unknown. It may also have to
291 1.1 christos guess when it can't figure out which is a better match between two
292 1.1 christos types (mst_data versus mst_bss) for example. Since the minimal
293 1.1 christos symbol info is sometimes derived from the BFD library's view of a
294 1.1 christos file, we need to live with what information bfd supplies. */
295 1.1 christos
296 1.1 christos enum minimal_symbol_type
297 1.1 christos {
298 1.1 christos mst_unknown = 0, /* Unknown type, the default */
299 1.1 christos mst_text, /* Generally executable instructions */
300 1.1 christos mst_text_gnu_ifunc, /* Executable code returning address
301 1.1 christos of executable code */
302 1.1 christos mst_slot_got_plt, /* GOT entries for .plt sections */
303 1.1 christos mst_data, /* Generally initialized data */
304 1.1 christos mst_bss, /* Generally uninitialized data */
305 1.1 christos mst_abs, /* Generally absolute (nonrelocatable) */
306 1.1 christos /* GDB uses mst_solib_trampoline for the start address of a shared
307 1.1 christos library trampoline entry. Breakpoints for shared library functions
308 1.1 christos are put there if the shared library is not yet loaded.
309 1.1 christos After the shared library is loaded, lookup_minimal_symbol will
310 1.1 christos prefer the minimal symbol from the shared library (usually
311 1.1 christos a mst_text symbol) over the mst_solib_trampoline symbol, and the
312 1.1 christos breakpoints will be moved to their true address in the shared
313 1.1 christos library via breakpoint_re_set. */
314 1.1 christos mst_solib_trampoline, /* Shared library trampoline code */
315 1.1 christos /* For the mst_file* types, the names are only guaranteed to be unique
316 1.1 christos within a given .o file. */
317 1.1 christos mst_file_text, /* Static version of mst_text */
318 1.1 christos mst_file_data, /* Static version of mst_data */
319 1.1 christos mst_file_bss /* Static version of mst_bss */
320 1.1 christos };
321 1.1 christos
322 1.1 christos /* Define a simple structure used to hold some very basic information about
323 1.1 christos all defined global symbols (text, data, bss, abs, etc). The only required
324 1.1 christos information is the general_symbol_info.
325 1.1 christos
326 1.1 christos In many cases, even if a file was compiled with no special options for
327 1.1 christos debugging at all, as long as was not stripped it will contain sufficient
328 1.1 christos information to build a useful minimal symbol table using this structure.
329 1.1 christos Even when a file contains enough debugging information to build a full
330 1.1 christos symbol table, these minimal symbols are still useful for quickly mapping
331 1.1 christos between names and addresses, and vice versa. They are also sometimes
332 1.1 christos used to figure out what full symbol table entries need to be read in. */
333 1.1 christos
334 1.1 christos struct minimal_symbol
335 1.1 christos {
336 1.1 christos
337 1.1 christos /* The general symbol info required for all types of symbols.
338 1.1 christos
339 1.1 christos The SYMBOL_VALUE_ADDRESS contains the address that this symbol
340 1.1 christos corresponds to. */
341 1.1 christos
342 1.1 christos struct general_symbol_info ginfo;
343 1.1 christos
344 1.1 christos /* Size of this symbol. end_psymtab in dbxread.c uses this
345 1.1 christos information to calculate the end of the partial symtab based on the
346 1.1 christos address of the last symbol plus the size of the last symbol. */
347 1.1 christos
348 1.1 christos unsigned long size;
349 1.1 christos
350 1.1 christos /* Which source file is this symbol in? Only relevant for mst_file_*. */
351 1.1 christos const char *filename;
352 1.1 christos
353 1.1 christos /* Classification type for this minimal symbol. */
354 1.1 christos
355 1.1 christos ENUM_BITFIELD(minimal_symbol_type) type : 8;
356 1.1 christos
357 1.1 christos /* Non-zero if this symbol was created by gdb.
358 1.1 christos Such symbols do not appear in the output of "info var|fun". */
359 1.1 christos unsigned int created_by_gdb : 1;
360 1.1 christos
361 1.1 christos /* Two flag bits provided for the use of the target. */
362 1.1 christos unsigned int target_flag_1 : 1;
363 1.1 christos unsigned int target_flag_2 : 1;
364 1.1 christos
365 1.1 christos /* Nonzero iff the size of the minimal symbol has been set.
366 1.1 christos Symbol size information can sometimes not be determined, because
367 1.1 christos the object file format may not carry that piece of information. */
368 1.1 christos unsigned int has_size : 1;
369 1.1 christos
370 1.1 christos /* Minimal symbols with the same hash key are kept on a linked
371 1.1 christos list. This is the link. */
372 1.1 christos
373 1.1 christos struct minimal_symbol *hash_next;
374 1.1 christos
375 1.1 christos /* Minimal symbols are stored in two different hash tables. This is
376 1.1 christos the `next' pointer for the demangled hash table. */
377 1.1 christos
378 1.1 christos struct minimal_symbol *demangled_hash_next;
379 1.1 christos };
380 1.1 christos
381 1.1 christos #define MSYMBOL_TARGET_FLAG_1(msymbol) (msymbol)->target_flag_1
382 1.1 christos #define MSYMBOL_TARGET_FLAG_2(msymbol) (msymbol)->target_flag_2
383 1.1 christos #define MSYMBOL_SIZE(msymbol) ((msymbol)->size + 0)
384 1.1 christos #define SET_MSYMBOL_SIZE(msymbol, sz) \
385 1.1 christos do \
386 1.1 christos { \
387 1.1 christos (msymbol)->size = sz; \
388 1.1 christos (msymbol)->has_size = 1; \
389 1.1 christos } while (0)
390 1.1 christos #define MSYMBOL_HAS_SIZE(msymbol) ((msymbol)->has_size + 0)
391 1.1 christos #define MSYMBOL_TYPE(msymbol) (msymbol)->type
392 1.1 christos
393 1.1 christos #include "minsyms.h"
394 1.1 christos
395 1.1 christos
396 1.1 christos
398 1.1 christos /* Represent one symbol name; a variable, constant, function or typedef. */
399 1.1 christos
400 1.1 christos /* Different name domains for symbols. Looking up a symbol specifies a
401 1.1 christos domain and ignores symbol definitions in other name domains. */
402 1.1 christos
403 1.1 christos typedef enum domain_enum_tag
404 1.1 christos {
405 1.1 christos /* UNDEF_DOMAIN is used when a domain has not been discovered or
406 1.1 christos none of the following apply. This usually indicates an error either
407 1.1 christos in the symbol information or in gdb's handling of symbols. */
408 1.1 christos
409 1.1 christos UNDEF_DOMAIN,
410 1.1 christos
411 1.1 christos /* VAR_DOMAIN is the usual domain. In C, this contains variables,
412 1.1 christos function names, typedef names and enum type values. */
413 1.1 christos
414 1.1 christos VAR_DOMAIN,
415 1.1 christos
416 1.1 christos /* STRUCT_DOMAIN is used in C to hold struct, union and enum type names.
417 1.1 christos Thus, if `struct foo' is used in a C program, it produces a symbol named
418 1.1 christos `foo' in the STRUCT_DOMAIN. */
419 1.1 christos
420 1.1 christos STRUCT_DOMAIN,
421 1.1 christos
422 1.1 christos /* MODULE_DOMAIN is used in Fortran to hold module type names. */
423 1.1 christos
424 1.1 christos MODULE_DOMAIN,
425 1.1 christos
426 1.1 christos /* LABEL_DOMAIN may be used for names of labels (for gotos). */
427 1.1 christos
428 1.1 christos LABEL_DOMAIN,
429 1.1 christos
430 1.1 christos /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN.
431 1.1 christos They also always use LOC_COMMON_BLOCK. */
432 1.1 christos COMMON_BLOCK_DOMAIN
433 1.1 christos } domain_enum;
434 1.1 christos
435 1.1 christos extern const char *domain_name (domain_enum);
436 1.1 christos
437 1.1 christos /* Searching domains, used for `search_symbols'. Element numbers are
438 1.1 christos hardcoded in GDB, check all enum uses before changing it. */
439 1.1 christos
440 1.1 christos enum search_domain
441 1.1 christos {
442 1.1 christos /* Everything in VAR_DOMAIN minus FUNCTIONS_DOMAIN and
443 1.1 christos TYPES_DOMAIN. */
444 1.1 christos VARIABLES_DOMAIN = 0,
445 1.1 christos
446 1.1 christos /* All functions -- for some reason not methods, though. */
447 1.1 christos FUNCTIONS_DOMAIN = 1,
448 1.1 christos
449 1.1 christos /* All defined types */
450 1.1 christos TYPES_DOMAIN = 2,
451 1.1 christos
452 1.1 christos /* Any type. */
453 1.1 christos ALL_DOMAIN = 3
454 1.1 christos };
455 1.1 christos
456 1.1 christos extern const char *search_domain_name (enum search_domain);
457 1.1 christos
458 1.1 christos /* An address-class says where to find the value of a symbol. */
459 1.1 christos
460 1.1 christos enum address_class
461 1.1 christos {
462 1.1 christos /* Not used; catches errors. */
463 1.1 christos
464 1.1 christos LOC_UNDEF,
465 1.1 christos
466 1.1 christos /* Value is constant int SYMBOL_VALUE, host byteorder. */
467 1.1 christos
468 1.1 christos LOC_CONST,
469 1.1 christos
470 1.1 christos /* Value is at fixed address SYMBOL_VALUE_ADDRESS. */
471 1.1 christos
472 1.1 christos LOC_STATIC,
473 1.1 christos
474 1.1 christos /* Value is in register. SYMBOL_VALUE is the register number
475 1.1 christos in the original debug format. SYMBOL_REGISTER_OPS holds a
476 1.1 christos function that can be called to transform this into the
477 1.1 christos actual register number this represents in a specific target
478 1.1 christos architecture (gdbarch).
479 1.1 christos
480 1.1 christos For some symbol formats (stabs, for some compilers at least),
481 1.1 christos the compiler generates two symbols, an argument and a register.
482 1.1 christos In some cases we combine them to a single LOC_REGISTER in symbol
483 1.1 christos reading, but currently not for all cases (e.g. it's passed on the
484 1.1 christos stack and then loaded into a register). */
485 1.1 christos
486 1.1 christos LOC_REGISTER,
487 1.1 christos
488 1.1 christos /* It's an argument; the value is at SYMBOL_VALUE offset in arglist. */
489 1.1 christos
490 1.1 christos LOC_ARG,
491 1.1 christos
492 1.1 christos /* Value address is at SYMBOL_VALUE offset in arglist. */
493 1.1 christos
494 1.1 christos LOC_REF_ARG,
495 1.1 christos
496 1.1 christos /* Value is in specified register. Just like LOC_REGISTER except the
497 1.1 christos register holds the address of the argument instead of the argument
498 1.1 christos itself. This is currently used for the passing of structs and unions
499 1.1 christos on sparc and hppa. It is also used for call by reference where the
500 1.1 christos address is in a register, at least by mipsread.c. */
501 1.1 christos
502 1.1 christos LOC_REGPARM_ADDR,
503 1.1 christos
504 1.1 christos /* Value is a local variable at SYMBOL_VALUE offset in stack frame. */
505 1.1 christos
506 1.1 christos LOC_LOCAL,
507 1.1 christos
508 1.1 christos /* Value not used; definition in SYMBOL_TYPE. Symbols in the domain
509 1.1 christos STRUCT_DOMAIN all have this class. */
510 1.1 christos
511 1.1 christos LOC_TYPEDEF,
512 1.1 christos
513 1.1 christos /* Value is address SYMBOL_VALUE_ADDRESS in the code. */
514 1.1 christos
515 1.1 christos LOC_LABEL,
516 1.1 christos
517 1.1 christos /* In a symbol table, value is SYMBOL_BLOCK_VALUE of a `struct block'.
518 1.1 christos In a partial symbol table, SYMBOL_VALUE_ADDRESS is the start address
519 1.1 christos of the block. Function names have this class. */
520 1.1 christos
521 1.1 christos LOC_BLOCK,
522 1.1 christos
523 1.1 christos /* Value is a constant byte-sequence pointed to by SYMBOL_VALUE_BYTES, in
524 1.1 christos target byte order. */
525 1.1 christos
526 1.1 christos LOC_CONST_BYTES,
527 1.1 christos
528 1.1 christos /* Value is at fixed address, but the address of the variable has
529 1.1 christos to be determined from the minimal symbol table whenever the
530 1.1 christos variable is referenced.
531 1.1 christos This happens if debugging information for a global symbol is
532 1.1 christos emitted and the corresponding minimal symbol is defined
533 1.1 christos in another object file or runtime common storage.
534 1.1 christos The linker might even remove the minimal symbol if the global
535 1.1 christos symbol is never referenced, in which case the symbol remains
536 1.1 christos unresolved.
537 1.1 christos
538 1.1 christos GDB would normally find the symbol in the minimal symbol table if it will
539 1.1 christos not find it in the full symbol table. But a reference to an external
540 1.1 christos symbol in a local block shadowing other definition requires full symbol
541 1.1 christos without possibly having its address available for LOC_STATIC. Testcase
542 1.1 christos is provided as `gdb.dwarf2/dw2-unresolved.exp'. */
543 1.1 christos
544 1.1 christos LOC_UNRESOLVED,
545 1.1 christos
546 1.1 christos /* The variable does not actually exist in the program.
547 1.1 christos The value is ignored. */
548 1.1 christos
549 1.1 christos LOC_OPTIMIZED_OUT,
550 1.1 christos
551 1.1 christos /* The variable's address is computed by a set of location
552 1.1 christos functions (see "struct symbol_computed_ops" below). */
553 1.1 christos LOC_COMPUTED,
554 1.1 christos
555 1.1 christos /* The variable uses general_symbol_info->value->common_block field.
556 1.1 christos It also always uses COMMON_BLOCK_DOMAIN. */
557 1.1 christos LOC_COMMON_BLOCK,
558 1.1 christos
559 1.1 christos /* Not used, just notes the boundary of the enum. */
560 1.1 christos LOC_FINAL_VALUE
561 1.1 christos };
562 1.1 christos
563 1.1 christos /* The methods needed to implement LOC_COMPUTED. These methods can
564 1.1 christos use the symbol's .aux_value for additional per-symbol information.
565 1.1 christos
566 1.1 christos At present this is only used to implement location expressions. */
567 1.1 christos
568 1.1 christos struct symbol_computed_ops
569 1.1 christos {
570 1.1 christos
571 1.1 christos /* Return the value of the variable SYMBOL, relative to the stack
572 1.1 christos frame FRAME. If the variable has been optimized out, return
573 1.1 christos zero.
574 1.1 christos
575 1.1 christos Iff `read_needs_frame (SYMBOL)' is zero, then FRAME may be zero. */
576 1.1 christos
577 1.1 christos struct value *(*read_variable) (struct symbol * symbol,
578 1.1 christos struct frame_info * frame);
579 1.1 christos
580 1.1 christos /* Read variable SYMBOL like read_variable at (callee) FRAME's function
581 1.1 christos entry. SYMBOL should be a function parameter, otherwise
582 1.1 christos NO_ENTRY_VALUE_ERROR will be thrown. */
583 1.1 christos struct value *(*read_variable_at_entry) (struct symbol *symbol,
584 1.1 christos struct frame_info *frame);
585 1.1 christos
586 1.1 christos /* Return non-zero if we need a frame to find the value of the SYMBOL. */
587 1.1 christos int (*read_needs_frame) (struct symbol * symbol);
588 1.1 christos
589 1.1 christos /* Write to STREAM a natural-language description of the location of
590 1.1 christos SYMBOL, in the context of ADDR. */
591 1.1 christos void (*describe_location) (struct symbol * symbol, CORE_ADDR addr,
592 1.1 christos struct ui_file * stream);
593 1.1 christos
594 1.1 christos /* Non-zero if this symbol's address computation is dependent on PC. */
595 1.1 christos unsigned char location_has_loclist;
596 1.1 christos
597 1.1 christos /* Tracepoint support. Append bytecodes to the tracepoint agent
598 1.1 christos expression AX that push the address of the object SYMBOL. Set
599 1.1 christos VALUE appropriately. Note --- for objects in registers, this
600 1.1 christos needn't emit any code; as long as it sets VALUE properly, then
601 1.1 christos the caller will generate the right code in the process of
602 1.1 christos treating this as an lvalue or rvalue. */
603 1.1 christos
604 1.1 christos void (*tracepoint_var_ref) (struct symbol *symbol, struct gdbarch *gdbarch,
605 1.1 christos struct agent_expr *ax, struct axs_value *value);
606 1.1 christos };
607 1.1 christos
608 1.1 christos /* The methods needed to implement LOC_BLOCK for inferior functions.
609 1.1 christos These methods can use the symbol's .aux_value for additional
610 1.1 christos per-symbol information. */
611 1.1 christos
612 1.1 christos struct symbol_block_ops
613 1.1 christos {
614 1.1 christos /* Fill in *START and *LENGTH with DWARF block data of function
615 1.1 christos FRAMEFUNC valid for inferior context address PC. Set *LENGTH to
616 1.1 christos zero if such location is not valid for PC; *START is left
617 1.1 christos uninitialized in such case. */
618 1.1 christos void (*find_frame_base_location) (struct symbol *framefunc, CORE_ADDR pc,
619 1.1 christos const gdb_byte **start, size_t *length);
620 1.1 christos };
621 1.1 christos
622 1.1 christos /* Functions used with LOC_REGISTER and LOC_REGPARM_ADDR. */
623 1.1 christos
624 1.1 christos struct symbol_register_ops
625 1.1 christos {
626 1.1 christos int (*register_number) (struct symbol *symbol, struct gdbarch *gdbarch);
627 1.1 christos };
628 1.1 christos
629 1.1 christos /* Objects of this type are used to find the address class and the
630 1.1 christos various computed ops vectors of a symbol. */
631 1.1 christos
632 1.1 christos struct symbol_impl
633 1.1 christos {
634 1.1 christos enum address_class aclass;
635 1.1 christos
636 1.1 christos /* Used with LOC_COMPUTED. */
637 1.1 christos const struct symbol_computed_ops *ops_computed;
638 1.1 christos
639 1.1 christos /* Used with LOC_BLOCK. */
640 1.1 christos const struct symbol_block_ops *ops_block;
641 1.1 christos
642 1.1 christos /* Used with LOC_REGISTER and LOC_REGPARM_ADDR. */
643 1.1 christos const struct symbol_register_ops *ops_register;
644 1.1 christos };
645 1.1 christos
646 1.1 christos /* The number of bits we reserve in a symbol for the aclass index.
647 1.1 christos This is a #define so that we can have a assertion elsewhere to
648 1.1 christos verify that we have reserved enough space for synthetic address
649 1.1 christos classes. */
650 1.1 christos
651 1.1 christos #define SYMBOL_ACLASS_BITS 6
652 1.1 christos
653 1.1 christos /* This structure is space critical. See space comments at the top. */
654 1.1 christos
655 1.1 christos struct symbol
656 1.1 christos {
657 1.1 christos
658 1.1 christos /* The general symbol info required for all types of symbols. */
659 1.1 christos
660 1.1 christos struct general_symbol_info ginfo;
661 1.1 christos
662 1.1 christos /* Data type of value */
663 1.1 christos
664 1.1 christos struct type *type;
665 1.1 christos
666 1.1 christos /* The symbol table containing this symbol. This is the file
667 1.1 christos associated with LINE. It can be NULL during symbols read-in but it is
668 1.1 christos never NULL during normal operation. */
669 1.1 christos struct symtab *symtab;
670 1.1 christos
671 1.1 christos /* Domain code. */
672 1.1 christos
673 1.1 christos ENUM_BITFIELD(domain_enum_tag) domain : 6;
674 1.1 christos
675 1.1 christos /* Address class. This holds an index into the 'symbol_impls'
676 1.1 christos table. The actual enum address_class value is stored there,
677 1.1 christos alongside any per-class ops vectors. */
678 1.1 christos
679 1.1 christos unsigned int aclass_index : SYMBOL_ACLASS_BITS;
680 1.1 christos
681 1.1 christos /* Whether this is an argument. */
682 1.1 christos
683 1.1 christos unsigned is_argument : 1;
684 1.1 christos
685 1.1 christos /* Whether this is an inlined function (class LOC_BLOCK only). */
686 1.1 christos unsigned is_inlined : 1;
687 1.1 christos
688 1.1 christos /* True if this is a C++ function symbol with template arguments.
689 1.1 christos In this case the symbol is really a "struct template_symbol". */
690 1.1 christos unsigned is_cplus_template_function : 1;
691 1.1 christos
692 1.1 christos /* Line number of this symbol's definition, except for inlined
693 1.1 christos functions. For an inlined function (class LOC_BLOCK and
694 1.1 christos SYMBOL_INLINED set) this is the line number of the function's call
695 1.1 christos site. Inlined function symbols are not definitions, and they are
696 1.1 christos never found by symbol table lookup.
697 1.1 christos
698 1.1 christos FIXME: Should we really make the assumption that nobody will try
699 1.1 christos to debug files longer than 64K lines? What about machine
700 1.1 christos generated programs? */
701 1.1 christos
702 1.1 christos unsigned short line;
703 1.1 christos
704 1.1 christos /* An arbitrary data pointer, allowing symbol readers to record
705 1.1 christos additional information on a per-symbol basis. Note that this data
706 1.1 christos must be allocated using the same obstack as the symbol itself. */
707 1.1 christos /* So far it is only used by LOC_COMPUTED to
708 1.1 christos find the location information. For a LOC_BLOCK symbol
709 1.1 christos for a function in a compilation unit compiled with DWARF 2
710 1.1 christos information, this is information used internally by the DWARF 2
711 1.1 christos code --- specifically, the location expression for the frame
712 1.1 christos base for this function. */
713 1.1 christos /* FIXME drow/2003-02-21: For the LOC_BLOCK case, it might be better
714 1.1 christos to add a magic symbol to the block containing this information,
715 1.1 christos or to have a generic debug info annotation slot for symbols. */
716 1.1 christos
717 1.1 christos void *aux_value;
718 1.1 christos
719 1.1 christos struct symbol *hash_next;
720 1.1 christos };
721 1.1 christos
722 1.1 christos extern const struct symbol_impl *symbol_impls;
723 1.1 christos
724 1.1 christos #define SYMBOL_DOMAIN(symbol) (symbol)->domain
725 1.1 christos #define SYMBOL_IMPL(symbol) (symbol_impls[(symbol)->aclass_index])
726 1.1 christos #define SYMBOL_ACLASS_INDEX(symbol) (symbol)->aclass_index
727 1.1 christos #define SYMBOL_CLASS(symbol) (SYMBOL_IMPL (symbol).aclass)
728 1.1 christos #define SYMBOL_IS_ARGUMENT(symbol) (symbol)->is_argument
729 1.1 christos #define SYMBOL_INLINED(symbol) (symbol)->is_inlined
730 1.1 christos #define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \
731 1.1 christos (symbol)->is_cplus_template_function
732 1.1 christos #define SYMBOL_TYPE(symbol) (symbol)->type
733 1.1 christos #define SYMBOL_LINE(symbol) (symbol)->line
734 1.1 christos #define SYMBOL_SYMTAB(symbol) (symbol)->symtab
735 1.1 christos #define SYMBOL_COMPUTED_OPS(symbol) (SYMBOL_IMPL (symbol).ops_computed)
736 1.1 christos #define SYMBOL_BLOCK_OPS(symbol) (SYMBOL_IMPL (symbol).ops_block)
737 1.1 christos #define SYMBOL_REGISTER_OPS(symbol) (SYMBOL_IMPL (symbol).ops_register)
738 1.1 christos #define SYMBOL_LOCATION_BATON(symbol) (symbol)->aux_value
739 1.1 christos #define SYMBOL_OBJFILE(symbol) (SYMBOL_SYMTAB (symbol)->objfile)
740 1.1 christos
741 1.1 christos extern int register_symbol_computed_impl (enum address_class,
742 1.1 christos const struct symbol_computed_ops *);
743 1.1 christos
744 1.1 christos extern int register_symbol_block_impl (enum address_class aclass,
745 1.1 christos const struct symbol_block_ops *ops);
746 1.1 christos
747 1.1 christos extern int register_symbol_register_impl (enum address_class,
748 1.1 christos const struct symbol_register_ops *);
749 1.1 christos
750 1.1 christos /* An instance of this type is used to represent a C++ template
751 1.1 christos function. It includes a "struct symbol" as a kind of base class;
752 1.1 christos users downcast to "struct template_symbol *" when needed. A symbol
753 1.1 christos is really of this type iff SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION is
754 1.1 christos true. */
755 1.1 christos
756 1.1 christos struct template_symbol
757 1.1 christos {
758 1.1 christos /* The base class. */
759 1.1 christos struct symbol base;
760 1.1 christos
761 1.1 christos /* The number of template arguments. */
762 1.1 christos int n_template_arguments;
763 1.1 christos
764 1.1 christos /* The template arguments. This is an array with
765 1.1 christos N_TEMPLATE_ARGUMENTS elements. */
766 1.1 christos struct symbol **template_arguments;
767 1.1 christos };
768 1.1 christos
769 1.1 christos
770 1.1 christos /* Each item represents a line-->pc (or the reverse) mapping. This is
772 1.1 christos somewhat more wasteful of space than one might wish, but since only
773 1.1 christos the files which are actually debugged are read in to core, we don't
774 1.1 christos waste much space. */
775 1.1 christos
776 1.1 christos struct linetable_entry
777 1.1 christos {
778 1.1 christos int line;
779 1.1 christos CORE_ADDR pc;
780 1.1 christos };
781 1.1 christos
782 1.1 christos /* The order of entries in the linetable is significant. They should
783 1.1 christos be sorted by increasing values of the pc field. If there is more than
784 1.1 christos one entry for a given pc, then I'm not sure what should happen (and
785 1.1 christos I not sure whether we currently handle it the best way).
786 1.1 christos
787 1.1 christos Example: a C for statement generally looks like this
788 1.1 christos
789 1.1 christos 10 0x100 - for the init/test part of a for stmt.
790 1.1 christos 20 0x200
791 1.1 christos 30 0x300
792 1.1 christos 10 0x400 - for the increment part of a for stmt.
793 1.1 christos
794 1.1 christos If an entry has a line number of zero, it marks the start of a PC
795 1.1 christos range for which no line number information is available. It is
796 1.1 christos acceptable, though wasteful of table space, for such a range to be
797 1.1 christos zero length. */
798 1.1 christos
799 1.1 christos struct linetable
800 1.1 christos {
801 1.1 christos int nitems;
802 1.1 christos
803 1.1 christos /* Actually NITEMS elements. If you don't like this use of the
804 1.1 christos `struct hack', you can shove it up your ANSI (seriously, if the
805 1.1 christos committee tells us how to do it, we can probably go along). */
806 1.1 christos struct linetable_entry item[1];
807 1.1 christos };
808 1.1 christos
809 1.1 christos /* How to relocate the symbols from each section in a symbol file.
810 1.1 christos Each struct contains an array of offsets.
811 1.1 christos The ordering and meaning of the offsets is file-type-dependent;
812 1.1 christos typically it is indexed by section numbers or symbol types or
813 1.1 christos something like that.
814 1.1 christos
815 1.1 christos To give us flexibility in changing the internal representation
816 1.1 christos of these offsets, the ANOFFSET macro must be used to insert and
817 1.1 christos extract offset values in the struct. */
818 1.1 christos
819 1.1 christos struct section_offsets
820 1.1 christos {
821 1.1 christos CORE_ADDR offsets[1]; /* As many as needed. */
822 1.1 christos };
823 1.1 christos
824 1.1 christos #define ANOFFSET(secoff, whichone) \
825 1.1 christos ((whichone == -1) \
826 1.1 christos ? (internal_error (__FILE__, __LINE__, \
827 1.1 christos _("Section index is uninitialized")), -1) \
828 1.1 christos : secoff->offsets[whichone])
829 1.1 christos
830 1.1 christos /* The size of a section_offsets table for N sections. */
831 1.1 christos #define SIZEOF_N_SECTION_OFFSETS(n) \
832 1.1 christos (sizeof (struct section_offsets) \
833 1.1 christos + sizeof (((struct section_offsets *) 0)->offsets) * ((n)-1))
834 1.1 christos
835 1.1 christos /* Each source file or header is represented by a struct symtab.
836 1.1 christos These objects are chained through the `next' field. */
837 1.1 christos
838 1.1 christos struct symtab
839 1.1 christos {
840 1.1 christos /* Unordered chain of all existing symtabs of this objfile. */
841 1.1 christos
842 1.1 christos struct symtab *next;
843 1.1 christos
844 1.1 christos /* List of all symbol scope blocks for this symtab. May be shared
845 1.1 christos between different symtabs (and normally is for all the symtabs
846 1.1 christos in a given compilation unit). */
847 1.1 christos
848 1.1 christos struct blockvector *blockvector;
849 1.1 christos
850 1.1 christos /* Table mapping core addresses to line numbers for this file.
851 1.1 christos Can be NULL if none. Never shared between different symtabs. */
852 1.1 christos
853 1.1 christos struct linetable *linetable;
854 1.1 christos
855 1.1 christos /* Section in objfile->section_offsets for the blockvector and
856 1.1 christos the linetable. Probably always SECT_OFF_TEXT. */
857 1.1 christos
858 1.1 christos int block_line_section;
859 1.1 christos
860 1.1 christos /* If several symtabs share a blockvector, exactly one of them
861 1.1 christos should be designated the primary, so that the blockvector
862 1.1 christos is relocated exactly once by objfile_relocate. */
863 1.1 christos
864 1.1 christos unsigned int primary : 1;
865 1.1 christos
866 1.1 christos /* Symtab has been compiled with both optimizations and debug info so that
867 1.1 christos GDB may stop skipping prologues as variables locations are valid already
868 1.1 christos at function entry points. */
869 1.1 christos
870 1.1 christos unsigned int locations_valid : 1;
871 1.1 christos
872 1.1 christos /* DWARF unwinder for this CU is valid even for epilogues (PC at the return
873 1.1 christos instruction). This is supported by GCC since 4.5.0. */
874 1.1 christos
875 1.1 christos unsigned int epilogue_unwind_valid : 1;
876 1.1 christos
877 1.1 christos /* The macro table for this symtab. Like the blockvector, this
878 1.1 christos may be shared between different symtabs --- and normally is for
879 1.1 christos all the symtabs in a given compilation unit. */
880 1.1 christos struct macro_table *macro_table;
881 1.1 christos
882 1.1 christos /* Name of this source file. This pointer is never NULL. */
883 1.1 christos
884 1.1 christos const char *filename;
885 1.1 christos
886 1.1 christos /* Directory in which it was compiled, or NULL if we don't know. */
887 1.1 christos
888 1.1 christos const char *dirname;
889 1.1 christos
890 1.1 christos /* Total number of lines found in source file. */
891 1.1 christos
892 1.1 christos int nlines;
893 1.1 christos
894 1.1 christos /* line_charpos[N] is the position of the (N-1)th line of the
895 1.1 christos source file. "position" means something we can lseek() to; it
896 1.1 christos is not guaranteed to be useful any other way. */
897 1.1 christos
898 1.1 christos int *line_charpos;
899 1.1 christos
900 1.1 christos /* Language of this source file. */
901 1.1 christos
902 1.1 christos enum language language;
903 1.1 christos
904 1.1 christos /* String that identifies the format of the debugging information, such
905 1.1 christos as "stabs", "dwarf 1", "dwarf 2", "coff", etc. This is mostly useful
906 1.1 christos for automated testing of gdb but may also be information that is
907 1.1 christos useful to the user. */
908 1.1 christos
909 1.1 christos const char *debugformat;
910 1.1 christos
911 1.1 christos /* String of producer version information. May be zero. */
912 1.1 christos
913 1.1 christos const char *producer;
914 1.1 christos
915 1.1 christos /* Full name of file as found by searching the source path.
916 1.1 christos NULL if not yet known. */
917 1.1 christos
918 1.1 christos char *fullname;
919 1.1 christos
920 1.1 christos /* Object file from which this symbol information was read. */
921 1.1 christos
922 1.1 christos struct objfile *objfile;
923 1.1 christos
924 1.1 christos /* struct call_site entries for this compilation unit or NULL. */
925 1.1 christos
926 1.1 christos htab_t call_site_htab;
927 1.1 christos
928 1.1 christos /* If non-NULL, then this points to a NULL-terminated vector of
929 1.1 christos included symbol tables. When searching the static or global
930 1.1 christos block of this symbol table, the corresponding block of all
931 1.1 christos included symbol tables will also be searched. Note that this
932 1.1 christos list must be flattened -- the symbol reader is responsible for
933 1.1 christos ensuring that this vector contains the transitive closure of all
934 1.1 christos included symbol tables. */
935 1.1 christos
936 1.1 christos struct symtab **includes;
937 1.1 christos
938 1.1 christos /* If this is an included symbol table, this points to one includer
939 1.1 christos of the table. This user is considered the canonical symbol table
940 1.1 christos containing this one. An included symbol table may itself be
941 1.1 christos included by another. */
942 1.1 christos
943 1.1 christos struct symtab *user;
944 1.1 christos };
945 1.1 christos
946 1.1 christos #define BLOCKVECTOR(symtab) (symtab)->blockvector
947 1.1 christos #define LINETABLE(symtab) (symtab)->linetable
948 1.1 christos #define SYMTAB_PSPACE(symtab) (symtab)->objfile->pspace
949 1.1 christos
950 1.1 christos /* Call this to set the "primary" field in struct symtab. */
951 1.1 christos extern void set_symtab_primary (struct symtab *, int primary);
952 1.1 christos
953 1.1 christos typedef struct symtab *symtab_ptr;
954 1.1 christos DEF_VEC_P (symtab_ptr);
955 1.1 christos
956 1.1 christos
957 1.1 christos
959 1.1 christos /* The virtual function table is now an array of structures which have the
960 1.1 christos form { int16 offset, delta; void *pfn; }.
961 1.1 christos
962 1.1 christos In normal virtual function tables, OFFSET is unused.
963 1.1 christos DELTA is the amount which is added to the apparent object's base
964 1.1 christos address in order to point to the actual object to which the
965 1.1 christos virtual function should be applied.
966 1.1 christos PFN is a pointer to the virtual function.
967 1.1 christos
968 1.1 christos Note that this macro is g++ specific (FIXME). */
969 1.1 christos
970 1.1 christos #define VTBL_FNADDR_OFFSET 2
971 1.1 christos
972 1.1 christos /* External variables and functions for the objects described above. */
973 1.1 christos
974 1.1 christos /* True if we are nested inside psymtab_to_symtab. */
975 1.1 christos
976 1.1 christos extern int currently_reading_symtab;
977 1.1 christos
978 1.1 christos /* symtab.c lookup functions */
979 1.1 christos
980 1.1 christos extern const char multiple_symbols_ask[];
981 1.1 christos extern const char multiple_symbols_all[];
982 1.1 christos extern const char multiple_symbols_cancel[];
983 1.1 christos
984 1.1 christos const char *multiple_symbols_select_mode (void);
985 1.1 christos
986 1.1 christos int symbol_matches_domain (enum language symbol_language,
987 1.1 christos domain_enum symbol_domain,
988 1.1 christos domain_enum domain);
989 1.1 christos
990 1.1 christos /* lookup a symbol table by source file name. */
991 1.1 christos
992 1.1 christos extern struct symtab *lookup_symtab (const char *);
993 1.1 christos
994 1.1 christos /* An object of this type is passed as the 'is_a_field_of_this'
995 1.1 christos argument to lookup_symbol and lookup_symbol_in_language. */
996 1.1 christos
997 1.1 christos struct field_of_this_result
998 1.1 christos {
999 1.1 christos /* The type in which the field was found. If this is NULL then the
1000 1.1 christos symbol was not found in 'this'. If non-NULL, then one of the
1001 1.1 christos other fields will be non-NULL as well. */
1002 1.1 christos
1003 1.1 christos struct type *type;
1004 1.1 christos
1005 1.1 christos /* If the symbol was found as an ordinary field of 'this', then this
1006 1.1 christos is non-NULL and points to the particular field. */
1007 1.1 christos
1008 1.1 christos struct field *field;
1009 1.1 christos
1010 1.1 christos /* If the symbol was found as an function field of 'this', then this
1011 1.1 christos is non-NULL and points to the particular field. */
1012 1.1 christos
1013 1.1 christos struct fn_fieldlist *fn_field;
1014 1.1 christos };
1015 1.1 christos
1016 1.1 christos /* lookup a symbol by name (optional block) in language. */
1017 1.1 christos
1018 1.1 christos extern struct symbol *lookup_symbol_in_language (const char *,
1019 1.1 christos const struct block *,
1020 1.1 christos const domain_enum,
1021 1.1 christos enum language,
1022 1.1 christos struct field_of_this_result *);
1023 1.1 christos
1024 1.1 christos /* lookup a symbol by name (optional block, optional symtab)
1025 1.1 christos in the current language. */
1026 1.1 christos
1027 1.1 christos extern struct symbol *lookup_symbol (const char *, const struct block *,
1028 1.1 christos const domain_enum,
1029 1.1 christos struct field_of_this_result *);
1030 1.1 christos
1031 1.1 christos /* A default version of lookup_symbol_nonlocal for use by languages
1032 1.1 christos that can't think of anything better to do. */
1033 1.1 christos
1034 1.1 christos extern struct symbol *basic_lookup_symbol_nonlocal (const char *,
1035 1.1 christos const struct block *,
1036 1.1 christos const domain_enum);
1037 1.1 christos
1038 1.1 christos /* Some helper functions for languages that need to write their own
1039 1.1 christos lookup_symbol_nonlocal functions. */
1040 1.1 christos
1041 1.1 christos /* Lookup a symbol in the static block associated to BLOCK, if there
1042 1.1 christos is one; do nothing if BLOCK is NULL or a global block. */
1043 1.1 christos
1044 1.1 christos extern struct symbol *lookup_symbol_static (const char *name,
1045 1.1 christos const struct block *block,
1046 1.1 christos const domain_enum domain);
1047 1.1 christos
1048 1.1 christos /* Lookup a symbol in all files' global blocks (searching psymtabs if
1049 1.1 christos necessary). */
1050 1.1 christos
1051 1.1 christos extern struct symbol *lookup_symbol_global (const char *name,
1052 1.1 christos const struct block *block,
1053 1.1 christos const domain_enum domain);
1054 1.1 christos
1055 1.1 christos /* Lookup a symbol within the block BLOCK. This, unlike
1056 1.1 christos lookup_symbol_block, will set SYMTAB and BLOCK_FOUND correctly, and
1057 1.1 christos will fix up the symbol if necessary. */
1058 1.1 christos
1059 1.1 christos extern struct symbol *lookup_symbol_aux_block (const char *name,
1060 1.1 christos const struct block *block,
1061 1.1 christos const domain_enum domain);
1062 1.1 christos
1063 1.1 christos extern struct symbol *lookup_language_this (const struct language_defn *lang,
1064 1.1 christos const struct block *block);
1065 1.1 christos
1066 1.1 christos /* Lookup a symbol only in the file static scope of all the objfiles. */
1067 1.1 christos
1068 1.1 christos struct symbol *lookup_static_symbol_aux (const char *name,
1069 1.1 christos const domain_enum domain);
1070 1.1 christos
1071 1.1 christos
1072 1.1 christos /* lookup a symbol by name, within a specified block. */
1073 1.1 christos
1074 1.1 christos extern struct symbol *lookup_block_symbol (const struct block *, const char *,
1075 1.1 christos const domain_enum);
1076 1.1 christos
1077 1.1 christos /* lookup a [struct, union, enum] by name, within a specified block. */
1078 1.1 christos
1079 1.1 christos extern struct type *lookup_struct (const char *, const struct block *);
1080 1.1 christos
1081 1.1 christos extern struct type *lookup_union (const char *, const struct block *);
1082 1.1 christos
1083 1.1 christos extern struct type *lookup_enum (const char *, const struct block *);
1084 1.1 christos
1085 1.1 christos /* from blockframe.c: */
1086 1.1 christos
1087 1.1 christos /* lookup the function symbol corresponding to the address. */
1088 1.1 christos
1089 1.1 christos extern struct symbol *find_pc_function (CORE_ADDR);
1090 1.1 christos
1091 1.1 christos /* lookup the function corresponding to the address and section. */
1092 1.1 christos
1093 1.1 christos extern struct symbol *find_pc_sect_function (CORE_ADDR, struct obj_section *);
1094 1.1 christos
1095 1.1 christos extern int find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name,
1096 1.1 christos CORE_ADDR *address,
1097 1.1 christos CORE_ADDR *endaddr,
1098 1.1 christos int *is_gnu_ifunc_p);
1099 1.1 christos
1100 1.1 christos /* lookup function from address, return name, start addr and end addr. */
1101 1.1 christos
1102 1.1 christos extern int find_pc_partial_function (CORE_ADDR, const char **, CORE_ADDR *,
1103 1.1 christos CORE_ADDR *);
1104 1.1 christos
1105 1.1 christos extern void clear_pc_function_cache (void);
1106 1.1 christos
1107 1.1 christos /* lookup partial symbol table by address and section. */
1108 1.1 christos
1109 1.1 christos extern struct symtab *find_pc_sect_symtab_via_partial (CORE_ADDR,
1110 1.1 christos struct obj_section *);
1111 1.1 christos
1112 1.1 christos /* lookup full symbol table by address. */
1113 1.1 christos
1114 1.1 christos extern struct symtab *find_pc_symtab (CORE_ADDR);
1115 1.1 christos
1116 1.1 christos /* lookup full symbol table by address and section. */
1117 1.1 christos
1118 1.1 christos extern struct symtab *find_pc_sect_symtab (CORE_ADDR, struct obj_section *);
1119 1.1 christos
1120 1.1 christos extern int find_pc_line_pc_range (CORE_ADDR, CORE_ADDR *, CORE_ADDR *);
1121 1.1 christos
1122 1.1 christos extern void reread_symbols (void);
1123 1.1 christos
1124 1.1 christos extern struct type *lookup_transparent_type (const char *);
1125 1.1 christos extern struct type *basic_lookup_transparent_type (const char *);
1126 1.1 christos
1127 1.1 christos
1128 1.1 christos /* Macro for name of symbol to indicate a file compiled with gcc. */
1129 1.1 christos #ifndef GCC_COMPILED_FLAG_SYMBOL
1130 1.1 christos #define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled."
1131 1.1 christos #endif
1132 1.1 christos
1133 1.1 christos /* Macro for name of symbol to indicate a file compiled with gcc2. */
1134 1.1 christos #ifndef GCC2_COMPILED_FLAG_SYMBOL
1135 1.1 christos #define GCC2_COMPILED_FLAG_SYMBOL "gcc2_compiled."
1136 1.1 christos #endif
1137 1.1 christos
1138 1.1 christos extern int in_gnu_ifunc_stub (CORE_ADDR pc);
1139 1.1 christos
1140 1.1 christos /* Functions for resolving STT_GNU_IFUNC symbols which are implemented only
1141 1.1 christos for ELF symbol files. */
1142 1.1 christos
1143 1.1 christos struct gnu_ifunc_fns
1144 1.1 christos {
1145 1.1 christos /* See elf_gnu_ifunc_resolve_addr for its real implementation. */
1146 1.1 christos CORE_ADDR (*gnu_ifunc_resolve_addr) (struct gdbarch *gdbarch, CORE_ADDR pc);
1147 1.1 christos
1148 1.1 christos /* See elf_gnu_ifunc_resolve_name for its real implementation. */
1149 1.1 christos int (*gnu_ifunc_resolve_name) (const char *function_name,
1150 1.1 christos CORE_ADDR *function_address_p);
1151 1.1 christos
1152 1.1 christos /* See elf_gnu_ifunc_resolver_stop for its real implementation. */
1153 1.1 christos void (*gnu_ifunc_resolver_stop) (struct breakpoint *b);
1154 1.1 christos
1155 1.1 christos /* See elf_gnu_ifunc_resolver_return_stop for its real implementation. */
1156 1.1 christos void (*gnu_ifunc_resolver_return_stop) (struct breakpoint *b);
1157 1.1 christos };
1158 1.1 christos
1159 1.1 christos #define gnu_ifunc_resolve_addr gnu_ifunc_fns_p->gnu_ifunc_resolve_addr
1160 1.1 christos #define gnu_ifunc_resolve_name gnu_ifunc_fns_p->gnu_ifunc_resolve_name
1161 1.1 christos #define gnu_ifunc_resolver_stop gnu_ifunc_fns_p->gnu_ifunc_resolver_stop
1162 1.1 christos #define gnu_ifunc_resolver_return_stop \
1163 1.1 christos gnu_ifunc_fns_p->gnu_ifunc_resolver_return_stop
1164 1.1 christos
1165 1.1 christos extern const struct gnu_ifunc_fns *gnu_ifunc_fns_p;
1166 1.1 christos
1167 1.1 christos extern CORE_ADDR find_solib_trampoline_target (struct frame_info *, CORE_ADDR);
1168 1.1 christos
1169 1.1 christos struct symtab_and_line
1170 1.1 christos {
1171 1.1 christos /* The program space of this sal. */
1172 1.1 christos struct program_space *pspace;
1173 1.1 christos
1174 1.1 christos struct symtab *symtab;
1175 1.1 christos struct obj_section *section;
1176 1.1 christos /* Line number. Line numbers start at 1 and proceed through symtab->nlines.
1177 1.1 christos 0 is never a valid line number; it is used to indicate that line number
1178 1.1 christos information is not available. */
1179 1.1 christos int line;
1180 1.1 christos
1181 1.1 christos CORE_ADDR pc;
1182 1.1 christos CORE_ADDR end;
1183 1.1 christos int explicit_pc;
1184 1.1 christos int explicit_line;
1185 1.1 christos
1186 1.1 christos /* The probe associated with this symtab_and_line. */
1187 1.1 christos struct probe *probe;
1188 1.1 christos };
1189 1.1 christos
1190 1.1 christos extern void init_sal (struct symtab_and_line *sal);
1191 1.1 christos
1192 1.1 christos struct symtabs_and_lines
1193 1.1 christos {
1194 1.1 christos struct symtab_and_line *sals;
1195 1.1 christos int nelts;
1196 1.1 christos };
1197 1.1 christos
1198 1.1 christos
1200 1.1 christos /* Given a pc value, return line number it is in. Second arg nonzero means
1201 1.1 christos if pc is on the boundary use the previous statement's line number. */
1202 1.1 christos
1203 1.1 christos extern struct symtab_and_line find_pc_line (CORE_ADDR, int);
1204 1.1 christos
1205 1.1 christos /* Same function, but specify a section as well as an address. */
1206 1.1 christos
1207 1.1 christos extern struct symtab_and_line find_pc_sect_line (CORE_ADDR,
1208 1.1 christos struct obj_section *, int);
1209 1.1 christos
1210 1.1 christos /* Given a symtab and line number, return the pc there. */
1211 1.1 christos
1212 1.1 christos extern int find_line_pc (struct symtab *, int, CORE_ADDR *);
1213 1.1 christos
1214 1.1 christos extern int find_line_pc_range (struct symtab_and_line, CORE_ADDR *,
1215 1.1 christos CORE_ADDR *);
1216 1.1 christos
1217 1.1 christos extern void resolve_sal_pc (struct symtab_and_line *);
1218 1.1 christos
1219 1.1 christos /* Symbol-reading stuff in symfile.c and solib.c. */
1220 1.1 christos
1221 1.1 christos extern void clear_solib (void);
1222 1.1 christos
1223 1.1 christos /* source.c */
1224 1.1 christos
1225 1.1 christos extern int identify_source_line (struct symtab *, int, int, CORE_ADDR);
1226 1.1 christos
1227 1.1 christos /* Flags passed as 4th argument to print_source_lines. */
1228 1.1 christos
1229 1.1 christos enum print_source_lines_flags
1230 1.1 christos {
1231 1.1 christos /* Do not print an error message. */
1232 1.1 christos PRINT_SOURCE_LINES_NOERROR = (1 << 0),
1233 1.1 christos
1234 1.1 christos /* Print the filename in front of the source lines. */
1235 1.1 christos PRINT_SOURCE_LINES_FILENAME = (1 << 1)
1236 1.1 christos };
1237 1.1 christos
1238 1.1 christos extern void print_source_lines (struct symtab *, int, int,
1239 1.1 christos enum print_source_lines_flags);
1240 1.1 christos
1241 1.1 christos extern void forget_cached_source_info_for_objfile (struct objfile *);
1242 1.1 christos extern void forget_cached_source_info (void);
1243 1.1 christos
1244 1.1 christos extern void select_source_symtab (struct symtab *);
1245 1.1 christos
1246 1.1 christos extern VEC (char_ptr) *default_make_symbol_completion_list_break_on
1247 1.1 christos (const char *text, const char *word, const char *break_on,
1248 1.1 christos enum type_code code);
1249 1.1 christos extern VEC (char_ptr) *default_make_symbol_completion_list (const char *,
1250 1.1 christos const char *,
1251 1.1 christos enum type_code);
1252 1.1 christos extern VEC (char_ptr) *make_symbol_completion_list (const char *, const char *);
1253 1.1 christos extern VEC (char_ptr) *make_symbol_completion_type (const char *, const char *,
1254 1.1 christos enum type_code);
1255 1.1 christos extern VEC (char_ptr) *make_symbol_completion_list_fn (struct cmd_list_element *,
1256 1.1 christos const char *,
1257 1.1 christos const char *);
1258 1.1 christos
1259 1.1 christos extern VEC (char_ptr) *make_file_symbol_completion_list (const char *,
1260 1.1 christos const char *,
1261 1.1 christos const char *);
1262 1.1 christos
1263 1.1 christos extern VEC (char_ptr) *make_source_files_completion_list (const char *,
1264 1.1 christos const char *);
1265 1.1 christos
1266 1.1 christos /* symtab.c */
1267 1.1 christos
1268 1.1 christos int matching_obj_sections (struct obj_section *, struct obj_section *);
1269 1.1 christos
1270 1.1 christos extern struct symtab *find_line_symtab (struct symtab *, int, int *, int *);
1271 1.1 christos
1272 1.1 christos extern struct symtab_and_line find_function_start_sal (struct symbol *sym,
1273 1.1 christos int);
1274 1.1 christos
1275 1.1 christos extern void skip_prologue_sal (struct symtab_and_line *);
1276 1.1 christos
1277 1.1 christos /* symfile.c */
1278 1.1 christos
1279 1.1 christos extern void clear_symtab_users (int add_flags);
1280 1.1 christos
1281 1.1 christos extern enum language deduce_language_from_filename (const char *);
1282 1.1 christos
1283 1.1 christos /* symtab.c */
1284 1.1 christos
1285 1.1 christos extern int in_prologue (struct gdbarch *gdbarch,
1286 1.1 christos CORE_ADDR pc, CORE_ADDR func_start);
1287 1.1 christos
1288 1.1 christos extern CORE_ADDR skip_prologue_using_sal (struct gdbarch *gdbarch,
1289 1.1 christos CORE_ADDR func_addr);
1290 1.1 christos
1291 1.1 christos extern struct symbol *fixup_symbol_section (struct symbol *,
1292 1.1 christos struct objfile *);
1293 1.1 christos
1294 1.1 christos /* Symbol searching */
1295 1.1 christos /* Note: struct symbol_search, search_symbols, et.al. are declared here,
1296 1.1 christos instead of making them local to symtab.c, for gdbtk's sake. */
1297 1.1 christos
1298 1.1 christos /* When using search_symbols, a list of the following structs is returned.
1299 1.1 christos Callers must free the search list using free_search_symbols! */
1300 1.1 christos struct symbol_search
1301 1.1 christos {
1302 1.1 christos /* The block in which the match was found. Could be, for example,
1303 1.1 christos STATIC_BLOCK or GLOBAL_BLOCK. */
1304 1.1 christos int block;
1305 1.1 christos
1306 1.1 christos /* Information describing what was found.
1307 1.1 christos
1308 1.1 christos If symtab and symbol are NOT NULL, then information was found
1309 1.1 christos for this match. */
1310 1.1 christos struct symtab *symtab;
1311 1.1 christos struct symbol *symbol;
1312 1.1 christos
1313 1.1 christos /* If msymbol is non-null, then a match was made on something for
1314 1.1 christos which only minimal_symbols exist. */
1315 1.1 christos struct bound_minimal_symbol msymbol;
1316 1.1 christos
1317 1.1 christos /* A link to the next match, or NULL for the end. */
1318 1.1 christos struct symbol_search *next;
1319 1.1 christos };
1320 1.1 christos
1321 1.1 christos extern void search_symbols (char *, enum search_domain, int, char **,
1322 1.1 christos struct symbol_search **);
1323 1.1 christos extern void free_search_symbols (struct symbol_search *);
1324 1.1 christos extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search
1325 1.1 christos **);
1326 1.1 christos
1327 1.1 christos /* The name of the ``main'' function.
1328 1.1 christos FIXME: cagney/2001-03-20: Can't make main_name() const since some
1329 1.1 christos of the calling code currently assumes that the string isn't
1330 1.1 christos const. */
1331 1.1 christos extern void set_main_name (const char *name);
1332 1.1 christos extern /*const */ char *main_name (void);
1333 1.1 christos extern enum language language_of_main;
1334 1.1 christos
1335 1.1 christos /* Check global symbols in objfile. */
1336 1.1 christos struct symbol *lookup_global_symbol_from_objfile (const struct objfile *,
1337 1.1 christos const char *name,
1338 1.1 christos const domain_enum domain);
1339 1.1 christos
1340 1.1 christos /* Return 1 if the supplied producer string matches the ARM RealView
1341 1.1 christos compiler (armcc). */
1342 1.1 christos int producer_is_realview (const char *producer);
1343 1.1 christos
1344 1.1 christos void fixup_section (struct general_symbol_info *ginfo,
1345 1.1 christos CORE_ADDR addr, struct objfile *objfile);
1346 1.1 christos
1347 1.1 christos struct objfile *lookup_objfile_from_block (const struct block *block);
1348 1.1 christos
1349 1.1 christos extern unsigned int symtab_create_debug;
1350 1.1 christos
1351 1.1 christos extern int basenames_may_differ;
1352 1.1 christos
1353 1.1 christos int compare_filenames_for_search (const char *filename,
1354 1.1 christos const char *search_name);
1355 1.1 christos
1356 1.1 christos int iterate_over_some_symtabs (const char *name,
1357 1.1 christos const char *real_path,
1358 1.1 christos int (*callback) (struct symtab *symtab,
1359 1.1 christos void *data),
1360 1.1 christos void *data,
1361 1.1 christos struct symtab *first,
1362 1.1 christos struct symtab *after_last);
1363 1.1 christos
1364 1.1 christos void iterate_over_symtabs (const char *name,
1365 1.1 christos int (*callback) (struct symtab *symtab,
1366 1.1 christos void *data),
1367 1.1 christos void *data);
1368 1.1 christos
1369 1.1 christos DEF_VEC_I (CORE_ADDR);
1370 1.1 christos
1371 1.1 christos VEC (CORE_ADDR) *find_pcs_for_symtab_line (struct symtab *symtab, int line,
1372 1.1 christos struct linetable_entry **best_entry);
1373 1.1 christos
1374 1.1 christos /* Callback for LA_ITERATE_OVER_SYMBOLS. The callback will be called
1375 1.1 christos once per matching symbol SYM, with DATA being the argument of the
1376 1.1 christos same name that was passed to LA_ITERATE_OVER_SYMBOLS. The callback
1377 1.1 christos should return nonzero to indicate that LA_ITERATE_OVER_SYMBOLS
1378 1.1 christos should continue iterating, or zero to indicate that the iteration
1379 1.1 christos should end. */
1380 1.1 christos
1381 1.1 christos typedef int (symbol_found_callback_ftype) (struct symbol *sym, void *data);
1382 1.1 christos
1383 1.1 christos void iterate_over_symbols (const struct block *block, const char *name,
1384 1.1 christos const domain_enum domain,
1385 1.1 christos symbol_found_callback_ftype *callback,
1386 1.1 christos void *data);
1387 1.1 christos
1388 1.1 christos struct cleanup *demangle_for_lookup (const char *name, enum language lang,
1389 1.1 christos const char **result_name);
1390 1.1 christos
1391 1.1 christos struct symbol *allocate_symbol (struct objfile *);
1392 1.1 christos
1393 1.1 christos void initialize_symbol (struct symbol *);
1394
1395 struct template_symbol *allocate_template_symbol (struct objfile *);
1396
1397 #endif /* !defined(SYMTAB_H) */
1398