15796c8dcSSimon Schubert /* Symbol table definitions for GDB. 25796c8dcSSimon Schubert 3*ef5ccd6cSJohn Marino Copyright (C) 1986-2013 Free Software Foundation, Inc. 45796c8dcSSimon Schubert 55796c8dcSSimon Schubert This file is part of GDB. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 85796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 95796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 105796c8dcSSimon Schubert (at your option) any later version. 115796c8dcSSimon Schubert 125796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 135796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 145796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 155796c8dcSSimon Schubert GNU General Public License for more details. 165796c8dcSSimon Schubert 175796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 185796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 195796c8dcSSimon Schubert 205796c8dcSSimon Schubert #if !defined (SYMTAB_H) 215796c8dcSSimon Schubert #define SYMTAB_H 1 225796c8dcSSimon Schubert 23a45ae5f8SJohn Marino #include "vec.h" 24*ef5ccd6cSJohn Marino #include "gdb_vecs.h" 25*ef5ccd6cSJohn Marino #include "gdbtypes.h" 26a45ae5f8SJohn Marino 275796c8dcSSimon Schubert /* Opaque declarations. */ 285796c8dcSSimon Schubert struct ui_file; 295796c8dcSSimon Schubert struct frame_info; 305796c8dcSSimon Schubert struct symbol; 315796c8dcSSimon Schubert struct obstack; 325796c8dcSSimon Schubert struct objfile; 335796c8dcSSimon Schubert struct block; 345796c8dcSSimon Schubert struct blockvector; 355796c8dcSSimon Schubert struct axs_value; 365796c8dcSSimon Schubert struct agent_expr; 37cf7f2e2dSJohn Marino struct program_space; 38a45ae5f8SJohn Marino struct language_defn; 39*ef5ccd6cSJohn Marino struct probe; 40*ef5ccd6cSJohn Marino struct common_block; 415796c8dcSSimon Schubert 425796c8dcSSimon Schubert /* Some of the structures in this file are space critical. 435796c8dcSSimon Schubert The space-critical structures are: 445796c8dcSSimon Schubert 455796c8dcSSimon Schubert struct general_symbol_info 465796c8dcSSimon Schubert struct symbol 475796c8dcSSimon Schubert struct partial_symbol 485796c8dcSSimon Schubert 495796c8dcSSimon Schubert These structures are laid out to encourage good packing. 505796c8dcSSimon Schubert They use ENUM_BITFIELD and short int fields, and they order the 515796c8dcSSimon Schubert structure members so that fields less than a word are next 525796c8dcSSimon Schubert to each other so they can be packed together. */ 535796c8dcSSimon Schubert 545796c8dcSSimon Schubert /* Rearranged: used ENUM_BITFIELD and rearranged field order in 555796c8dcSSimon Schubert all the space critical structures (plus struct minimal_symbol). 565796c8dcSSimon Schubert Memory usage dropped from 99360768 bytes to 90001408 bytes. 575796c8dcSSimon Schubert I measured this with before-and-after tests of 585796c8dcSSimon Schubert "HEAD-old-gdb -readnow HEAD-old-gdb" and 595796c8dcSSimon Schubert "HEAD-new-gdb -readnow HEAD-old-gdb" on native i686-pc-linux-gnu, 605796c8dcSSimon Schubert red hat linux 8, with LD_LIBRARY_PATH=/usr/lib/debug, 615796c8dcSSimon Schubert typing "maint space 1" at the first command prompt. 625796c8dcSSimon Schubert 635796c8dcSSimon Schubert Here is another measurement (from andrew c): 645796c8dcSSimon Schubert # no /usr/lib/debug, just plain glibc, like a normal user 655796c8dcSSimon Schubert gdb HEAD-old-gdb 665796c8dcSSimon Schubert (gdb) break internal_error 675796c8dcSSimon Schubert (gdb) run 685796c8dcSSimon Schubert (gdb) maint internal-error 695796c8dcSSimon Schubert (gdb) backtrace 705796c8dcSSimon Schubert (gdb) maint space 1 715796c8dcSSimon Schubert 725796c8dcSSimon Schubert gdb gdb_6_0_branch 2003-08-19 space used: 8896512 735796c8dcSSimon Schubert gdb HEAD 2003-08-19 space used: 8904704 745796c8dcSSimon Schubert gdb HEAD 2003-08-21 space used: 8396800 (+symtab.h) 755796c8dcSSimon Schubert gdb HEAD 2003-08-21 space used: 8265728 (+gdbtypes.h) 765796c8dcSSimon Schubert 775796c8dcSSimon Schubert The third line shows the savings from the optimizations in symtab.h. 785796c8dcSSimon Schubert The fourth line shows the savings from the optimizations in 795796c8dcSSimon Schubert gdbtypes.h. Both optimizations are in gdb HEAD now. 805796c8dcSSimon Schubert 815796c8dcSSimon Schubert --chastain 2003-08-21 */ 825796c8dcSSimon Schubert 83c50c785cSJohn Marino /* Struct for storing C++ specific information. Allocated when needed. */ 845796c8dcSSimon Schubert 85c50c785cSJohn Marino struct cplus_specific 86c50c785cSJohn Marino { 87*ef5ccd6cSJohn Marino const char *demangled_name; 88c50c785cSJohn Marino }; 895796c8dcSSimon Schubert 905796c8dcSSimon Schubert /* Define a structure for the information that is common to all symbol types, 915796c8dcSSimon Schubert including minimal symbols, partial symbols, and full symbols. In a 925796c8dcSSimon Schubert multilanguage environment, some language specific information may need to 935796c8dcSSimon Schubert be recorded along with each symbol. */ 945796c8dcSSimon Schubert 955796c8dcSSimon Schubert /* This structure is space critical. See space comments at the top. */ 965796c8dcSSimon Schubert 975796c8dcSSimon Schubert struct general_symbol_info 985796c8dcSSimon Schubert { 995796c8dcSSimon Schubert /* Name of the symbol. This is a required field. Storage for the 1005796c8dcSSimon Schubert name is allocated on the objfile_obstack for the associated 1015796c8dcSSimon Schubert objfile. For languages like C++ that make a distinction between 1025796c8dcSSimon Schubert the mangled name and demangled name, this is the mangled 1035796c8dcSSimon Schubert name. */ 1045796c8dcSSimon Schubert 105*ef5ccd6cSJohn Marino const char *name; 1065796c8dcSSimon Schubert 1075796c8dcSSimon Schubert /* Value of the symbol. Which member of this union to use, and what 1085796c8dcSSimon Schubert it means, depends on what kind of symbol this is and its 1095796c8dcSSimon Schubert SYMBOL_CLASS. See comments there for more details. All of these 1105796c8dcSSimon Schubert are in host byte order (though what they point to might be in 1115796c8dcSSimon Schubert target byte order, e.g. LOC_CONST_BYTES). */ 1125796c8dcSSimon Schubert 1135796c8dcSSimon Schubert union 1145796c8dcSSimon Schubert { 115*ef5ccd6cSJohn Marino LONGEST ivalue; 1165796c8dcSSimon Schubert 1175796c8dcSSimon Schubert struct block *block; 1185796c8dcSSimon Schubert 1195796c8dcSSimon Schubert gdb_byte *bytes; 1205796c8dcSSimon Schubert 1215796c8dcSSimon Schubert CORE_ADDR address; 1225796c8dcSSimon Schubert 123*ef5ccd6cSJohn Marino /* A common block. Used with LOC_COMMON_BLOCK. */ 124*ef5ccd6cSJohn Marino 125*ef5ccd6cSJohn Marino struct common_block *common_block; 126*ef5ccd6cSJohn Marino 127c50c785cSJohn Marino /* For opaque typedef struct chain. */ 1285796c8dcSSimon Schubert 1295796c8dcSSimon Schubert struct symbol *chain; 1305796c8dcSSimon Schubert } 1315796c8dcSSimon Schubert value; 1325796c8dcSSimon Schubert 1335796c8dcSSimon Schubert /* Since one and only one language can apply, wrap the language specific 1345796c8dcSSimon Schubert information inside a union. */ 1355796c8dcSSimon Schubert 1365796c8dcSSimon Schubert union 1375796c8dcSSimon Schubert { 138c50c785cSJohn Marino /* This is used by languages which wish to store a demangled name. 139c50c785cSJohn Marino currently used by Ada, Java, and Objective C. */ 140c50c785cSJohn Marino struct mangled_lang 1415796c8dcSSimon Schubert { 142*ef5ccd6cSJohn Marino const char *demangled_name; 1435796c8dcSSimon Schubert } 144c50c785cSJohn Marino mangled_lang; 145c50c785cSJohn Marino 146c50c785cSJohn Marino struct cplus_specific *cplus_specific; 1475796c8dcSSimon Schubert } 1485796c8dcSSimon Schubert language_specific; 1495796c8dcSSimon Schubert 1505796c8dcSSimon Schubert /* Record the source code language that applies to this symbol. 1515796c8dcSSimon Schubert This is used to select one of the fields from the language specific 1525796c8dcSSimon Schubert union above. */ 1535796c8dcSSimon Schubert 1545796c8dcSSimon Schubert ENUM_BITFIELD(language) language : 8; 1555796c8dcSSimon Schubert 1565796c8dcSSimon Schubert /* Which section is this symbol in? This is an index into 1575796c8dcSSimon Schubert section_offsets for this objfile. Negative means that the symbol 1585796c8dcSSimon Schubert does not get relocated relative to a section. 1595796c8dcSSimon Schubert Disclaimer: currently this is just used for xcoff, so don't 1605796c8dcSSimon Schubert expect all symbol-reading code to set it correctly (the ELF code 1615796c8dcSSimon Schubert also tries to set it correctly). */ 1625796c8dcSSimon Schubert 1635796c8dcSSimon Schubert short section; 1645796c8dcSSimon Schubert 165cf7f2e2dSJohn Marino /* The section associated with this symbol. It can be NULL. */ 1665796c8dcSSimon Schubert 1675796c8dcSSimon Schubert struct obj_section *obj_section; 1685796c8dcSSimon Schubert }; 1695796c8dcSSimon Schubert 170*ef5ccd6cSJohn Marino extern void symbol_set_demangled_name (struct general_symbol_info *, 171*ef5ccd6cSJohn Marino const char *, 172c50c785cSJohn Marino struct objfile *); 173c50c785cSJohn Marino 174*ef5ccd6cSJohn Marino extern const char *symbol_get_demangled_name 175*ef5ccd6cSJohn Marino (const struct general_symbol_info *); 176c50c785cSJohn Marino 1775796c8dcSSimon Schubert extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *); 1785796c8dcSSimon Schubert 1795796c8dcSSimon Schubert /* Note that all the following SYMBOL_* macros are used with the 1805796c8dcSSimon Schubert SYMBOL argument being either a partial symbol, a minimal symbol or 1815796c8dcSSimon Schubert a full symbol. All three types have a ginfo field. In particular 182c50c785cSJohn Marino the SYMBOL_SET_LANGUAGE, SYMBOL_DEMANGLED_NAME, etc. 1835796c8dcSSimon Schubert macros cannot be entirely substituted by 1845796c8dcSSimon Schubert functions, unless the callers are changed to pass in the ginfo 1855796c8dcSSimon Schubert field only, instead of the SYMBOL parameter. */ 1865796c8dcSSimon Schubert 1875796c8dcSSimon Schubert #define SYMBOL_VALUE(symbol) (symbol)->ginfo.value.ivalue 1885796c8dcSSimon Schubert #define SYMBOL_VALUE_ADDRESS(symbol) (symbol)->ginfo.value.address 1895796c8dcSSimon Schubert #define SYMBOL_VALUE_BYTES(symbol) (symbol)->ginfo.value.bytes 190*ef5ccd6cSJohn Marino #define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->ginfo.value.common_block 1915796c8dcSSimon Schubert #define SYMBOL_BLOCK_VALUE(symbol) (symbol)->ginfo.value.block 1925796c8dcSSimon Schubert #define SYMBOL_VALUE_CHAIN(symbol) (symbol)->ginfo.value.chain 1935796c8dcSSimon Schubert #define SYMBOL_LANGUAGE(symbol) (symbol)->ginfo.language 1945796c8dcSSimon Schubert #define SYMBOL_SECTION(symbol) (symbol)->ginfo.section 1955796c8dcSSimon Schubert #define SYMBOL_OBJ_SECTION(symbol) (symbol)->ginfo.obj_section 1965796c8dcSSimon Schubert 1975796c8dcSSimon Schubert /* Initializes the language dependent portion of a symbol 1985796c8dcSSimon Schubert depending upon the language for the symbol. */ 199c50c785cSJohn Marino #define SYMBOL_SET_LANGUAGE(symbol,language) \ 200c50c785cSJohn Marino (symbol_set_language (&(symbol)->ginfo, (language))) 201c50c785cSJohn Marino extern void symbol_set_language (struct general_symbol_info *symbol, 2025796c8dcSSimon Schubert enum language language); 2035796c8dcSSimon Schubert 2045796c8dcSSimon Schubert /* Set just the linkage name of a symbol; do not try to demangle 2055796c8dcSSimon Schubert it. Used for constructs which do not have a mangled name, 2065796c8dcSSimon Schubert e.g. struct tags. Unlike SYMBOL_SET_NAMES, linkage_name must 207cf7f2e2dSJohn Marino be terminated and either already on the objfile's obstack or 208cf7f2e2dSJohn Marino permanently allocated. */ 2095796c8dcSSimon Schubert #define SYMBOL_SET_LINKAGE_NAME(symbol,linkage_name) \ 2105796c8dcSSimon Schubert (symbol)->ginfo.name = (linkage_name) 2115796c8dcSSimon Schubert 2125796c8dcSSimon Schubert /* Set the linkage and natural names of a symbol, by demangling 2135796c8dcSSimon Schubert the linkage name. */ 214cf7f2e2dSJohn Marino #define SYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile) \ 215cf7f2e2dSJohn Marino symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name, objfile) 2165796c8dcSSimon Schubert extern void symbol_set_names (struct general_symbol_info *symbol, 217cf7f2e2dSJohn Marino const char *linkage_name, int len, int copy_name, 2185796c8dcSSimon Schubert struct objfile *objfile); 2195796c8dcSSimon Schubert 2205796c8dcSSimon Schubert /* Now come lots of name accessor macros. Short version as to when to 2215796c8dcSSimon Schubert use which: Use SYMBOL_NATURAL_NAME to refer to the name of the 2225796c8dcSSimon Schubert symbol in the original source code. Use SYMBOL_LINKAGE_NAME if you 2235796c8dcSSimon Schubert want to know what the linker thinks the symbol's name is. Use 2245796c8dcSSimon Schubert SYMBOL_PRINT_NAME for output. Use SYMBOL_DEMANGLED_NAME if you 2255796c8dcSSimon Schubert specifically need to know whether SYMBOL_NATURAL_NAME and 2265796c8dcSSimon Schubert SYMBOL_LINKAGE_NAME are different. */ 2275796c8dcSSimon Schubert 2285796c8dcSSimon Schubert /* Return SYMBOL's "natural" name, i.e. the name that it was called in 2295796c8dcSSimon Schubert the original source code. In languages like C++ where symbols may 2305796c8dcSSimon Schubert be mangled for ease of manipulation by the linker, this is the 2315796c8dcSSimon Schubert demangled name. */ 2325796c8dcSSimon Schubert 2335796c8dcSSimon Schubert #define SYMBOL_NATURAL_NAME(symbol) \ 2345796c8dcSSimon Schubert (symbol_natural_name (&(symbol)->ginfo)) 235*ef5ccd6cSJohn Marino extern const char *symbol_natural_name 236*ef5ccd6cSJohn Marino (const struct general_symbol_info *symbol); 2375796c8dcSSimon Schubert 2385796c8dcSSimon Schubert /* Return SYMBOL's name from the point of view of the linker. In 2395796c8dcSSimon Schubert languages like C++ where symbols may be mangled for ease of 2405796c8dcSSimon Schubert manipulation by the linker, this is the mangled name; otherwise, 2415796c8dcSSimon Schubert it's the same as SYMBOL_NATURAL_NAME. */ 2425796c8dcSSimon Schubert 2435796c8dcSSimon Schubert #define SYMBOL_LINKAGE_NAME(symbol) (symbol)->ginfo.name 2445796c8dcSSimon Schubert 2455796c8dcSSimon Schubert /* Return the demangled name for a symbol based on the language for 2465796c8dcSSimon Schubert that symbol. If no demangled name exists, return NULL. */ 2475796c8dcSSimon Schubert #define SYMBOL_DEMANGLED_NAME(symbol) \ 2485796c8dcSSimon Schubert (symbol_demangled_name (&(symbol)->ginfo)) 249*ef5ccd6cSJohn Marino extern const char *symbol_demangled_name 250*ef5ccd6cSJohn Marino (const struct general_symbol_info *symbol); 2515796c8dcSSimon Schubert 2525796c8dcSSimon Schubert /* Macro that returns a version of the name of a symbol that is 2535796c8dcSSimon Schubert suitable for output. In C++ this is the "demangled" form of the 2545796c8dcSSimon Schubert name if demangle is on and the "mangled" form of the name if 2555796c8dcSSimon Schubert demangle is off. In other languages this is just the symbol name. 2565796c8dcSSimon Schubert The result should never be NULL. Don't use this for internal 257a45ae5f8SJohn Marino purposes (e.g. storing in a hashtable): it's only suitable for output. 258a45ae5f8SJohn Marino 259a45ae5f8SJohn Marino N.B. symbol may be anything with a ginfo member, 260a45ae5f8SJohn Marino e.g., struct symbol or struct minimal_symbol. */ 2615796c8dcSSimon Schubert 2625796c8dcSSimon Schubert #define SYMBOL_PRINT_NAME(symbol) \ 2635796c8dcSSimon Schubert (demangle ? SYMBOL_NATURAL_NAME (symbol) : SYMBOL_LINKAGE_NAME (symbol)) 264a45ae5f8SJohn Marino extern int demangle; 2655796c8dcSSimon Schubert 2665796c8dcSSimon Schubert /* Macro that returns the name to be used when sorting and searching symbols. 2675796c8dcSSimon Schubert In C++, Chill, and Java, we search for the demangled form of a name, 2685796c8dcSSimon Schubert and so sort symbols accordingly. In Ada, however, we search by mangled 2695796c8dcSSimon Schubert name. If there is no distinct demangled name, then SYMBOL_SEARCH_NAME 2705796c8dcSSimon Schubert returns the same value (same pointer) as SYMBOL_LINKAGE_NAME. */ 2715796c8dcSSimon Schubert #define SYMBOL_SEARCH_NAME(symbol) \ 2725796c8dcSSimon Schubert (symbol_search_name (&(symbol)->ginfo)) 273*ef5ccd6cSJohn Marino extern const char *symbol_search_name (const struct general_symbol_info *); 2745796c8dcSSimon Schubert 275*ef5ccd6cSJohn Marino /* Return non-zero if NAME matches the "search" name of SYMBOL. 276*ef5ccd6cSJohn Marino Whitespace and trailing parentheses are ignored. 277*ef5ccd6cSJohn Marino See strcmp_iw for details about its behavior. */ 2785796c8dcSSimon Schubert #define SYMBOL_MATCHES_SEARCH_NAME(symbol, name) \ 2795796c8dcSSimon Schubert (strcmp_iw (SYMBOL_SEARCH_NAME (symbol), (name)) == 0) 2805796c8dcSSimon Schubert 2815796c8dcSSimon Schubert /* Classification types for a minimal symbol. These should be taken as 2825796c8dcSSimon Schubert "advisory only", since if gdb can't easily figure out a 2835796c8dcSSimon Schubert classification it simply selects mst_unknown. It may also have to 2845796c8dcSSimon Schubert guess when it can't figure out which is a better match between two 2855796c8dcSSimon Schubert types (mst_data versus mst_bss) for example. Since the minimal 2865796c8dcSSimon Schubert symbol info is sometimes derived from the BFD library's view of a 2875796c8dcSSimon Schubert file, we need to live with what information bfd supplies. */ 2885796c8dcSSimon Schubert 2895796c8dcSSimon Schubert enum minimal_symbol_type 2905796c8dcSSimon Schubert { 2915796c8dcSSimon Schubert mst_unknown = 0, /* Unknown type, the default */ 2925796c8dcSSimon Schubert mst_text, /* Generally executable instructions */ 293c50c785cSJohn Marino mst_text_gnu_ifunc, /* Executable code returning address 294c50c785cSJohn Marino of executable code */ 295c50c785cSJohn Marino mst_slot_got_plt, /* GOT entries for .plt sections */ 2965796c8dcSSimon Schubert mst_data, /* Generally initialized data */ 2975796c8dcSSimon Schubert mst_bss, /* Generally uninitialized data */ 2985796c8dcSSimon Schubert mst_abs, /* Generally absolute (nonrelocatable) */ 2995796c8dcSSimon Schubert /* GDB uses mst_solib_trampoline for the start address of a shared 3005796c8dcSSimon Schubert library trampoline entry. Breakpoints for shared library functions 3015796c8dcSSimon Schubert are put there if the shared library is not yet loaded. 3025796c8dcSSimon Schubert After the shared library is loaded, lookup_minimal_symbol will 3035796c8dcSSimon Schubert prefer the minimal symbol from the shared library (usually 3045796c8dcSSimon Schubert a mst_text symbol) over the mst_solib_trampoline symbol, and the 3055796c8dcSSimon Schubert breakpoints will be moved to their true address in the shared 3065796c8dcSSimon Schubert library via breakpoint_re_set. */ 3075796c8dcSSimon Schubert mst_solib_trampoline, /* Shared library trampoline code */ 3085796c8dcSSimon Schubert /* For the mst_file* types, the names are only guaranteed to be unique 3095796c8dcSSimon Schubert within a given .o file. */ 3105796c8dcSSimon Schubert mst_file_text, /* Static version of mst_text */ 3115796c8dcSSimon Schubert mst_file_data, /* Static version of mst_data */ 3125796c8dcSSimon Schubert mst_file_bss /* Static version of mst_bss */ 3135796c8dcSSimon Schubert }; 3145796c8dcSSimon Schubert 3155796c8dcSSimon Schubert /* Define a simple structure used to hold some very basic information about 3165796c8dcSSimon Schubert all defined global symbols (text, data, bss, abs, etc). The only required 3175796c8dcSSimon Schubert information is the general_symbol_info. 3185796c8dcSSimon Schubert 3195796c8dcSSimon Schubert In many cases, even if a file was compiled with no special options for 3205796c8dcSSimon Schubert debugging at all, as long as was not stripped it will contain sufficient 3215796c8dcSSimon Schubert information to build a useful minimal symbol table using this structure. 3225796c8dcSSimon Schubert Even when a file contains enough debugging information to build a full 3235796c8dcSSimon Schubert symbol table, these minimal symbols are still useful for quickly mapping 3245796c8dcSSimon Schubert between names and addresses, and vice versa. They are also sometimes 3255796c8dcSSimon Schubert used to figure out what full symbol table entries need to be read in. */ 3265796c8dcSSimon Schubert 3275796c8dcSSimon Schubert struct minimal_symbol 3285796c8dcSSimon Schubert { 3295796c8dcSSimon Schubert 3305796c8dcSSimon Schubert /* The general symbol info required for all types of symbols. 3315796c8dcSSimon Schubert 3325796c8dcSSimon Schubert The SYMBOL_VALUE_ADDRESS contains the address that this symbol 3335796c8dcSSimon Schubert corresponds to. */ 3345796c8dcSSimon Schubert 3355796c8dcSSimon Schubert struct general_symbol_info ginfo; 3365796c8dcSSimon Schubert 3375796c8dcSSimon Schubert /* Size of this symbol. end_psymtab in dbxread.c uses this 3385796c8dcSSimon Schubert information to calculate the end of the partial symtab based on the 3395796c8dcSSimon Schubert address of the last symbol plus the size of the last symbol. */ 3405796c8dcSSimon Schubert 3415796c8dcSSimon Schubert unsigned long size; 3425796c8dcSSimon Schubert 3435796c8dcSSimon Schubert /* Which source file is this symbol in? Only relevant for mst_file_*. */ 344*ef5ccd6cSJohn Marino const char *filename; 3455796c8dcSSimon Schubert 3465796c8dcSSimon Schubert /* Classification type for this minimal symbol. */ 3475796c8dcSSimon Schubert 3485796c8dcSSimon Schubert ENUM_BITFIELD(minimal_symbol_type) type : 8; 3495796c8dcSSimon Schubert 350*ef5ccd6cSJohn Marino /* Non-zero if this symbol was created by gdb. 351*ef5ccd6cSJohn Marino Such symbols do not appear in the output of "info var|fun". */ 352*ef5ccd6cSJohn Marino unsigned int created_by_gdb : 1; 353*ef5ccd6cSJohn Marino 3545796c8dcSSimon Schubert /* Two flag bits provided for the use of the target. */ 3555796c8dcSSimon Schubert unsigned int target_flag_1 : 1; 3565796c8dcSSimon Schubert unsigned int target_flag_2 : 1; 3575796c8dcSSimon Schubert 358*ef5ccd6cSJohn Marino /* Nonzero iff the size of the minimal symbol has been set. 359*ef5ccd6cSJohn Marino Symbol size information can sometimes not be determined, because 360*ef5ccd6cSJohn Marino the object file format may not carry that piece of information. */ 361*ef5ccd6cSJohn Marino unsigned int has_size : 1; 362*ef5ccd6cSJohn Marino 3635796c8dcSSimon Schubert /* Minimal symbols with the same hash key are kept on a linked 3645796c8dcSSimon Schubert list. This is the link. */ 3655796c8dcSSimon Schubert 3665796c8dcSSimon Schubert struct minimal_symbol *hash_next; 3675796c8dcSSimon Schubert 3685796c8dcSSimon Schubert /* Minimal symbols are stored in two different hash tables. This is 3695796c8dcSSimon Schubert the `next' pointer for the demangled hash table. */ 3705796c8dcSSimon Schubert 3715796c8dcSSimon Schubert struct minimal_symbol *demangled_hash_next; 3725796c8dcSSimon Schubert }; 3735796c8dcSSimon Schubert 3745796c8dcSSimon Schubert #define MSYMBOL_TARGET_FLAG_1(msymbol) (msymbol)->target_flag_1 3755796c8dcSSimon Schubert #define MSYMBOL_TARGET_FLAG_2(msymbol) (msymbol)->target_flag_2 376*ef5ccd6cSJohn Marino #define MSYMBOL_SIZE(msymbol) ((msymbol)->size + 0) 377*ef5ccd6cSJohn Marino #define SET_MSYMBOL_SIZE(msymbol, sz) \ 378*ef5ccd6cSJohn Marino do \ 379*ef5ccd6cSJohn Marino { \ 380*ef5ccd6cSJohn Marino (msymbol)->size = sz; \ 381*ef5ccd6cSJohn Marino (msymbol)->has_size = 1; \ 382*ef5ccd6cSJohn Marino } while (0) 383*ef5ccd6cSJohn Marino #define MSYMBOL_HAS_SIZE(msymbol) ((msymbol)->has_size + 0) 3845796c8dcSSimon Schubert #define MSYMBOL_TYPE(msymbol) (msymbol)->type 3855796c8dcSSimon Schubert 386*ef5ccd6cSJohn Marino #include "minsyms.h" 387*ef5ccd6cSJohn Marino 3885796c8dcSSimon Schubert 3895796c8dcSSimon Schubert 3905796c8dcSSimon Schubert /* Represent one symbol name; a variable, constant, function or typedef. */ 3915796c8dcSSimon Schubert 3925796c8dcSSimon Schubert /* Different name domains for symbols. Looking up a symbol specifies a 3935796c8dcSSimon Schubert domain and ignores symbol definitions in other name domains. */ 3945796c8dcSSimon Schubert 3955796c8dcSSimon Schubert typedef enum domain_enum_tag 3965796c8dcSSimon Schubert { 3975796c8dcSSimon Schubert /* UNDEF_DOMAIN is used when a domain has not been discovered or 3985796c8dcSSimon Schubert none of the following apply. This usually indicates an error either 3995796c8dcSSimon Schubert in the symbol information or in gdb's handling of symbols. */ 4005796c8dcSSimon Schubert 4015796c8dcSSimon Schubert UNDEF_DOMAIN, 4025796c8dcSSimon Schubert 4035796c8dcSSimon Schubert /* VAR_DOMAIN is the usual domain. In C, this contains variables, 4045796c8dcSSimon Schubert function names, typedef names and enum type values. */ 4055796c8dcSSimon Schubert 4065796c8dcSSimon Schubert VAR_DOMAIN, 4075796c8dcSSimon Schubert 4085796c8dcSSimon Schubert /* STRUCT_DOMAIN is used in C to hold struct, union and enum type names. 4095796c8dcSSimon Schubert Thus, if `struct foo' is used in a C program, it produces a symbol named 4105796c8dcSSimon Schubert `foo' in the STRUCT_DOMAIN. */ 4115796c8dcSSimon Schubert 4125796c8dcSSimon Schubert STRUCT_DOMAIN, 4135796c8dcSSimon Schubert 414c50c785cSJohn Marino /* LABEL_DOMAIN may be used for names of labels (for gotos). */ 4155796c8dcSSimon Schubert 416*ef5ccd6cSJohn Marino LABEL_DOMAIN, 417*ef5ccd6cSJohn Marino 418*ef5ccd6cSJohn Marino /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. 419*ef5ccd6cSJohn Marino They also always use LOC_COMMON_BLOCK. */ 420*ef5ccd6cSJohn Marino COMMON_BLOCK_DOMAIN 421a45ae5f8SJohn Marino } domain_enum; 4225796c8dcSSimon Schubert 423a45ae5f8SJohn Marino /* Searching domains, used for `search_symbols'. Element numbers are 424a45ae5f8SJohn Marino hardcoded in GDB, check all enum uses before changing it. */ 4255796c8dcSSimon Schubert 426a45ae5f8SJohn Marino enum search_domain 427a45ae5f8SJohn Marino { 4285796c8dcSSimon Schubert /* Everything in VAR_DOMAIN minus FUNCTIONS_DOMAIN and 4295796c8dcSSimon Schubert TYPES_DOMAIN. */ 430a45ae5f8SJohn Marino VARIABLES_DOMAIN = 0, 4315796c8dcSSimon Schubert 4325796c8dcSSimon Schubert /* All functions -- for some reason not methods, though. */ 433a45ae5f8SJohn Marino FUNCTIONS_DOMAIN = 1, 4345796c8dcSSimon Schubert 4355796c8dcSSimon Schubert /* All defined types */ 436a45ae5f8SJohn Marino TYPES_DOMAIN = 2, 437c50c785cSJohn Marino 438c50c785cSJohn Marino /* Any type. */ 439a45ae5f8SJohn Marino ALL_DOMAIN = 3 440a45ae5f8SJohn Marino }; 4415796c8dcSSimon Schubert 4425796c8dcSSimon Schubert /* An address-class says where to find the value of a symbol. */ 4435796c8dcSSimon Schubert 4445796c8dcSSimon Schubert enum address_class 4455796c8dcSSimon Schubert { 446c50c785cSJohn Marino /* Not used; catches errors. */ 4475796c8dcSSimon Schubert 4485796c8dcSSimon Schubert LOC_UNDEF, 4495796c8dcSSimon Schubert 450c50c785cSJohn Marino /* Value is constant int SYMBOL_VALUE, host byteorder. */ 4515796c8dcSSimon Schubert 4525796c8dcSSimon Schubert LOC_CONST, 4535796c8dcSSimon Schubert 454c50c785cSJohn Marino /* Value is at fixed address SYMBOL_VALUE_ADDRESS. */ 4555796c8dcSSimon Schubert 4565796c8dcSSimon Schubert LOC_STATIC, 4575796c8dcSSimon Schubert 4585796c8dcSSimon Schubert /* Value is in register. SYMBOL_VALUE is the register number 4595796c8dcSSimon Schubert in the original debug format. SYMBOL_REGISTER_OPS holds a 4605796c8dcSSimon Schubert function that can be called to transform this into the 4615796c8dcSSimon Schubert actual register number this represents in a specific target 4625796c8dcSSimon Schubert architecture (gdbarch). 4635796c8dcSSimon Schubert 4645796c8dcSSimon Schubert For some symbol formats (stabs, for some compilers at least), 4655796c8dcSSimon Schubert the compiler generates two symbols, an argument and a register. 4665796c8dcSSimon Schubert In some cases we combine them to a single LOC_REGISTER in symbol 4675796c8dcSSimon Schubert reading, but currently not for all cases (e.g. it's passed on the 4685796c8dcSSimon Schubert stack and then loaded into a register). */ 4695796c8dcSSimon Schubert 4705796c8dcSSimon Schubert LOC_REGISTER, 4715796c8dcSSimon Schubert 4725796c8dcSSimon Schubert /* It's an argument; the value is at SYMBOL_VALUE offset in arglist. */ 4735796c8dcSSimon Schubert 4745796c8dcSSimon Schubert LOC_ARG, 4755796c8dcSSimon Schubert 4765796c8dcSSimon Schubert /* Value address is at SYMBOL_VALUE offset in arglist. */ 4775796c8dcSSimon Schubert 4785796c8dcSSimon Schubert LOC_REF_ARG, 4795796c8dcSSimon Schubert 4805796c8dcSSimon Schubert /* Value is in specified register. Just like LOC_REGISTER except the 4815796c8dcSSimon Schubert register holds the address of the argument instead of the argument 4825796c8dcSSimon Schubert itself. This is currently used for the passing of structs and unions 4835796c8dcSSimon Schubert on sparc and hppa. It is also used for call by reference where the 4845796c8dcSSimon Schubert address is in a register, at least by mipsread.c. */ 4855796c8dcSSimon Schubert 4865796c8dcSSimon Schubert LOC_REGPARM_ADDR, 4875796c8dcSSimon Schubert 4885796c8dcSSimon Schubert /* Value is a local variable at SYMBOL_VALUE offset in stack frame. */ 4895796c8dcSSimon Schubert 4905796c8dcSSimon Schubert LOC_LOCAL, 4915796c8dcSSimon Schubert 4925796c8dcSSimon Schubert /* Value not used; definition in SYMBOL_TYPE. Symbols in the domain 4935796c8dcSSimon Schubert STRUCT_DOMAIN all have this class. */ 4945796c8dcSSimon Schubert 4955796c8dcSSimon Schubert LOC_TYPEDEF, 4965796c8dcSSimon Schubert 497c50c785cSJohn Marino /* Value is address SYMBOL_VALUE_ADDRESS in the code. */ 4985796c8dcSSimon Schubert 4995796c8dcSSimon Schubert LOC_LABEL, 5005796c8dcSSimon Schubert 5015796c8dcSSimon Schubert /* In a symbol table, value is SYMBOL_BLOCK_VALUE of a `struct block'. 5025796c8dcSSimon Schubert In a partial symbol table, SYMBOL_VALUE_ADDRESS is the start address 5035796c8dcSSimon Schubert of the block. Function names have this class. */ 5045796c8dcSSimon Schubert 5055796c8dcSSimon Schubert LOC_BLOCK, 5065796c8dcSSimon Schubert 5075796c8dcSSimon Schubert /* Value is a constant byte-sequence pointed to by SYMBOL_VALUE_BYTES, in 5085796c8dcSSimon Schubert target byte order. */ 5095796c8dcSSimon Schubert 5105796c8dcSSimon Schubert LOC_CONST_BYTES, 5115796c8dcSSimon Schubert 5125796c8dcSSimon Schubert /* Value is at fixed address, but the address of the variable has 5135796c8dcSSimon Schubert to be determined from the minimal symbol table whenever the 5145796c8dcSSimon Schubert variable is referenced. 5155796c8dcSSimon Schubert This happens if debugging information for a global symbol is 5165796c8dcSSimon Schubert emitted and the corresponding minimal symbol is defined 5175796c8dcSSimon Schubert in another object file or runtime common storage. 5185796c8dcSSimon Schubert The linker might even remove the minimal symbol if the global 5195796c8dcSSimon Schubert symbol is never referenced, in which case the symbol remains 5205796c8dcSSimon Schubert unresolved. 5215796c8dcSSimon Schubert 5225796c8dcSSimon Schubert GDB would normally find the symbol in the minimal symbol table if it will 5235796c8dcSSimon Schubert not find it in the full symbol table. But a reference to an external 5245796c8dcSSimon Schubert symbol in a local block shadowing other definition requires full symbol 5255796c8dcSSimon Schubert without possibly having its address available for LOC_STATIC. Testcase 5265796c8dcSSimon Schubert is provided as `gdb.dwarf2/dw2-unresolved.exp'. */ 5275796c8dcSSimon Schubert 5285796c8dcSSimon Schubert LOC_UNRESOLVED, 5295796c8dcSSimon Schubert 5305796c8dcSSimon Schubert /* The variable does not actually exist in the program. 5315796c8dcSSimon Schubert The value is ignored. */ 5325796c8dcSSimon Schubert 5335796c8dcSSimon Schubert LOC_OPTIMIZED_OUT, 5345796c8dcSSimon Schubert 5355796c8dcSSimon Schubert /* The variable's address is computed by a set of location 5365796c8dcSSimon Schubert functions (see "struct symbol_computed_ops" below). */ 5375796c8dcSSimon Schubert LOC_COMPUTED, 538*ef5ccd6cSJohn Marino 539*ef5ccd6cSJohn Marino /* The variable uses general_symbol_info->value->common_block field. 540*ef5ccd6cSJohn Marino It also always uses COMMON_BLOCK_DOMAIN. */ 541*ef5ccd6cSJohn Marino LOC_COMMON_BLOCK, 5425796c8dcSSimon Schubert }; 5435796c8dcSSimon Schubert 5445796c8dcSSimon Schubert /* The methods needed to implement LOC_COMPUTED. These methods can 5455796c8dcSSimon Schubert use the symbol's .aux_value for additional per-symbol information. 5465796c8dcSSimon Schubert 5475796c8dcSSimon Schubert At present this is only used to implement location expressions. */ 5485796c8dcSSimon Schubert 5495796c8dcSSimon Schubert struct symbol_computed_ops 5505796c8dcSSimon Schubert { 5515796c8dcSSimon Schubert 5525796c8dcSSimon Schubert /* Return the value of the variable SYMBOL, relative to the stack 5535796c8dcSSimon Schubert frame FRAME. If the variable has been optimized out, return 5545796c8dcSSimon Schubert zero. 5555796c8dcSSimon Schubert 5565796c8dcSSimon Schubert Iff `read_needs_frame (SYMBOL)' is zero, then FRAME may be zero. */ 5575796c8dcSSimon Schubert 5585796c8dcSSimon Schubert struct value *(*read_variable) (struct symbol * symbol, 5595796c8dcSSimon Schubert struct frame_info * frame); 5605796c8dcSSimon Schubert 561a45ae5f8SJohn Marino /* Read variable SYMBOL like read_variable at (callee) FRAME's function 562a45ae5f8SJohn Marino entry. SYMBOL should be a function parameter, otherwise 563a45ae5f8SJohn Marino NO_ENTRY_VALUE_ERROR will be thrown. */ 564a45ae5f8SJohn Marino struct value *(*read_variable_at_entry) (struct symbol *symbol, 565a45ae5f8SJohn Marino struct frame_info *frame); 566a45ae5f8SJohn Marino 5675796c8dcSSimon Schubert /* Return non-zero if we need a frame to find the value of the SYMBOL. */ 5685796c8dcSSimon Schubert int (*read_needs_frame) (struct symbol * symbol); 5695796c8dcSSimon Schubert 5705796c8dcSSimon Schubert /* Write to STREAM a natural-language description of the location of 571cf7f2e2dSJohn Marino SYMBOL, in the context of ADDR. */ 572cf7f2e2dSJohn Marino void (*describe_location) (struct symbol * symbol, CORE_ADDR addr, 573cf7f2e2dSJohn Marino struct ui_file * stream); 5745796c8dcSSimon Schubert 5755796c8dcSSimon Schubert /* Tracepoint support. Append bytecodes to the tracepoint agent 5765796c8dcSSimon Schubert expression AX that push the address of the object SYMBOL. Set 5775796c8dcSSimon Schubert VALUE appropriately. Note --- for objects in registers, this 5785796c8dcSSimon Schubert needn't emit any code; as long as it sets VALUE properly, then 5795796c8dcSSimon Schubert the caller will generate the right code in the process of 5805796c8dcSSimon Schubert treating this as an lvalue or rvalue. */ 5815796c8dcSSimon Schubert 5825796c8dcSSimon Schubert void (*tracepoint_var_ref) (struct symbol *symbol, struct gdbarch *gdbarch, 5835796c8dcSSimon Schubert struct agent_expr *ax, struct axs_value *value); 5845796c8dcSSimon Schubert }; 5855796c8dcSSimon Schubert 5865796c8dcSSimon Schubert /* Functions used with LOC_REGISTER and LOC_REGPARM_ADDR. */ 5875796c8dcSSimon Schubert 5885796c8dcSSimon Schubert struct symbol_register_ops 5895796c8dcSSimon Schubert { 5905796c8dcSSimon Schubert int (*register_number) (struct symbol *symbol, struct gdbarch *gdbarch); 5915796c8dcSSimon Schubert }; 5925796c8dcSSimon Schubert 5935796c8dcSSimon Schubert /* This structure is space critical. See space comments at the top. */ 5945796c8dcSSimon Schubert 5955796c8dcSSimon Schubert struct symbol 5965796c8dcSSimon Schubert { 5975796c8dcSSimon Schubert 5985796c8dcSSimon Schubert /* The general symbol info required for all types of symbols. */ 5995796c8dcSSimon Schubert 6005796c8dcSSimon Schubert struct general_symbol_info ginfo; 6015796c8dcSSimon Schubert 6025796c8dcSSimon Schubert /* Data type of value */ 6035796c8dcSSimon Schubert 6045796c8dcSSimon Schubert struct type *type; 6055796c8dcSSimon Schubert 6065796c8dcSSimon Schubert /* The symbol table containing this symbol. This is the file 607cf7f2e2dSJohn Marino associated with LINE. It can be NULL during symbols read-in but it is 608cf7f2e2dSJohn Marino never NULL during normal operation. */ 6095796c8dcSSimon Schubert struct symtab *symtab; 6105796c8dcSSimon Schubert 6115796c8dcSSimon Schubert /* Domain code. */ 6125796c8dcSSimon Schubert 6135796c8dcSSimon Schubert ENUM_BITFIELD(domain_enum_tag) domain : 6; 6145796c8dcSSimon Schubert 6155796c8dcSSimon Schubert /* Address class */ 6165796c8dcSSimon Schubert /* NOTE: cagney/2003-11-02: The fields "aclass" and "ops" contain 6175796c8dcSSimon Schubert overlapping information. By creating a per-aclass ops vector, or 6185796c8dcSSimon Schubert using the aclass as an index into an ops table, the aclass and 6195796c8dcSSimon Schubert ops fields can be merged. The latter, for instance, would shave 6205796c8dcSSimon Schubert 32-bits from each symbol (relative to a symbol lookup, any table 6215796c8dcSSimon Schubert index overhead would be in the noise). */ 6225796c8dcSSimon Schubert 6235796c8dcSSimon Schubert ENUM_BITFIELD(address_class) aclass : 6; 6245796c8dcSSimon Schubert 6255796c8dcSSimon Schubert /* Whether this is an argument. */ 6265796c8dcSSimon Schubert 6275796c8dcSSimon Schubert unsigned is_argument : 1; 6285796c8dcSSimon Schubert 6295796c8dcSSimon Schubert /* Whether this is an inlined function (class LOC_BLOCK only). */ 6305796c8dcSSimon Schubert unsigned is_inlined : 1; 6315796c8dcSSimon Schubert 632c50c785cSJohn Marino /* True if this is a C++ function symbol with template arguments. 633c50c785cSJohn Marino In this case the symbol is really a "struct template_symbol". */ 634c50c785cSJohn Marino unsigned is_cplus_template_function : 1; 635c50c785cSJohn Marino 6365796c8dcSSimon Schubert /* Line number of this symbol's definition, except for inlined 6375796c8dcSSimon Schubert functions. For an inlined function (class LOC_BLOCK and 6385796c8dcSSimon Schubert SYMBOL_INLINED set) this is the line number of the function's call 6395796c8dcSSimon Schubert site. Inlined function symbols are not definitions, and they are 6405796c8dcSSimon Schubert never found by symbol table lookup. 6415796c8dcSSimon Schubert 6425796c8dcSSimon Schubert FIXME: Should we really make the assumption that nobody will try 6435796c8dcSSimon Schubert to debug files longer than 64K lines? What about machine 6445796c8dcSSimon Schubert generated programs? */ 6455796c8dcSSimon Schubert 6465796c8dcSSimon Schubert unsigned short line; 6475796c8dcSSimon Schubert 6485796c8dcSSimon Schubert /* Method's for symbol's of this class. */ 6495796c8dcSSimon Schubert /* NOTE: cagney/2003-11-02: See comment above attached to "aclass". */ 6505796c8dcSSimon Schubert 6515796c8dcSSimon Schubert union 6525796c8dcSSimon Schubert { 6535796c8dcSSimon Schubert /* Used with LOC_COMPUTED. */ 6545796c8dcSSimon Schubert const struct symbol_computed_ops *ops_computed; 6555796c8dcSSimon Schubert 6565796c8dcSSimon Schubert /* Used with LOC_REGISTER and LOC_REGPARM_ADDR. */ 6575796c8dcSSimon Schubert const struct symbol_register_ops *ops_register; 6585796c8dcSSimon Schubert } ops; 6595796c8dcSSimon Schubert 6605796c8dcSSimon Schubert /* An arbitrary data pointer, allowing symbol readers to record 6615796c8dcSSimon Schubert additional information on a per-symbol basis. Note that this data 6625796c8dcSSimon Schubert must be allocated using the same obstack as the symbol itself. */ 6635796c8dcSSimon Schubert /* So far it is only used by LOC_COMPUTED to 6645796c8dcSSimon Schubert find the location information. For a LOC_BLOCK symbol 6655796c8dcSSimon Schubert for a function in a compilation unit compiled with DWARF 2 6665796c8dcSSimon Schubert information, this is information used internally by the DWARF 2 6675796c8dcSSimon Schubert code --- specifically, the location expression for the frame 6685796c8dcSSimon Schubert base for this function. */ 6695796c8dcSSimon Schubert /* FIXME drow/2003-02-21: For the LOC_BLOCK case, it might be better 6705796c8dcSSimon Schubert to add a magic symbol to the block containing this information, 6715796c8dcSSimon Schubert or to have a generic debug info annotation slot for symbols. */ 6725796c8dcSSimon Schubert 6735796c8dcSSimon Schubert void *aux_value; 6745796c8dcSSimon Schubert 6755796c8dcSSimon Schubert struct symbol *hash_next; 6765796c8dcSSimon Schubert }; 6775796c8dcSSimon Schubert 6785796c8dcSSimon Schubert 6795796c8dcSSimon Schubert #define SYMBOL_DOMAIN(symbol) (symbol)->domain 6805796c8dcSSimon Schubert #define SYMBOL_CLASS(symbol) (symbol)->aclass 6815796c8dcSSimon Schubert #define SYMBOL_IS_ARGUMENT(symbol) (symbol)->is_argument 6825796c8dcSSimon Schubert #define SYMBOL_INLINED(symbol) (symbol)->is_inlined 683c50c785cSJohn Marino #define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \ 684c50c785cSJohn Marino (symbol)->is_cplus_template_function 6855796c8dcSSimon Schubert #define SYMBOL_TYPE(symbol) (symbol)->type 6865796c8dcSSimon Schubert #define SYMBOL_LINE(symbol) (symbol)->line 6875796c8dcSSimon Schubert #define SYMBOL_SYMTAB(symbol) (symbol)->symtab 6885796c8dcSSimon Schubert #define SYMBOL_COMPUTED_OPS(symbol) (symbol)->ops.ops_computed 6895796c8dcSSimon Schubert #define SYMBOL_REGISTER_OPS(symbol) (symbol)->ops.ops_register 6905796c8dcSSimon Schubert #define SYMBOL_LOCATION_BATON(symbol) (symbol)->aux_value 691c50c785cSJohn Marino 692c50c785cSJohn Marino /* An instance of this type is used to represent a C++ template 693c50c785cSJohn Marino function. It includes a "struct symbol" as a kind of base class; 694c50c785cSJohn Marino users downcast to "struct template_symbol *" when needed. A symbol 695c50c785cSJohn Marino is really of this type iff SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION is 696c50c785cSJohn Marino true. */ 697c50c785cSJohn Marino 698c50c785cSJohn Marino struct template_symbol 699c50c785cSJohn Marino { 700c50c785cSJohn Marino /* The base class. */ 701c50c785cSJohn Marino struct symbol base; 702c50c785cSJohn Marino 703c50c785cSJohn Marino /* The number of template arguments. */ 704c50c785cSJohn Marino int n_template_arguments; 705c50c785cSJohn Marino 706c50c785cSJohn Marino /* The template arguments. This is an array with 707c50c785cSJohn Marino N_TEMPLATE_ARGUMENTS elements. */ 708c50c785cSJohn Marino struct symbol **template_arguments; 709c50c785cSJohn Marino }; 710c50c785cSJohn Marino 7115796c8dcSSimon Schubert 7125796c8dcSSimon Schubert /* Each item represents a line-->pc (or the reverse) mapping. This is 7135796c8dcSSimon Schubert somewhat more wasteful of space than one might wish, but since only 7145796c8dcSSimon Schubert the files which are actually debugged are read in to core, we don't 7155796c8dcSSimon Schubert waste much space. */ 7165796c8dcSSimon Schubert 7175796c8dcSSimon Schubert struct linetable_entry 7185796c8dcSSimon Schubert { 7195796c8dcSSimon Schubert int line; 7205796c8dcSSimon Schubert CORE_ADDR pc; 7215796c8dcSSimon Schubert }; 7225796c8dcSSimon Schubert 7235796c8dcSSimon Schubert /* The order of entries in the linetable is significant. They should 7245796c8dcSSimon Schubert be sorted by increasing values of the pc field. If there is more than 7255796c8dcSSimon Schubert one entry for a given pc, then I'm not sure what should happen (and 7265796c8dcSSimon Schubert I not sure whether we currently handle it the best way). 7275796c8dcSSimon Schubert 7285796c8dcSSimon Schubert Example: a C for statement generally looks like this 7295796c8dcSSimon Schubert 7305796c8dcSSimon Schubert 10 0x100 - for the init/test part of a for stmt. 7315796c8dcSSimon Schubert 20 0x200 7325796c8dcSSimon Schubert 30 0x300 7335796c8dcSSimon Schubert 10 0x400 - for the increment part of a for stmt. 7345796c8dcSSimon Schubert 7355796c8dcSSimon Schubert If an entry has a line number of zero, it marks the start of a PC 7365796c8dcSSimon Schubert range for which no line number information is available. It is 7375796c8dcSSimon Schubert acceptable, though wasteful of table space, for such a range to be 7385796c8dcSSimon Schubert zero length. */ 7395796c8dcSSimon Schubert 7405796c8dcSSimon Schubert struct linetable 7415796c8dcSSimon Schubert { 7425796c8dcSSimon Schubert int nitems; 7435796c8dcSSimon Schubert 7445796c8dcSSimon Schubert /* Actually NITEMS elements. If you don't like this use of the 7455796c8dcSSimon Schubert `struct hack', you can shove it up your ANSI (seriously, if the 7465796c8dcSSimon Schubert committee tells us how to do it, we can probably go along). */ 7475796c8dcSSimon Schubert struct linetable_entry item[1]; 7485796c8dcSSimon Schubert }; 7495796c8dcSSimon Schubert 7505796c8dcSSimon Schubert /* How to relocate the symbols from each section in a symbol file. 7515796c8dcSSimon Schubert Each struct contains an array of offsets. 7525796c8dcSSimon Schubert The ordering and meaning of the offsets is file-type-dependent; 7535796c8dcSSimon Schubert typically it is indexed by section numbers or symbol types or 7545796c8dcSSimon Schubert something like that. 7555796c8dcSSimon Schubert 7565796c8dcSSimon Schubert To give us flexibility in changing the internal representation 7575796c8dcSSimon Schubert of these offsets, the ANOFFSET macro must be used to insert and 7585796c8dcSSimon Schubert extract offset values in the struct. */ 7595796c8dcSSimon Schubert 7605796c8dcSSimon Schubert struct section_offsets 7615796c8dcSSimon Schubert { 7625796c8dcSSimon Schubert CORE_ADDR offsets[1]; /* As many as needed. */ 7635796c8dcSSimon Schubert }; 7645796c8dcSSimon Schubert 7655796c8dcSSimon Schubert #define ANOFFSET(secoff, whichone) \ 7665796c8dcSSimon Schubert ((whichone == -1) \ 767c50c785cSJohn Marino ? (internal_error (__FILE__, __LINE__, \ 768c50c785cSJohn Marino _("Section index is uninitialized")), -1) \ 7695796c8dcSSimon Schubert : secoff->offsets[whichone]) 7705796c8dcSSimon Schubert 7715796c8dcSSimon Schubert /* The size of a section_offsets table for N sections. */ 7725796c8dcSSimon Schubert #define SIZEOF_N_SECTION_OFFSETS(n) \ 7735796c8dcSSimon Schubert (sizeof (struct section_offsets) \ 7745796c8dcSSimon Schubert + sizeof (((struct section_offsets *) 0)->offsets) * ((n)-1)) 7755796c8dcSSimon Schubert 7765796c8dcSSimon Schubert /* Each source file or header is represented by a struct symtab. 7775796c8dcSSimon Schubert These objects are chained through the `next' field. */ 7785796c8dcSSimon Schubert 7795796c8dcSSimon Schubert struct symtab 7805796c8dcSSimon Schubert { 781c50c785cSJohn Marino /* Unordered chain of all existing symtabs of this objfile. */ 7825796c8dcSSimon Schubert 7835796c8dcSSimon Schubert struct symtab *next; 7845796c8dcSSimon Schubert 7855796c8dcSSimon Schubert /* List of all symbol scope blocks for this symtab. May be shared 7865796c8dcSSimon Schubert between different symtabs (and normally is for all the symtabs 7875796c8dcSSimon Schubert in a given compilation unit). */ 7885796c8dcSSimon Schubert 7895796c8dcSSimon Schubert struct blockvector *blockvector; 7905796c8dcSSimon Schubert 7915796c8dcSSimon Schubert /* Table mapping core addresses to line numbers for this file. 7925796c8dcSSimon Schubert Can be NULL if none. Never shared between different symtabs. */ 7935796c8dcSSimon Schubert 7945796c8dcSSimon Schubert struct linetable *linetable; 7955796c8dcSSimon Schubert 7965796c8dcSSimon Schubert /* Section in objfile->section_offsets for the blockvector and 7975796c8dcSSimon Schubert the linetable. Probably always SECT_OFF_TEXT. */ 7985796c8dcSSimon Schubert 7995796c8dcSSimon Schubert int block_line_section; 8005796c8dcSSimon Schubert 8015796c8dcSSimon Schubert /* If several symtabs share a blockvector, exactly one of them 8025796c8dcSSimon Schubert should be designated the primary, so that the blockvector 8035796c8dcSSimon Schubert is relocated exactly once by objfile_relocate. */ 8045796c8dcSSimon Schubert 805c50c785cSJohn Marino unsigned int primary : 1; 806c50c785cSJohn Marino 807c50c785cSJohn Marino /* Symtab has been compiled with both optimizations and debug info so that 808c50c785cSJohn Marino GDB may stop skipping prologues as variables locations are valid already 809c50c785cSJohn Marino at function entry points. */ 810c50c785cSJohn Marino 811c50c785cSJohn Marino unsigned int locations_valid : 1; 8125796c8dcSSimon Schubert 813a45ae5f8SJohn Marino /* DWARF unwinder for this CU is valid even for epilogues (PC at the return 814a45ae5f8SJohn Marino instruction). This is supported by GCC since 4.5.0. */ 815a45ae5f8SJohn Marino 816a45ae5f8SJohn Marino unsigned int epilogue_unwind_valid : 1; 817a45ae5f8SJohn Marino 8185796c8dcSSimon Schubert /* The macro table for this symtab. Like the blockvector, this 8195796c8dcSSimon Schubert may be shared between different symtabs --- and normally is for 8205796c8dcSSimon Schubert all the symtabs in a given compilation unit. */ 8215796c8dcSSimon Schubert struct macro_table *macro_table; 8225796c8dcSSimon Schubert 823*ef5ccd6cSJohn Marino /* Name of this source file. This pointer is never NULL. */ 8245796c8dcSSimon Schubert 8255796c8dcSSimon Schubert char *filename; 8265796c8dcSSimon Schubert 8275796c8dcSSimon Schubert /* Directory in which it was compiled, or NULL if we don't know. */ 8285796c8dcSSimon Schubert 8295796c8dcSSimon Schubert char *dirname; 8305796c8dcSSimon Schubert 8315796c8dcSSimon Schubert /* Total number of lines found in source file. */ 8325796c8dcSSimon Schubert 8335796c8dcSSimon Schubert int nlines; 8345796c8dcSSimon Schubert 8355796c8dcSSimon Schubert /* line_charpos[N] is the position of the (N-1)th line of the 8365796c8dcSSimon Schubert source file. "position" means something we can lseek() to; it 8375796c8dcSSimon Schubert is not guaranteed to be useful any other way. */ 8385796c8dcSSimon Schubert 8395796c8dcSSimon Schubert int *line_charpos; 8405796c8dcSSimon Schubert 8415796c8dcSSimon Schubert /* Language of this source file. */ 8425796c8dcSSimon Schubert 8435796c8dcSSimon Schubert enum language language; 8445796c8dcSSimon Schubert 8455796c8dcSSimon Schubert /* String that identifies the format of the debugging information, such 8465796c8dcSSimon Schubert as "stabs", "dwarf 1", "dwarf 2", "coff", etc. This is mostly useful 8475796c8dcSSimon Schubert for automated testing of gdb but may also be information that is 8485796c8dcSSimon Schubert useful to the user. */ 8495796c8dcSSimon Schubert 850a45ae5f8SJohn Marino const char *debugformat; 8515796c8dcSSimon Schubert 8525796c8dcSSimon Schubert /* String of producer version information. May be zero. */ 8535796c8dcSSimon Schubert 854a45ae5f8SJohn Marino const char *producer; 8555796c8dcSSimon Schubert 8565796c8dcSSimon Schubert /* Full name of file as found by searching the source path. 8575796c8dcSSimon Schubert NULL if not yet known. */ 8585796c8dcSSimon Schubert 8595796c8dcSSimon Schubert char *fullname; 8605796c8dcSSimon Schubert 8615796c8dcSSimon Schubert /* Object file from which this symbol information was read. */ 8625796c8dcSSimon Schubert 8635796c8dcSSimon Schubert struct objfile *objfile; 8645796c8dcSSimon Schubert 865a45ae5f8SJohn Marino /* struct call_site entries for this compilation unit or NULL. */ 866a45ae5f8SJohn Marino 867a45ae5f8SJohn Marino htab_t call_site_htab; 868*ef5ccd6cSJohn Marino 869*ef5ccd6cSJohn Marino /* If non-NULL, then this points to a NULL-terminated vector of 870*ef5ccd6cSJohn Marino included symbol tables. When searching the static or global 871*ef5ccd6cSJohn Marino block of this symbol table, the corresponding block of all 872*ef5ccd6cSJohn Marino included symbol tables will also be searched. Note that this 873*ef5ccd6cSJohn Marino list must be flattened -- the symbol reader is responsible for 874*ef5ccd6cSJohn Marino ensuring that this vector contains the transitive closure of all 875*ef5ccd6cSJohn Marino included symbol tables. */ 876*ef5ccd6cSJohn Marino 877*ef5ccd6cSJohn Marino struct symtab **includes; 878*ef5ccd6cSJohn Marino 879*ef5ccd6cSJohn Marino /* If this is an included symbol table, this points to one includer 880*ef5ccd6cSJohn Marino of the table. This user is considered the canonical symbol table 881*ef5ccd6cSJohn Marino containing this one. An included symbol table may itself be 882*ef5ccd6cSJohn Marino included by another. */ 883*ef5ccd6cSJohn Marino 884*ef5ccd6cSJohn Marino struct symtab *user; 8855796c8dcSSimon Schubert }; 8865796c8dcSSimon Schubert 8875796c8dcSSimon Schubert #define BLOCKVECTOR(symtab) (symtab)->blockvector 8885796c8dcSSimon Schubert #define LINETABLE(symtab) (symtab)->linetable 889cf7f2e2dSJohn Marino #define SYMTAB_PSPACE(symtab) (symtab)->objfile->pspace 8905796c8dcSSimon Schubert 8915796c8dcSSimon Schubert 8925796c8dcSSimon Schubert /* The virtual function table is now an array of structures which have the 8935796c8dcSSimon Schubert form { int16 offset, delta; void *pfn; }. 8945796c8dcSSimon Schubert 8955796c8dcSSimon Schubert In normal virtual function tables, OFFSET is unused. 8965796c8dcSSimon Schubert DELTA is the amount which is added to the apparent object's base 8975796c8dcSSimon Schubert address in order to point to the actual object to which the 8985796c8dcSSimon Schubert virtual function should be applied. 8995796c8dcSSimon Schubert PFN is a pointer to the virtual function. 9005796c8dcSSimon Schubert 9015796c8dcSSimon Schubert Note that this macro is g++ specific (FIXME). */ 9025796c8dcSSimon Schubert 9035796c8dcSSimon Schubert #define VTBL_FNADDR_OFFSET 2 9045796c8dcSSimon Schubert 9055796c8dcSSimon Schubert /* External variables and functions for the objects described above. */ 9065796c8dcSSimon Schubert 9075796c8dcSSimon Schubert /* True if we are nested inside psymtab_to_symtab. */ 9085796c8dcSSimon Schubert 9095796c8dcSSimon Schubert extern int currently_reading_symtab; 9105796c8dcSSimon Schubert 9115796c8dcSSimon Schubert /* symtab.c lookup functions */ 9125796c8dcSSimon Schubert 9135796c8dcSSimon Schubert extern const char multiple_symbols_ask[]; 9145796c8dcSSimon Schubert extern const char multiple_symbols_all[]; 9155796c8dcSSimon Schubert extern const char multiple_symbols_cancel[]; 9165796c8dcSSimon Schubert 9175796c8dcSSimon Schubert const char *multiple_symbols_select_mode (void); 9185796c8dcSSimon Schubert 9195796c8dcSSimon Schubert int symbol_matches_domain (enum language symbol_language, 9205796c8dcSSimon Schubert domain_enum symbol_domain, 9215796c8dcSSimon Schubert domain_enum domain); 9225796c8dcSSimon Schubert 923c50c785cSJohn Marino /* lookup a symbol table by source file name. */ 9245796c8dcSSimon Schubert 9255796c8dcSSimon Schubert extern struct symtab *lookup_symtab (const char *); 9265796c8dcSSimon Schubert 927*ef5ccd6cSJohn Marino /* An object of this type is passed as the 'is_a_field_of_this' 928*ef5ccd6cSJohn Marino argument to lookup_symbol and lookup_symbol_in_language. */ 929*ef5ccd6cSJohn Marino 930*ef5ccd6cSJohn Marino struct field_of_this_result 931*ef5ccd6cSJohn Marino { 932*ef5ccd6cSJohn Marino /* The type in which the field was found. If this is NULL then the 933*ef5ccd6cSJohn Marino symbol was not found in 'this'. If non-NULL, then one of the 934*ef5ccd6cSJohn Marino other fields will be non-NULL as well. */ 935*ef5ccd6cSJohn Marino 936*ef5ccd6cSJohn Marino struct type *type; 937*ef5ccd6cSJohn Marino 938*ef5ccd6cSJohn Marino /* If the symbol was found as an ordinary field of 'this', then this 939*ef5ccd6cSJohn Marino is non-NULL and points to the particular field. */ 940*ef5ccd6cSJohn Marino 941*ef5ccd6cSJohn Marino struct field *field; 942*ef5ccd6cSJohn Marino 943*ef5ccd6cSJohn Marino /* If the symbol was found as an function field of 'this', then this 944*ef5ccd6cSJohn Marino is non-NULL and points to the particular field. */ 945*ef5ccd6cSJohn Marino 946*ef5ccd6cSJohn Marino struct fn_fieldlist *fn_field; 947*ef5ccd6cSJohn Marino }; 948*ef5ccd6cSJohn Marino 9495796c8dcSSimon Schubert /* lookup a symbol by name (optional block) in language. */ 9505796c8dcSSimon Schubert 9515796c8dcSSimon Schubert extern struct symbol *lookup_symbol_in_language (const char *, 9525796c8dcSSimon Schubert const struct block *, 9535796c8dcSSimon Schubert const domain_enum, 9545796c8dcSSimon Schubert enum language, 955*ef5ccd6cSJohn Marino struct field_of_this_result *); 9565796c8dcSSimon Schubert 9575796c8dcSSimon Schubert /* lookup a symbol by name (optional block, optional symtab) 958c50c785cSJohn Marino in the current language. */ 9595796c8dcSSimon Schubert 9605796c8dcSSimon Schubert extern struct symbol *lookup_symbol (const char *, const struct block *, 961*ef5ccd6cSJohn Marino const domain_enum, 962*ef5ccd6cSJohn Marino struct field_of_this_result *); 9635796c8dcSSimon Schubert 9645796c8dcSSimon Schubert /* A default version of lookup_symbol_nonlocal for use by languages 9655796c8dcSSimon Schubert that can't think of anything better to do. */ 9665796c8dcSSimon Schubert 9675796c8dcSSimon Schubert extern struct symbol *basic_lookup_symbol_nonlocal (const char *, 9685796c8dcSSimon Schubert const struct block *, 9695796c8dcSSimon Schubert const domain_enum); 9705796c8dcSSimon Schubert 9715796c8dcSSimon Schubert /* Some helper functions for languages that need to write their own 9725796c8dcSSimon Schubert lookup_symbol_nonlocal functions. */ 9735796c8dcSSimon Schubert 9745796c8dcSSimon Schubert /* Lookup a symbol in the static block associated to BLOCK, if there 9755796c8dcSSimon Schubert is one; do nothing if BLOCK is NULL or a global block. */ 9765796c8dcSSimon Schubert 9775796c8dcSSimon Schubert extern struct symbol *lookup_symbol_static (const char *name, 9785796c8dcSSimon Schubert const struct block *block, 9795796c8dcSSimon Schubert const domain_enum domain); 9805796c8dcSSimon Schubert 9815796c8dcSSimon Schubert /* Lookup a symbol in all files' global blocks (searching psymtabs if 9825796c8dcSSimon Schubert necessary). */ 9835796c8dcSSimon Schubert 9845796c8dcSSimon Schubert extern struct symbol *lookup_symbol_global (const char *name, 9855796c8dcSSimon Schubert const struct block *block, 9865796c8dcSSimon Schubert const domain_enum domain); 9875796c8dcSSimon Schubert 9885796c8dcSSimon Schubert /* Lookup a symbol within the block BLOCK. This, unlike 9895796c8dcSSimon Schubert lookup_symbol_block, will set SYMTAB and BLOCK_FOUND correctly, and 9905796c8dcSSimon Schubert will fix up the symbol if necessary. */ 9915796c8dcSSimon Schubert 9925796c8dcSSimon Schubert extern struct symbol *lookup_symbol_aux_block (const char *name, 9935796c8dcSSimon Schubert const struct block *block, 9945796c8dcSSimon Schubert const domain_enum domain); 9955796c8dcSSimon Schubert 996a45ae5f8SJohn Marino extern struct symbol *lookup_language_this (const struct language_defn *lang, 997a45ae5f8SJohn Marino const struct block *block); 998a45ae5f8SJohn Marino 999cf7f2e2dSJohn Marino /* Lookup a symbol only in the file static scope of all the objfiles. */ 10005796c8dcSSimon Schubert 1001cf7f2e2dSJohn Marino struct symbol *lookup_static_symbol_aux (const char *name, 1002cf7f2e2dSJohn Marino const domain_enum domain); 1003cf7f2e2dSJohn Marino 10045796c8dcSSimon Schubert 1005c50c785cSJohn Marino /* lookup a symbol by name, within a specified block. */ 10065796c8dcSSimon Schubert 10075796c8dcSSimon Schubert extern struct symbol *lookup_block_symbol (const struct block *, const char *, 10085796c8dcSSimon Schubert const domain_enum); 10095796c8dcSSimon Schubert 1010c50c785cSJohn Marino /* lookup a [struct, union, enum] by name, within a specified block. */ 10115796c8dcSSimon Schubert 1012*ef5ccd6cSJohn Marino extern struct type *lookup_struct (const char *, const struct block *); 10135796c8dcSSimon Schubert 1014*ef5ccd6cSJohn Marino extern struct type *lookup_union (const char *, const struct block *); 10155796c8dcSSimon Schubert 1016*ef5ccd6cSJohn Marino extern struct type *lookup_enum (const char *, const struct block *); 10175796c8dcSSimon Schubert 10185796c8dcSSimon Schubert /* from blockframe.c: */ 10195796c8dcSSimon Schubert 1020c50c785cSJohn Marino /* lookup the function symbol corresponding to the address. */ 10215796c8dcSSimon Schubert 10225796c8dcSSimon Schubert extern struct symbol *find_pc_function (CORE_ADDR); 10235796c8dcSSimon Schubert 1024c50c785cSJohn Marino /* lookup the function corresponding to the address and section. */ 10255796c8dcSSimon Schubert 10265796c8dcSSimon Schubert extern struct symbol *find_pc_sect_function (CORE_ADDR, struct obj_section *); 10275796c8dcSSimon Schubert 1028*ef5ccd6cSJohn Marino extern int find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name, 1029c50c785cSJohn Marino CORE_ADDR *address, 1030c50c785cSJohn Marino CORE_ADDR *endaddr, 1031c50c785cSJohn Marino int *is_gnu_ifunc_p); 1032c50c785cSJohn Marino 1033c50c785cSJohn Marino /* lookup function from address, return name, start addr and end addr. */ 10345796c8dcSSimon Schubert 1035*ef5ccd6cSJohn Marino extern int find_pc_partial_function (CORE_ADDR, const char **, CORE_ADDR *, 10365796c8dcSSimon Schubert CORE_ADDR *); 10375796c8dcSSimon Schubert 10385796c8dcSSimon Schubert extern void clear_pc_function_cache (void); 10395796c8dcSSimon Schubert 1040c50c785cSJohn Marino /* lookup partial symbol table by address and section. */ 10415796c8dcSSimon Schubert 1042cf7f2e2dSJohn Marino extern struct symtab *find_pc_sect_symtab_via_partial (CORE_ADDR, 10435796c8dcSSimon Schubert struct obj_section *); 10445796c8dcSSimon Schubert 1045c50c785cSJohn Marino /* lookup full symbol table by address. */ 10465796c8dcSSimon Schubert 10475796c8dcSSimon Schubert extern struct symtab *find_pc_symtab (CORE_ADDR); 10485796c8dcSSimon Schubert 1049c50c785cSJohn Marino /* lookup full symbol table by address and section. */ 10505796c8dcSSimon Schubert 10515796c8dcSSimon Schubert extern struct symtab *find_pc_sect_symtab (CORE_ADDR, struct obj_section *); 10525796c8dcSSimon Schubert 10535796c8dcSSimon Schubert extern int find_pc_line_pc_range (CORE_ADDR, CORE_ADDR *, CORE_ADDR *); 10545796c8dcSSimon Schubert 10555796c8dcSSimon Schubert extern void reread_symbols (void); 10565796c8dcSSimon Schubert 10575796c8dcSSimon Schubert extern struct type *lookup_transparent_type (const char *); 10585796c8dcSSimon Schubert extern struct type *basic_lookup_transparent_type (const char *); 10595796c8dcSSimon Schubert 10605796c8dcSSimon Schubert 10615796c8dcSSimon Schubert /* Macro for name of symbol to indicate a file compiled with gcc. */ 10625796c8dcSSimon Schubert #ifndef GCC_COMPILED_FLAG_SYMBOL 10635796c8dcSSimon Schubert #define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled." 10645796c8dcSSimon Schubert #endif 10655796c8dcSSimon Schubert 10665796c8dcSSimon Schubert /* Macro for name of symbol to indicate a file compiled with gcc2. */ 10675796c8dcSSimon Schubert #ifndef GCC2_COMPILED_FLAG_SYMBOL 10685796c8dcSSimon Schubert #define GCC2_COMPILED_FLAG_SYMBOL "gcc2_compiled." 10695796c8dcSSimon Schubert #endif 10705796c8dcSSimon Schubert 1071c50c785cSJohn Marino extern int in_gnu_ifunc_stub (CORE_ADDR pc); 1072c50c785cSJohn Marino 1073c50c785cSJohn Marino /* Functions for resolving STT_GNU_IFUNC symbols which are implemented only 1074c50c785cSJohn Marino for ELF symbol files. */ 1075c50c785cSJohn Marino 1076c50c785cSJohn Marino struct gnu_ifunc_fns 1077c50c785cSJohn Marino { 1078c50c785cSJohn Marino /* See elf_gnu_ifunc_resolve_addr for its real implementation. */ 1079c50c785cSJohn Marino CORE_ADDR (*gnu_ifunc_resolve_addr) (struct gdbarch *gdbarch, CORE_ADDR pc); 1080c50c785cSJohn Marino 1081c50c785cSJohn Marino /* See elf_gnu_ifunc_resolve_name for its real implementation. */ 1082c50c785cSJohn Marino int (*gnu_ifunc_resolve_name) (const char *function_name, 1083c50c785cSJohn Marino CORE_ADDR *function_address_p); 1084c50c785cSJohn Marino 1085c50c785cSJohn Marino /* See elf_gnu_ifunc_resolver_stop for its real implementation. */ 1086c50c785cSJohn Marino void (*gnu_ifunc_resolver_stop) (struct breakpoint *b); 1087c50c785cSJohn Marino 1088c50c785cSJohn Marino /* See elf_gnu_ifunc_resolver_return_stop for its real implementation. */ 1089c50c785cSJohn Marino void (*gnu_ifunc_resolver_return_stop) (struct breakpoint *b); 1090c50c785cSJohn Marino }; 1091c50c785cSJohn Marino 1092c50c785cSJohn Marino #define gnu_ifunc_resolve_addr gnu_ifunc_fns_p->gnu_ifunc_resolve_addr 1093c50c785cSJohn Marino #define gnu_ifunc_resolve_name gnu_ifunc_fns_p->gnu_ifunc_resolve_name 1094c50c785cSJohn Marino #define gnu_ifunc_resolver_stop gnu_ifunc_fns_p->gnu_ifunc_resolver_stop 1095c50c785cSJohn Marino #define gnu_ifunc_resolver_return_stop \ 1096c50c785cSJohn Marino gnu_ifunc_fns_p->gnu_ifunc_resolver_return_stop 1097c50c785cSJohn Marino 1098c50c785cSJohn Marino extern const struct gnu_ifunc_fns *gnu_ifunc_fns_p; 1099c50c785cSJohn Marino 11005796c8dcSSimon Schubert extern CORE_ADDR find_solib_trampoline_target (struct frame_info *, CORE_ADDR); 11015796c8dcSSimon Schubert 11025796c8dcSSimon Schubert struct symtab_and_line 11035796c8dcSSimon Schubert { 1104cf7f2e2dSJohn Marino /* The program space of this sal. */ 1105cf7f2e2dSJohn Marino struct program_space *pspace; 1106cf7f2e2dSJohn Marino 11075796c8dcSSimon Schubert struct symtab *symtab; 11085796c8dcSSimon Schubert struct obj_section *section; 11095796c8dcSSimon Schubert /* Line number. Line numbers start at 1 and proceed through symtab->nlines. 11105796c8dcSSimon Schubert 0 is never a valid line number; it is used to indicate that line number 11115796c8dcSSimon Schubert information is not available. */ 11125796c8dcSSimon Schubert int line; 11135796c8dcSSimon Schubert 11145796c8dcSSimon Schubert CORE_ADDR pc; 11155796c8dcSSimon Schubert CORE_ADDR end; 11165796c8dcSSimon Schubert int explicit_pc; 11175796c8dcSSimon Schubert int explicit_line; 1118*ef5ccd6cSJohn Marino 1119*ef5ccd6cSJohn Marino /* The probe associated with this symtab_and_line. */ 1120*ef5ccd6cSJohn Marino struct probe *probe; 11215796c8dcSSimon Schubert }; 11225796c8dcSSimon Schubert 11235796c8dcSSimon Schubert extern void init_sal (struct symtab_and_line *sal); 11245796c8dcSSimon Schubert 11255796c8dcSSimon Schubert struct symtabs_and_lines 11265796c8dcSSimon Schubert { 11275796c8dcSSimon Schubert struct symtab_and_line *sals; 11285796c8dcSSimon Schubert int nelts; 11295796c8dcSSimon Schubert }; 11305796c8dcSSimon Schubert 11315796c8dcSSimon Schubert 11325796c8dcSSimon Schubert /* Given a pc value, return line number it is in. Second arg nonzero means 11335796c8dcSSimon Schubert if pc is on the boundary use the previous statement's line number. */ 11345796c8dcSSimon Schubert 11355796c8dcSSimon Schubert extern struct symtab_and_line find_pc_line (CORE_ADDR, int); 11365796c8dcSSimon Schubert 1137c50c785cSJohn Marino /* Same function, but specify a section as well as an address. */ 11385796c8dcSSimon Schubert 11395796c8dcSSimon Schubert extern struct symtab_and_line find_pc_sect_line (CORE_ADDR, 11405796c8dcSSimon Schubert struct obj_section *, int); 11415796c8dcSSimon Schubert 11425796c8dcSSimon Schubert /* Given a symtab and line number, return the pc there. */ 11435796c8dcSSimon Schubert 11445796c8dcSSimon Schubert extern int find_line_pc (struct symtab *, int, CORE_ADDR *); 11455796c8dcSSimon Schubert 11465796c8dcSSimon Schubert extern int find_line_pc_range (struct symtab_and_line, CORE_ADDR *, 11475796c8dcSSimon Schubert CORE_ADDR *); 11485796c8dcSSimon Schubert 11495796c8dcSSimon Schubert extern void resolve_sal_pc (struct symtab_and_line *); 11505796c8dcSSimon Schubert 11515796c8dcSSimon Schubert /* Symbol-reading stuff in symfile.c and solib.c. */ 11525796c8dcSSimon Schubert 11535796c8dcSSimon Schubert extern void clear_solib (void); 11545796c8dcSSimon Schubert 11555796c8dcSSimon Schubert /* source.c */ 11565796c8dcSSimon Schubert 11575796c8dcSSimon Schubert extern int identify_source_line (struct symtab *, int, int, CORE_ADDR); 11585796c8dcSSimon Schubert 1159*ef5ccd6cSJohn Marino /* Flags passed as 4th argument to print_source_lines. */ 1160*ef5ccd6cSJohn Marino 1161*ef5ccd6cSJohn Marino enum print_source_lines_flags 1162*ef5ccd6cSJohn Marino { 1163*ef5ccd6cSJohn Marino /* Do not print an error message. */ 1164*ef5ccd6cSJohn Marino PRINT_SOURCE_LINES_NOERROR = (1 << 0), 1165*ef5ccd6cSJohn Marino 1166*ef5ccd6cSJohn Marino /* Print the filename in front of the source lines. */ 1167*ef5ccd6cSJohn Marino PRINT_SOURCE_LINES_FILENAME = (1 << 1) 1168*ef5ccd6cSJohn Marino }; 1169*ef5ccd6cSJohn Marino 1170*ef5ccd6cSJohn Marino extern void print_source_lines (struct symtab *, int, int, 1171*ef5ccd6cSJohn Marino enum print_source_lines_flags); 11725796c8dcSSimon Schubert 1173a45ae5f8SJohn Marino extern void forget_cached_source_info_for_objfile (struct objfile *); 11745796c8dcSSimon Schubert extern void forget_cached_source_info (void); 11755796c8dcSSimon Schubert 11765796c8dcSSimon Schubert extern void select_source_symtab (struct symtab *); 11775796c8dcSSimon Schubert 1178*ef5ccd6cSJohn Marino extern VEC (char_ptr) *default_make_symbol_completion_list_break_on 1179*ef5ccd6cSJohn Marino (char *text, char *word, const char *break_on, 1180*ef5ccd6cSJohn Marino enum type_code code); 1181*ef5ccd6cSJohn Marino extern VEC (char_ptr) *default_make_symbol_completion_list (char *, char *, 1182*ef5ccd6cSJohn Marino enum type_code); 1183*ef5ccd6cSJohn Marino extern VEC (char_ptr) *make_symbol_completion_list (char *, char *); 1184*ef5ccd6cSJohn Marino extern VEC (char_ptr) *make_symbol_completion_type (char *, char *, 1185*ef5ccd6cSJohn Marino enum type_code); 1186*ef5ccd6cSJohn Marino extern VEC (char_ptr) *make_symbol_completion_list_fn (struct cmd_list_element *, 11875796c8dcSSimon Schubert char *, char *); 11885796c8dcSSimon Schubert 1189*ef5ccd6cSJohn Marino extern VEC (char_ptr) *make_file_symbol_completion_list (char *, 1190*ef5ccd6cSJohn Marino char *, char *); 11915796c8dcSSimon Schubert 1192*ef5ccd6cSJohn Marino extern VEC (char_ptr) *make_source_files_completion_list (char *, char *); 11935796c8dcSSimon Schubert 11945796c8dcSSimon Schubert /* symtab.c */ 11955796c8dcSSimon Schubert 11965796c8dcSSimon Schubert int matching_obj_sections (struct obj_section *, struct obj_section *); 11975796c8dcSSimon Schubert 1198c50c785cSJohn Marino extern const char *find_main_filename (void); 11995796c8dcSSimon Schubert 12005796c8dcSSimon Schubert extern struct symtab *find_line_symtab (struct symtab *, int, int *, int *); 12015796c8dcSSimon Schubert 12025796c8dcSSimon Schubert extern struct symtab_and_line find_function_start_sal (struct symbol *sym, 12035796c8dcSSimon Schubert int); 12045796c8dcSSimon Schubert 1205cf7f2e2dSJohn Marino extern void skip_prologue_sal (struct symtab_and_line *); 1206cf7f2e2dSJohn Marino 12075796c8dcSSimon Schubert /* symfile.c */ 12085796c8dcSSimon Schubert 1209c50c785cSJohn Marino extern void clear_symtab_users (int add_flags); 12105796c8dcSSimon Schubert 1211c50c785cSJohn Marino extern enum language deduce_language_from_filename (const char *); 12125796c8dcSSimon Schubert 12135796c8dcSSimon Schubert /* symtab.c */ 12145796c8dcSSimon Schubert 12155796c8dcSSimon Schubert extern int in_prologue (struct gdbarch *gdbarch, 12165796c8dcSSimon Schubert CORE_ADDR pc, CORE_ADDR func_start); 12175796c8dcSSimon Schubert 12185796c8dcSSimon Schubert extern CORE_ADDR skip_prologue_using_sal (struct gdbarch *gdbarch, 12195796c8dcSSimon Schubert CORE_ADDR func_addr); 12205796c8dcSSimon Schubert 12215796c8dcSSimon Schubert extern struct symbol *fixup_symbol_section (struct symbol *, 12225796c8dcSSimon Schubert struct objfile *); 12235796c8dcSSimon Schubert 12245796c8dcSSimon Schubert /* Symbol searching */ 1225*ef5ccd6cSJohn Marino /* Note: struct symbol_search, search_symbols, et.al. are declared here, 1226*ef5ccd6cSJohn Marino instead of making them local to symtab.c, for gdbtk's sake. */ 12275796c8dcSSimon Schubert 12285796c8dcSSimon Schubert /* When using search_symbols, a list of the following structs is returned. 12295796c8dcSSimon Schubert Callers must free the search list using free_search_symbols! */ 12305796c8dcSSimon Schubert struct symbol_search 12315796c8dcSSimon Schubert { 12325796c8dcSSimon Schubert /* The block in which the match was found. Could be, for example, 12335796c8dcSSimon Schubert STATIC_BLOCK or GLOBAL_BLOCK. */ 12345796c8dcSSimon Schubert int block; 12355796c8dcSSimon Schubert 12365796c8dcSSimon Schubert /* Information describing what was found. 12375796c8dcSSimon Schubert 12385796c8dcSSimon Schubert If symtab abd symbol are NOT NULL, then information was found 12395796c8dcSSimon Schubert for this match. */ 12405796c8dcSSimon Schubert struct symtab *symtab; 12415796c8dcSSimon Schubert struct symbol *symbol; 12425796c8dcSSimon Schubert 12435796c8dcSSimon Schubert /* If msymbol is non-null, then a match was made on something for 12445796c8dcSSimon Schubert which only minimal_symbols exist. */ 12455796c8dcSSimon Schubert struct minimal_symbol *msymbol; 12465796c8dcSSimon Schubert 12475796c8dcSSimon Schubert /* A link to the next match, or NULL for the end. */ 12485796c8dcSSimon Schubert struct symbol_search *next; 12495796c8dcSSimon Schubert }; 12505796c8dcSSimon Schubert 1251a45ae5f8SJohn Marino extern void search_symbols (char *, enum search_domain, int, char **, 12525796c8dcSSimon Schubert struct symbol_search **); 12535796c8dcSSimon Schubert extern void free_search_symbols (struct symbol_search *); 12545796c8dcSSimon Schubert extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search 12555796c8dcSSimon Schubert *); 12565796c8dcSSimon Schubert 12575796c8dcSSimon Schubert /* The name of the ``main'' function. 12585796c8dcSSimon Schubert FIXME: cagney/2001-03-20: Can't make main_name() const since some 12595796c8dcSSimon Schubert of the calling code currently assumes that the string isn't 12605796c8dcSSimon Schubert const. */ 12615796c8dcSSimon Schubert extern void set_main_name (const char *name); 12625796c8dcSSimon Schubert extern /*const */ char *main_name (void); 1263c50c785cSJohn Marino extern enum language language_of_main; 12645796c8dcSSimon Schubert 12655796c8dcSSimon Schubert /* Check global symbols in objfile. */ 1266c50c785cSJohn Marino struct symbol *lookup_global_symbol_from_objfile (const struct objfile *, 12675796c8dcSSimon Schubert const char *name, 12685796c8dcSSimon Schubert const domain_enum domain); 12695796c8dcSSimon Schubert 1270cf7f2e2dSJohn Marino /* Return 1 if the supplied producer string matches the ARM RealView 1271cf7f2e2dSJohn Marino compiler (armcc). */ 1272cf7f2e2dSJohn Marino int producer_is_realview (const char *producer); 1273cf7f2e2dSJohn Marino 1274cf7f2e2dSJohn Marino void fixup_section (struct general_symbol_info *ginfo, 1275cf7f2e2dSJohn Marino CORE_ADDR addr, struct objfile *objfile); 1276cf7f2e2dSJohn Marino 1277cf7f2e2dSJohn Marino struct objfile *lookup_objfile_from_block (const struct block *block); 12785796c8dcSSimon Schubert 1279*ef5ccd6cSJohn Marino extern int symtab_create_debug; 1280*ef5ccd6cSJohn Marino 1281a45ae5f8SJohn Marino extern int basenames_may_differ; 1282a45ae5f8SJohn Marino 1283*ef5ccd6cSJohn Marino int compare_filenames_for_search (const char *filename, 1284*ef5ccd6cSJohn Marino const char *search_name); 1285*ef5ccd6cSJohn Marino 1286a45ae5f8SJohn Marino int iterate_over_some_symtabs (const char *name, 1287a45ae5f8SJohn Marino const char *real_path, 1288a45ae5f8SJohn Marino int (*callback) (struct symtab *symtab, 1289a45ae5f8SJohn Marino void *data), 1290a45ae5f8SJohn Marino void *data, 1291a45ae5f8SJohn Marino struct symtab *first, 1292a45ae5f8SJohn Marino struct symtab *after_last); 1293a45ae5f8SJohn Marino 1294a45ae5f8SJohn Marino void iterate_over_symtabs (const char *name, 1295a45ae5f8SJohn Marino int (*callback) (struct symtab *symtab, 1296a45ae5f8SJohn Marino void *data), 1297a45ae5f8SJohn Marino void *data); 1298a45ae5f8SJohn Marino 1299a45ae5f8SJohn Marino DEF_VEC_I (CORE_ADDR); 1300a45ae5f8SJohn Marino 1301a45ae5f8SJohn Marino VEC (CORE_ADDR) *find_pcs_for_symtab_line (struct symtab *symtab, int line, 1302a45ae5f8SJohn Marino struct linetable_entry **best_entry); 1303a45ae5f8SJohn Marino 1304*ef5ccd6cSJohn Marino /* Callback for LA_ITERATE_OVER_SYMBOLS. The callback will be called 1305*ef5ccd6cSJohn Marino once per matching symbol SYM, with DATA being the argument of the 1306*ef5ccd6cSJohn Marino same name that was passed to LA_ITERATE_OVER_SYMBOLS. The callback 1307*ef5ccd6cSJohn Marino should return nonzero to indicate that LA_ITERATE_OVER_SYMBOLS 1308*ef5ccd6cSJohn Marino should continue iterating, or zero to indicate that the iteration 1309*ef5ccd6cSJohn Marino should end. */ 1310*ef5ccd6cSJohn Marino 1311*ef5ccd6cSJohn Marino typedef int (symbol_found_callback_ftype) (struct symbol *sym, void *data); 1312*ef5ccd6cSJohn Marino 1313a45ae5f8SJohn Marino void iterate_over_symbols (const struct block *block, const char *name, 1314a45ae5f8SJohn Marino const domain_enum domain, 1315*ef5ccd6cSJohn Marino symbol_found_callback_ftype *callback, 1316a45ae5f8SJohn Marino void *data); 1317a45ae5f8SJohn Marino 1318a45ae5f8SJohn Marino struct cleanup *demangle_for_lookup (const char *name, enum language lang, 1319a45ae5f8SJohn Marino const char **result_name); 1320a45ae5f8SJohn Marino 13215796c8dcSSimon Schubert #endif /* !defined(SYMTAB_H) */ 1322