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