gdb/symtab.h - gdb

Global variables defined

Data types defined

Macros defined

Source code

  1. /* Symbol table definitions for GDB.

  2.    Copyright (C) 1986-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #if !defined (SYMTAB_H)
  15. #define SYMTAB_H 1

  16. #include "vec.h"
  17. #include "gdb_vecs.h"
  18. #include "gdbtypes.h"

  19. /* Opaque declarations.  */
  20. struct ui_file;
  21. struct frame_info;
  22. struct symbol;
  23. struct obstack;
  24. struct objfile;
  25. struct block;
  26. struct blockvector;
  27. struct axs_value;
  28. struct agent_expr;
  29. struct program_space;
  30. struct language_defn;
  31. struct probe;
  32. struct common_block;

  33. /* Some of the structures in this file are space critical.
  34.    The space-critical structures are:

  35.      struct general_symbol_info
  36.      struct symbol
  37.      struct partial_symbol

  38.    These structures are laid out to encourage good packing.
  39.    They use ENUM_BITFIELD and short int fields, and they order the
  40.    structure members so that fields less than a word are next
  41.    to each other so they can be packed together.  */

  42. /* Rearranged: used ENUM_BITFIELD and rearranged field order in
  43.    all the space critical structures (plus struct minimal_symbol).
  44.    Memory usage dropped from 99360768 bytes to 90001408 bytes.
  45.    I measured this with before-and-after tests of
  46.    "HEAD-old-gdb -readnow HEAD-old-gdb" and
  47.    "HEAD-new-gdb -readnow HEAD-old-gdb" on native i686-pc-linux-gnu,
  48.    red hat linux 8, with LD_LIBRARY_PATH=/usr/lib/debug,
  49.    typing "maint space 1" at the first command prompt.

  50.    Here is another measurement (from andrew c):
  51.      # no /usr/lib/debug, just plain glibc, like a normal user
  52.      gdb HEAD-old-gdb
  53.      (gdb) break internal_error
  54.      (gdb) run
  55.      (gdb) maint internal-error
  56.      (gdb) backtrace
  57.      (gdb) maint space 1

  58.    gdb gdb_6_0_branch  2003-08-19  space used: 8896512
  59.    gdb HEAD            2003-08-19  space used: 8904704
  60.    gdb HEAD            2003-08-21  space used: 8396800 (+symtab.h)
  61.    gdb HEAD            2003-08-21  space used: 8265728 (+gdbtypes.h)

  62.    The third line shows the savings from the optimizations in symtab.h.
  63.    The fourth line shows the savings from the optimizations in
  64.    gdbtypes.h.  Both optimizations are in gdb HEAD now.

  65.    --chastain 2003-08-21  */

  66. /* Define a structure for the information that is common to all symbol types,
  67.    including minimal symbols, partial symbols, and full symbols.  In a
  68.    multilanguage environment, some language specific information may need to
  69.    be recorded along with each symbol.  */

  70. /* This structure is space critical.  See space comments at the top.  */

  71. struct general_symbol_info
  72. {
  73.   /* Name of the symbol.  This is a required field.  Storage for the
  74.      name is allocated on the objfile_obstack for the associated
  75.      objfile.  For languages like C++ that make a distinction between
  76.      the mangled name and demangled name, this is the mangled
  77.      name.  */

  78.   const char *name;

  79.   /* Value of the symbol.  Which member of this union to use, and what
  80.      it means, depends on what kind of symbol this is and its
  81.      SYMBOL_CLASS.  See comments there for more details.  All of these
  82.      are in host byte order (though what they point to might be in
  83.      target byte order, e.g. LOC_CONST_BYTES).  */

  84.   union
  85.   {
  86.     LONGEST ivalue;

  87.     const struct block *block;

  88.     const gdb_byte *bytes;

  89.     CORE_ADDR address;

  90.     /* A common block.  Used with LOC_COMMON_BLOCK.  */

  91.     const struct common_block *common_block;

  92.     /* For opaque typedef struct chain.  */

  93.     struct symbol *chain;
  94.   }
  95.   value;

  96.   /* Since one and only one language can apply, wrap the language specific
  97.      information inside a union.  */

  98.   union
  99.   {
  100.     /* A pointer to an obstack that can be used for storage associated
  101.        with this symbol.  This is only used by Ada, and only when the
  102.        'ada_mangled' field is zero.  */
  103.     struct obstack *obstack;

  104.     /* This is used by languages which wish to store a demangled name.
  105.        currently used by Ada, C++, Java, and Objective C.  */
  106.     struct mangled_lang
  107.     {
  108.       const char *demangled_name;
  109.     }
  110.     mangled_lang;
  111.   }
  112.   language_specific;

  113.   /* Record the source code language that applies to this symbol.
  114.      This is used to select one of the fields from the language specific
  115.      union above.  */

  116.   ENUM_BITFIELD(language) language : 8;

  117.   /* This is only used by Ada.  If set, then the 'mangled_lang' field
  118.      of language_specific is valid.  Otherwise, the 'obstack' field is
  119.      valid.  */
  120.   unsigned int ada_mangled : 1;

  121.   /* Which section is this symbol in?  This is an index into
  122.      section_offsets for this objfile.  Negative means that the symbol
  123.      does not get relocated relative to a section.  */

  124.   short section;
  125. };

  126. extern void symbol_set_demangled_name (struct general_symbol_info *,
  127.                                        const char *,
  128.                                        struct obstack *);

  129. extern const char *symbol_get_demangled_name
  130.   (const struct general_symbol_info *);

  131. extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);

  132. /* Note that all the following SYMBOL_* macros are used with the
  133.    SYMBOL argument being either a partial symbol or
  134.    a full symbol.  Both types have a ginfo field.  In particular
  135.    the SYMBOL_SET_LANGUAGE, SYMBOL_DEMANGLED_NAME, etc.
  136.    macros cannot be entirely substituted by
  137.    functions, unless the callers are changed to pass in the ginfo
  138.    field only, instead of the SYMBOL parameter.  */

  139. #define SYMBOL_VALUE(symbol)                (symbol)->ginfo.value.ivalue
  140. #define SYMBOL_VALUE_ADDRESS(symbol)        (symbol)->ginfo.value.address
  141. #define SYMBOL_VALUE_BYTES(symbol)        (symbol)->ginfo.value.bytes
  142. #define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->ginfo.value.common_block
  143. #define SYMBOL_BLOCK_VALUE(symbol)        (symbol)->ginfo.value.block
  144. #define SYMBOL_VALUE_CHAIN(symbol)        (symbol)->ginfo.value.chain
  145. #define SYMBOL_LANGUAGE(symbol)                (symbol)->ginfo.language
  146. #define SYMBOL_SECTION(symbol)                (symbol)->ginfo.section
  147. #define SYMBOL_OBJ_SECTION(objfile, symbol)                        \
  148.   (((symbol)->ginfo.section >= 0)                                \
  149.    ? (&(((objfile)->sections)[(symbol)->ginfo.section]))        \
  150.    : NULL)

  151. /* Initializes the language dependent portion of a symbol
  152.    depending upon the language for the symbol.  */
  153. #define SYMBOL_SET_LANGUAGE(symbol,language,obstack)        \
  154.   (symbol_set_language (&(symbol)->ginfo, (language), (obstack)))
  155. extern void symbol_set_language (struct general_symbol_info *symbol,
  156.                                  enum language language,
  157.                                  struct obstack *obstack);

  158. /* Set just the linkage name of a symbol; do not try to demangle
  159.    it.  Used for constructs which do not have a mangled name,
  160.    e.g. struct tags.  Unlike SYMBOL_SET_NAMES, linkage_name must
  161.    be terminated and either already on the objfile's obstack or
  162.    permanently allocated.  */
  163. #define SYMBOL_SET_LINKAGE_NAME(symbol,linkage_name) \
  164.   (symbol)->ginfo.name = (linkage_name)

  165. /* Set the linkage and natural names of a symbol, by demangling
  166.    the linkage name.  */
  167. #define SYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile)        \
  168.   symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name, objfile)
  169. extern void symbol_set_names (struct general_symbol_info *symbol,
  170.                               const char *linkage_name, int len, int copy_name,
  171.                               struct objfile *objfile);

  172. /* Now come lots of name accessor macros.  Short version as to when to
  173.    use which: Use SYMBOL_NATURAL_NAME to refer to the name of the
  174.    symbol in the original source code.  Use SYMBOL_LINKAGE_NAME if you
  175.    want to know what the linker thinks the symbol's name is.  Use
  176.    SYMBOL_PRINT_NAME for output.  Use SYMBOL_DEMANGLED_NAME if you
  177.    specifically need to know whether SYMBOL_NATURAL_NAME and
  178.    SYMBOL_LINKAGE_NAME are different.  */

  179. /* Return SYMBOL's "natural" name, i.e. the name that it was called in
  180.    the original source code.  In languages like C++ where symbols may
  181.    be mangled for ease of manipulation by the linker, this is the
  182.    demangled name.  */

  183. #define SYMBOL_NATURAL_NAME(symbol) \
  184.   (symbol_natural_name (&(symbol)->ginfo))
  185. extern const char *symbol_natural_name
  186.   (const struct general_symbol_info *symbol);

  187. /* Return SYMBOL's name from the point of view of the linker.  In
  188.    languages like C++ where symbols may be mangled for ease of
  189.    manipulation by the linker, this is the mangled name; otherwise,
  190.    it's the same as SYMBOL_NATURAL_NAME.  */

  191. #define SYMBOL_LINKAGE_NAME(symbol)        (symbol)->ginfo.name

  192. /* Return the demangled name for a symbol based on the language for
  193.    that symbol.  If no demangled name exists, return NULL.  */
  194. #define SYMBOL_DEMANGLED_NAME(symbol) \
  195.   (symbol_demangled_name (&(symbol)->ginfo))
  196. extern const char *symbol_demangled_name
  197.   (const struct general_symbol_info *symbol);

  198. /* Macro that returns a version of the name of a symbol that is
  199.    suitable for output.  In C++ this is the "demangled" form of the
  200.    name if demangle is on and the "mangled" form of the name if
  201.    demangle is off.  In other languages this is just the symbol name.
  202.    The result should never be NULL.  Don't use this for internal
  203.    purposes (e.g. storing in a hashtable): it's only suitable for output.

  204.    N.B. symbol may be anything with a ginfo member,
  205.    e.g., struct symbol or struct minimal_symbol.  */

  206. #define SYMBOL_PRINT_NAME(symbol)                                        \
  207.   (demangle ? SYMBOL_NATURAL_NAME (symbol) : SYMBOL_LINKAGE_NAME (symbol))
  208. extern int demangle;

  209. /* Macro that returns the name to be used when sorting and searching symbols.
  210.    In  C++ and Java, we search for the demangled form of a name,
  211.    and so sort symbols accordingly.  In Ada, however, we search by mangled
  212.    name.  If there is no distinct demangled name, then SYMBOL_SEARCH_NAME
  213.    returns the same value (same pointer) as SYMBOL_LINKAGE_NAME.  */
  214. #define SYMBOL_SEARCH_NAME(symbol)                                         \
  215.    (symbol_search_name (&(symbol)->ginfo))
  216. extern const char *symbol_search_name (const struct general_symbol_info *);

  217. /* Return non-zero if NAME matches the "search" name of SYMBOL.
  218.    Whitespace and trailing parentheses are ignored.
  219.    See strcmp_iw for details about its behavior.  */
  220. #define SYMBOL_MATCHES_SEARCH_NAME(symbol, name)                        \
  221.   (strcmp_iw (SYMBOL_SEARCH_NAME (symbol), (name)) == 0)

  222. /* Classification types for a minimal symbol.  These should be taken as
  223.    "advisory only", since if gdb can't easily figure out a
  224.    classification it simply selects mst_unknown.  It may also have to
  225.    guess when it can't figure out which is a better match between two
  226.    types (mst_data versus mst_bss) for example.  Since the minimal
  227.    symbol info is sometimes derived from the BFD library's view of a
  228.    file, we need to live with what information bfd supplies.  */

  229. enum minimal_symbol_type
  230. {
  231.   mst_unknown = 0,                /* Unknown type, the default */
  232.   mst_text,                        /* Generally executable instructions */
  233.   mst_text_gnu_ifunc,                /* Executable code returning address
  234.                                    of executable code */
  235.   mst_slot_got_plt,                /* GOT entries for .plt sections */
  236.   mst_data,                        /* Generally initialized data */
  237.   mst_bss,                        /* Generally uninitialized data */
  238.   mst_abs,                        /* Generally absolute (nonrelocatable) */
  239.   /* GDB uses mst_solib_trampoline for the start address of a shared
  240.      library trampoline entry.  Breakpoints for shared library functions
  241.      are put there if the shared library is not yet loaded.
  242.      After the shared library is loaded, lookup_minimal_symbol will
  243.      prefer the minimal symbol from the shared library (usually
  244.      a mst_text symbol) over the mst_solib_trampoline symbol, and the
  245.      breakpoints will be moved to their true address in the shared
  246.      library via breakpoint_re_set.  */
  247.   mst_solib_trampoline,                /* Shared library trampoline code */
  248.   /* For the mst_file* types, the names are only guaranteed to be unique
  249.      within a given .o file.  */
  250.   mst_file_text,                /* Static version of mst_text */
  251.   mst_file_data,                /* Static version of mst_data */
  252.   mst_file_bss                        /* Static version of mst_bss */
  253. };

  254. /* Define a simple structure used to hold some very basic information about
  255.    all defined global symbols (text, data, bss, abs, etc).  The only required
  256.    information is the general_symbol_info.

  257.    In many cases, even if a file was compiled with no special options for
  258.    debugging at all, as long as was not stripped it will contain sufficient
  259.    information to build a useful minimal symbol table using this structure.
  260.    Even when a file contains enough debugging information to build a full
  261.    symbol table, these minimal symbols are still useful for quickly mapping
  262.    between names and addresses, and vice versa.  They are also sometimes
  263.    used to figure out what full symbol table entries need to be read in.  */

  264. struct minimal_symbol
  265. {

  266.   /* The general symbol info required for all types of symbols.

  267.      The SYMBOL_VALUE_ADDRESS contains the address that this symbol
  268.      corresponds to.  */

  269.   struct general_symbol_info mginfo;

  270.   /* Size of this symbolend_psymtab in dbxread.c uses this
  271.      information to calculate the end of the partial symtab based on the
  272.      address of the last symbol plus the size of the last symbol.  */

  273.   unsigned long size;

  274.   /* Which source file is this symbol in?  Only relevant for mst_file_*.  */
  275.   const char *filename;

  276.   /* Classification type for this minimal symbol.  */

  277.   ENUM_BITFIELD(minimal_symbol_type) type : 8;

  278.   /* Non-zero if this symbol was created by gdb.
  279.      Such symbols do not appear in the output of "info var|fun".  */
  280.   unsigned int created_by_gdb : 1;

  281.   /* Two flag bits provided for the use of the target.  */
  282.   unsigned int target_flag_1 : 1;
  283.   unsigned int target_flag_2 : 1;

  284.   /* Nonzero iff the size of the minimal symbol has been set.
  285.      Symbol size information can sometimes not be determined, because
  286.      the object file format may not carry that piece of information.  */
  287.   unsigned int has_size : 1;

  288.   /* Minimal symbols with the same hash key are kept on a linked
  289.      list.  This is the link.  */

  290.   struct minimal_symbol *hash_next;

  291.   /* Minimal symbols are stored in two different hash tables.  This is
  292.      the `next' pointer for the demangled hash table.  */

  293.   struct minimal_symbol *demangled_hash_next;
  294. };

  295. #define MSYMBOL_TARGET_FLAG_1(msymbol)  (msymbol)->target_flag_1
  296. #define MSYMBOL_TARGET_FLAG_2(msymbol)  (msymbol)->target_flag_2
  297. #define MSYMBOL_SIZE(msymbol)                ((msymbol)->size + 0)
  298. #define SET_MSYMBOL_SIZE(msymbol, sz)                \
  299.   do                                                \
  300.     {                                                \
  301.       (msymbol)->size = sz;                        \
  302.       (msymbol)->has_size = 1;                        \
  303.     } while (0)
  304. #define MSYMBOL_HAS_SIZE(msymbol)        ((msymbol)->has_size + 0)
  305. #define MSYMBOL_TYPE(msymbol)                (msymbol)->type

  306. #define MSYMBOL_VALUE(symbol)                (symbol)->mginfo.value.ivalue
  307. /* The unrelocated address of the minimal symbol.  */
  308. #define MSYMBOL_VALUE_RAW_ADDRESS(symbol) ((symbol)->mginfo.value.address + 0)
  309. /* The relocated address of the minimal symbol, using the section
  310.    offsets from OBJFILE.  */
  311. #define MSYMBOL_VALUE_ADDRESS(objfile, symbol)                                \
  312.   ((symbol)->mginfo.value.address                                        \
  313.    + ANOFFSET ((objfile)->section_offsets, ((symbol)->mginfo.section)))
  314. /* For a bound minsym, we can easily compute the address directly.  */
  315. #define BMSYMBOL_VALUE_ADDRESS(symbol) \
  316.   MSYMBOL_VALUE_ADDRESS ((symbol).objfile, (symbol).minsym)
  317. #define SET_MSYMBOL_VALUE_ADDRESS(symbol, new_value)        \
  318.   ((symbol)->mginfo.value.address = (new_value))
  319. #define MSYMBOL_VALUE_BYTES(symbol)        (symbol)->mginfo.value.bytes
  320. #define MSYMBOL_BLOCK_VALUE(symbol)        (symbol)->mginfo.value.block
  321. #define MSYMBOL_VALUE_CHAIN(symbol)        (symbol)->mginfo.value.chain
  322. #define MSYMBOL_LANGUAGE(symbol)        (symbol)->mginfo.language
  323. #define MSYMBOL_SECTION(symbol)                (symbol)->mginfo.section
  324. #define MSYMBOL_OBJ_SECTION(objfile, symbol)                        \
  325.   (((symbol)->mginfo.section >= 0)                                \
  326.    ? (&(((objfile)->sections)[(symbol)->mginfo.section]))        \
  327.    : NULL)

  328. #define MSYMBOL_NATURAL_NAME(symbol) \
  329.   (symbol_natural_name (&(symbol)->mginfo))
  330. #define MSYMBOL_LINKAGE_NAME(symbol)        (symbol)->mginfo.name
  331. #define MSYMBOL_PRINT_NAME(symbol)                                        \
  332.   (demangle ? MSYMBOL_NATURAL_NAME (symbol) : MSYMBOL_LINKAGE_NAME (symbol))
  333. #define MSYMBOL_DEMANGLED_NAME(symbol) \
  334.   (symbol_demangled_name (&(symbol)->mginfo))
  335. #define MSYMBOL_SET_LANGUAGE(symbol,language,obstack)        \
  336.   (symbol_set_language (&(symbol)->mginfo, (language), (obstack)))
  337. #define MSYMBOL_SEARCH_NAME(symbol)                                         \
  338.    (symbol_search_name (&(symbol)->mginfo))
  339. #define MSYMBOL_MATCHES_SEARCH_NAME(symbol, name)                        \
  340.   (strcmp_iw (MSYMBOL_SEARCH_NAME (symbol), (name)) == 0)
  341. #define MSYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile)        \
  342.   symbol_set_names (&(symbol)->mginfo, linkage_name, len, copy_name, objfile)

  343. #include "minsyms.h"



  344. /* Represent one symbol name; a variable, constant, function or typedef.  */

  345. /* Different name domains for symbols.  Looking up a symbol specifies a
  346.    domain and ignores symbol definitions in other name domains.  */

  347. typedef enum domain_enum_tag
  348. {
  349.   /* UNDEF_DOMAIN is used when a domain has not been discovered or
  350.      none of the following apply.  This usually indicates an error either
  351.      in the symbol information or in gdb's handling of symbols.  */

  352.   UNDEF_DOMAIN,

  353.   /* VAR_DOMAIN is the usual domain.  In C, this contains variables,
  354.      function names, typedef names and enum type values.  */

  355.   VAR_DOMAIN,

  356.   /* STRUCT_DOMAIN is used in C to hold struct, union and enum type names.
  357.      Thus, if `struct foo' is used in a C program, it produces a symbol named
  358.      `foo' in the STRUCT_DOMAIN.  */

  359.   STRUCT_DOMAIN,

  360.   /* MODULE_DOMAIN is used in Fortran to hold module type names.  */

  361.   MODULE_DOMAIN,

  362.   /* LABEL_DOMAIN may be used for names of labels (for gotos).  */

  363.   LABEL_DOMAIN,

  364.   /* Fortran common blocks.  Their naming must be separate from VAR_DOMAIN.
  365.      They also always use LOC_COMMON_BLOCK.  */
  366.   COMMON_BLOCK_DOMAIN
  367. } domain_enum;

  368. /* The number of bits in a symbol used to represent the domain.  */

  369. #define SYMBOL_DOMAIN_BITS 4

  370. extern const char *domain_name (domain_enum);

  371. /* Searching domains, used for `search_symbols'.  Element numbers are
  372.    hardcoded in GDB, check all enum uses before changing it.  */

  373. enum search_domain
  374. {
  375.   /* Everything in VAR_DOMAIN minus FUNCTIONS_DOMAIN and
  376.      TYPES_DOMAIN.  */
  377.   VARIABLES_DOMAIN = 0,

  378.   /* All functions -- for some reason not methods, though.  */
  379.   FUNCTIONS_DOMAIN = 1,

  380.   /* All defined types */
  381.   TYPES_DOMAIN = 2,

  382.   /* Any type.  */
  383.   ALL_DOMAIN = 3
  384. };

  385. extern const char *search_domain_name (enum search_domain);

  386. /* An address-class says where to find the value of a symbol.  */

  387. enum address_class
  388. {
  389.   /* Not used; catches errors.  */

  390.   LOC_UNDEF,

  391.   /* Value is constant int SYMBOL_VALUE, host byteorder.  */

  392.   LOC_CONST,

  393.   /* Value is at fixed address SYMBOL_VALUE_ADDRESS.  */

  394.   LOC_STATIC,

  395.   /* Value is in register.  SYMBOL_VALUE is the register number
  396.      in the original debug format.  SYMBOL_REGISTER_OPS holds a
  397.      function that can be called to transform this into the
  398.      actual register number this represents in a specific target
  399.      architecture (gdbarch).

  400.      For some symbol formats (stabs, for some compilers at least),
  401.      the compiler generates two symbols, an argument and a register.
  402.      In some cases we combine them to a single LOC_REGISTER in symbol
  403.      reading, but currently not for all cases (e.g. it's passed on the
  404.      stack and then loaded into a register).  */

  405.   LOC_REGISTER,

  406.   /* It's an argument; the value is at SYMBOL_VALUE offset in arglist.  */

  407.   LOC_ARG,

  408.   /* Value address is at SYMBOL_VALUE offset in arglist.  */

  409.   LOC_REF_ARG,

  410.   /* Value is in specified register.  Just like LOC_REGISTER except the
  411.      register holds the address of the argument instead of the argument
  412.      itself.  This is currently used for the passing of structs and unions
  413.      on sparc and hppa.  It is also used for call by reference where the
  414.      address is in a register, at least by mipsread.c.  */

  415.   LOC_REGPARM_ADDR,

  416.   /* Value is a local variable at SYMBOL_VALUE offset in stack frame.  */

  417.   LOC_LOCAL,

  418.   /* Value not used; definition in SYMBOL_TYPE.  Symbols in the domain
  419.      STRUCT_DOMAIN all have this class.  */

  420.   LOC_TYPEDEF,

  421.   /* Value is address SYMBOL_VALUE_ADDRESS in the code.  */

  422.   LOC_LABEL,

  423.   /* In a symbol table, value is SYMBOL_BLOCK_VALUE of a `struct block'.
  424.      In a partial symbol table, SYMBOL_VALUE_ADDRESS is the start address
  425.      of the blockFunction names have this class.  */

  426.   LOC_BLOCK,

  427.   /* Value is a constant byte-sequence pointed to by SYMBOL_VALUE_BYTES, in
  428.      target byte order.  */

  429.   LOC_CONST_BYTES,

  430.   /* Value is at fixed address, but the address of the variable has
  431.      to be determined from the minimal symbol table whenever the
  432.      variable is referenced.
  433.      This happens if debugging information for a global symbol is
  434.      emitted and the corresponding minimal symbol is defined
  435.      in another object file or runtime common storage.
  436.      The linker might even remove the minimal symbol if the global
  437.      symbol is never referenced, in which case the symbol remains
  438.      unresolved.

  439.      GDB would normally find the symbol in the minimal symbol table if it will
  440.      not find it in the full symbol table.  But a reference to an external
  441.      symbol in a local block shadowing other definition requires full symbol
  442.      without possibly having its address available for LOC_STATIC.  Testcase
  443.      is provided as `gdb.dwarf2/dw2-unresolved.exp'.  */

  444.   LOC_UNRESOLVED,

  445.   /* The variable does not actually exist in the program.
  446.      The value is ignored.  */

  447.   LOC_OPTIMIZED_OUT,

  448.   /* The variable's address is computed by a set of location
  449.      functions (see "struct symbol_computed_ops" below).  */
  450.   LOC_COMPUTED,

  451.   /* The variable uses general_symbol_info->value->common_block field.
  452.      It also always uses COMMON_BLOCK_DOMAIN.  */
  453.   LOC_COMMON_BLOCK,

  454.   /* Not used, just notes the boundary of the enum.  */
  455.   LOC_FINAL_VALUE
  456. };

  457. /* The methods needed to implement LOC_COMPUTED.  These methods can
  458.    use the symbol's .aux_value for additional per-symbol information.

  459.    At present this is only used to implement location expressions.  */

  460. struct symbol_computed_ops
  461. {

  462.   /* Return the value of the variable SYMBOL, relative to the stack
  463.      frame FRAME.  If the variable has been optimized out, return
  464.      zero.

  465.      Iff `read_needs_frame (SYMBOL)' is zero, then FRAME may be zero.  */

  466.   struct value *(*read_variable) (struct symbol * symbol,
  467.                                   struct frame_info * frame);

  468.   /* Read variable SYMBOL like read_variable at (callee) FRAME's function
  469.      entrySYMBOL should be a function parameter, otherwise
  470.      NO_ENTRY_VALUE_ERROR will be thrown.  */
  471.   struct value *(*read_variable_at_entry) (struct symbol *symbol,
  472.                                            struct frame_info *frame);

  473.   /* Return non-zero if we need a frame to find the value of the SYMBOL.  */
  474.   int (*read_needs_frame) (struct symbol * symbol);

  475.   /* Write to STREAM a natural-language description of the location of
  476.      SYMBOL, in the context of ADDR.  */
  477.   void (*describe_location) (struct symbol * symbol, CORE_ADDR addr,
  478.                              struct ui_file * stream);

  479.   /* Non-zero if this symbol's address computation is dependent on PC.  */
  480.   unsigned char location_has_loclist;

  481.   /* Tracepoint support.  Append bytecodes to the tracepoint agent
  482.      expression AX that push the address of the object SYMBOL.  Set
  483.      VALUE appropriately.  Note --- for objects in registers, this
  484.      needn't emit any code; as long as it sets VALUE properly, then
  485.      the caller will generate the right code in the process of
  486.      treating this as an lvalue or rvalue.  */

  487.   void (*tracepoint_var_ref) (struct symbol *symbol, struct gdbarch *gdbarch,
  488.                               struct agent_expr *ax, struct axs_value *value);

  489.   /* Generate C code to compute the location of SYMBOL.  The C code is
  490.      emitted to STREAM.  GDBARCH is the current architecture and PC is
  491.      the PC at which SYMBOL's location should be evaluated.
  492.      REGISTERS_USED is a vector indexed by register number; the
  493.      generator function should set an element in this vector if the
  494.      corresponding register is needed by the location computation.
  495.      The generated C code must assign the location to a local
  496.      variable; this variable's name is RESULT_NAME.  */

  497.   void (*generate_c_location) (struct symbol *symbol, struct ui_file *stream,
  498.                                struct gdbarch *gdbarch,
  499.                                unsigned char *registers_used,
  500.                                CORE_ADDR pc, const char *result_name);

  501. };

  502. /* The methods needed to implement LOC_BLOCK for inferior functions.
  503.    These methods can use the symbol's .aux_value for additional
  504.    per-symbol information.  */

  505. struct symbol_block_ops
  506. {
  507.   /* Fill in *START and *LENGTH with DWARF block data of function
  508.      FRAMEFUNC valid for inferior context address PC.  Set *LENGTH to
  509.      zero if such location is not valid for PC; *START is left
  510.      uninitialized in such case.  */
  511.   void (*find_frame_base_location) (struct symbol *framefunc, CORE_ADDR pc,
  512.                                     const gdb_byte **start, size_t *length);
  513. };

  514. /* Functions used with LOC_REGISTER and LOC_REGPARM_ADDR.  */

  515. struct symbol_register_ops
  516. {
  517.   int (*register_number) (struct symbol *symbol, struct gdbarch *gdbarch);
  518. };

  519. /* Objects of this type are used to find the address class and the
  520.    various computed ops vectors of a symbol.  */

  521. struct symbol_impl
  522. {
  523.   enum address_class aclass;

  524.   /* Used with LOC_COMPUTED.  */
  525.   const struct symbol_computed_ops *ops_computed;

  526.   /* Used with LOC_BLOCK.  */
  527.   const struct symbol_block_ops *ops_block;

  528.   /* Used with LOC_REGISTER and LOC_REGPARM_ADDR.  */
  529.   const struct symbol_register_ops *ops_register;
  530. };

  531. /* The number of bits we reserve in a symbol for the aclass index.
  532.    This is a #define so that we can have a assertion elsewhere to
  533.    verify that we have reserved enough space for synthetic address
  534.    classes.  */

  535. #define SYMBOL_ACLASS_BITS 6

  536. /* This structure is space critical.  See space comments at the top.  */

  537. struct symbol
  538. {

  539.   /* The general symbol info required for all types of symbols.  */

  540.   struct general_symbol_info ginfo;

  541.   /* Data type of value */

  542.   struct type *type;

  543.   /* The owner of this symbol.
  544.      Which one to use is defined by symbol.is_objfile_owned.  */

  545.   union
  546.   {
  547.     /* The symbol table containing this symbol.  This is the file associated
  548.        with LINE.  It can be NULL during symbols read-in but it is never NULL
  549.        during normal operation.  */
  550.     struct symtab *symtab;

  551.     /* For types defined by the architecture.  */
  552.     struct gdbarch *arch;
  553.   } owner;

  554.   /* Domain code.  */

  555.   ENUM_BITFIELD(domain_enum_tag) domain : SYMBOL_DOMAIN_BITS;

  556.   /* Address class.  This holds an index into the 'symbol_impls'
  557.      table.  The actual enum address_class value is stored there,
  558.      alongside any per-class ops vectors.  */

  559.   unsigned int aclass_index : SYMBOL_ACLASS_BITS;

  560.   /* If non-zero then symbol is objfile-owned, use owner.symtab.
  561.      Otherwise symbol is arch-owned, use owner.arch.  */

  562.   unsigned int is_objfile_owned : 1;

  563.   /* Whether this is an argument.  */

  564.   unsigned is_argument : 1;

  565.   /* Whether this is an inlined function (class LOC_BLOCK only).  */
  566.   unsigned is_inlined : 1;

  567.   /* True if this is a C++ function symbol with template arguments.
  568.      In this case the symbol is really a "struct template_symbol".  */
  569.   unsigned is_cplus_template_function : 1;

  570.   /* Line number of this symbol's definition, except for inlined
  571.      functions.  For an inlined function (class LOC_BLOCK and
  572.      SYMBOL_INLINED set) this is the line number of the function's call
  573.      site.  Inlined function symbols are not definitions, and they are
  574.      never found by symbol table lookup.
  575.      If this symbol is arch-owned, LINE shall be zero.

  576.      FIXME: Should we really make the assumption that nobody will try
  577.      to debug files longer than 64K lines?  What about machine
  578.      generated programs?  */

  579.   unsigned short line;

  580.   /* An arbitrary data pointer, allowing symbol readers to record
  581.      additional information on a per-symbol basis.  Note that this data
  582.      must be allocated using the same obstack as the symbol itself.  */
  583.   /* So far it is only used by LOC_COMPUTED to
  584.      find the location information.  For a LOC_BLOCK symbol
  585.      for a function in a compilation unit compiled with DWARF 2
  586.      information, this is information used internally by the DWARF 2
  587.      code --- specifically, the location expression for the frame
  588.      base for this function.  */
  589.   /* FIXME drow/2003-02-21: For the LOC_BLOCK case, it might be better
  590.      to add a magic symbol to the block containing this information,
  591.      or to have a generic debug info annotation slot for symbols.  */

  592.   void *aux_value;

  593.   struct symbol *hash_next;
  594. };

  595. extern const struct symbol_impl *symbol_impls;

  596. /* Note: There is no accessor macro for symbol.owner because it is
  597.    "private".  */

  598. #define SYMBOL_DOMAIN(symbol)        (symbol)->domain
  599. #define SYMBOL_IMPL(symbol)                (symbol_impls[(symbol)->aclass_index])
  600. #define SYMBOL_ACLASS_INDEX(symbol)        (symbol)->aclass_index
  601. #define SYMBOL_CLASS(symbol)                (SYMBOL_IMPL (symbol).aclass)
  602. #define SYMBOL_OBJFILE_OWNED(symbol)        ((symbol)->is_objfile_owned)
  603. #define SYMBOL_IS_ARGUMENT(symbol)        (symbol)->is_argument
  604. #define SYMBOL_INLINED(symbol)                (symbol)->is_inlined
  605. #define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \
  606.   (symbol)->is_cplus_template_function
  607. #define SYMBOL_TYPE(symbol)                (symbol)->type
  608. #define SYMBOL_LINE(symbol)                (symbol)->line
  609. #define SYMBOL_COMPUTED_OPS(symbol)        (SYMBOL_IMPL (symbol).ops_computed)
  610. #define SYMBOL_BLOCK_OPS(symbol)        (SYMBOL_IMPL (symbol).ops_block)
  611. #define SYMBOL_REGISTER_OPS(symbol)        (SYMBOL_IMPL (symbol).ops_register)
  612. #define SYMBOL_LOCATION_BATON(symbol)   (symbol)->aux_value

  613. extern int register_symbol_computed_impl (enum address_class,
  614.                                           const struct symbol_computed_ops *);

  615. extern int register_symbol_block_impl (enum address_class aclass,
  616.                                        const struct symbol_block_ops *ops);

  617. extern int register_symbol_register_impl (enum address_class,
  618.                                           const struct symbol_register_ops *);

  619. /* Return the OBJFILE of SYMBOL.
  620.    It is an error to call this if symbol.is_objfile_owned is false, which
  621.    only happens for architecture-provided types.  */

  622. extern struct objfile *symbol_objfile (const struct symbol *symbol);

  623. /* Return the ARCH of SYMBOL.  */

  624. extern struct gdbarch *symbol_arch (const struct symbol *symbol);

  625. /* Return the SYMTAB of SYMBOL.
  626.    It is an error to call this if symbol.is_objfile_owned is false, which
  627.    only happens for architecture-provided types.  */

  628. extern struct symtab *symbol_symtab (const struct symbol *symbol);

  629. /* Set the symtab of SYMBOL to SYMTAB.
  630.    It is an error to call this if symbol.is_objfile_owned is false, which
  631.    only happens for architecture-provided types.  */

  632. extern void symbol_set_symtab (struct symbol *symbol, struct symtab *symtab);

  633. /* An instance of this type is used to represent a C++ template
  634.    function.  It includes a "struct symbol" as a kind of base class;
  635.    users downcast to "struct template_symbol *" when needed.  A symbol
  636.    is really of this type iff SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION is
  637.    true.  */

  638. struct template_symbol
  639. {
  640.   /* The base class.  */
  641.   struct symbol base;

  642.   /* The number of template arguments.  */
  643.   int n_template_arguments;

  644.   /* The template arguments.  This is an array with
  645.      N_TEMPLATE_ARGUMENTS elements.  */
  646.   struct symbol **template_arguments;
  647. };


  648. /* Each item represents a line-->pc (or the reverse) mapping.  This is
  649.    somewhat more wasteful of space than one might wish, but since only
  650.    the files which are actually debugged are read in to core, we don't
  651.    waste much space.  */

  652. struct linetable_entry
  653. {
  654.   int line;
  655.   CORE_ADDR pc;
  656. };

  657. /* The order of entries in the linetable is significant.  They should
  658.    be sorted by increasing values of the pc field.  If there is more than
  659.    one entry for a given pc, then I'm not sure what should happen (and
  660.    I not sure whether we currently handle it the best way).

  661.    Example: a C for statement generally looks like this

  662.    10   0x100   - for the init/test part of a for stmt.
  663.    20   0x200
  664.    30   0x300
  665.    10   0x400   - for the increment part of a for stmt.

  666.    If an entry has a line number of zero, it marks the start of a PC
  667.    range for which no line number information is available.  It is
  668.    acceptable, though wasteful of table space, for such a range to be
  669.    zero length.  */

  670. struct linetable
  671. {
  672.   int nitems;

  673.   /* Actually NITEMS elements.  If you don't like this use of the
  674.      `struct hack', you can shove it up your ANSI (seriously, if the
  675.      committee tells us how to do it, we can probably go along).  */
  676.   struct linetable_entry item[1];
  677. };

  678. /* How to relocate the symbols from each section in a symbol file.
  679.    Each struct contains an array of offsets.
  680.    The ordering and meaning of the offsets is file-type-dependent;
  681.    typically it is indexed by section numbers or symbol types or
  682.    something like that.

  683.    To give us flexibility in changing the internal representation
  684.    of these offsets, the ANOFFSET macro must be used to insert and
  685.    extract offset values in the struct.  */

  686. struct section_offsets
  687. {
  688.   CORE_ADDR offsets[1];                /* As many as needed.  */
  689. };

  690. #define        ANOFFSET(secoff, whichone) \
  691.   ((whichone == -1)                          \
  692.    ? (internal_error (__FILE__, __LINE__, \
  693.                       _("Section index is uninitialized")), -1) \
  694.    : secoff->offsets[whichone])

  695. /* The size of a section_offsets table for N sections.  */
  696. #define SIZEOF_N_SECTION_OFFSETS(n) \
  697.   (sizeof (struct section_offsets) \
  698.    + sizeof (((struct section_offsets *) 0)->offsets) * ((n)-1))

  699. /* Each source file or header is represented by a struct symtab.
  700.    The name "symtab" is historical, another name for it is "filetab".
  701.    These objects are chained through the `next' field.  */

  702. struct symtab
  703. {
  704.   /* Unordered chain of all existing symtabs of this objfile.  */

  705.   struct symtab *next;

  706.   /* Backlink to containing compunit symtab.  */

  707.   struct compunit_symtab *compunit_symtab;

  708.   /* Table mapping core addresses to line numbers for this file.
  709.      Can be NULL if none.  Never shared between different symtabs.  */

  710.   struct linetable *linetable;

  711.   /* Name of this source file.  This pointer is never NULL.  */

  712.   const char *filename;

  713.   /* Total number of lines found in source file.  */

  714.   int nlines;

  715.   /* line_charpos[N] is the position of the (N-1)th line of the
  716.      source file.  "position" means something we can lseek() to; it
  717.      is not guaranteed to be useful any other way.  */

  718.   int *line_charpos;

  719.   /* Language of this source file.  */

  720.   enum language language;

  721.   /* Full name of file as found by searching the source path.
  722.      NULL if not yet known.  */

  723.   char *fullname;
  724. };

  725. #define SYMTAB_COMPUNIT(symtab) ((symtab)->compunit_symtab)
  726. #define SYMTAB_LINETABLE(symtab) ((symtab)->linetable)
  727. #define SYMTAB_LANGUAGE(symtab) ((symtab)->language)
  728. #define SYMTAB_BLOCKVECTOR(symtab) \
  729.   COMPUNIT_BLOCKVECTOR (SYMTAB_COMPUNIT (symtab))
  730. #define SYMTAB_OBJFILE(symtab) \
  731.   COMPUNIT_OBJFILE (SYMTAB_COMPUNIT (symtab))
  732. #define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace)
  733. #define SYMTAB_DIRNAME(symtab) \
  734.   COMPUNIT_DIRNAME (SYMTAB_COMPUNIT (symtab))

  735. typedef struct symtab *symtab_ptr;
  736. DEF_VEC_P (symtab_ptr);

  737. /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well
  738.    as the list of all source files (what gdb has historically associated with
  739.    the term "symtab").
  740.    Additional information is recorded here that is common to all symtabs in a
  741.    compilation unit (DWARF or otherwise).

  742.    Example:
  743.    For the case of a program built out of these files:

  744.    foo.c
  745.      foo1.h
  746.      foo2.h
  747.    bar.c
  748.      foo1.h
  749.      bar.h

  750.    This is recorded as:

  751.    objfile -> foo.c(cu) -> bar.c(cu) -> NULL
  752.                 |            |
  753.                 v            v
  754.               foo.c        bar.c
  755.                 |            |
  756.                 v            v
  757.               foo1.h       foo1.h
  758.                 |            |
  759.                 v            v
  760.               foo2.h       bar.h
  761.                 |            |
  762.                 v            v
  763.                NULL         NULL

  764.    where "foo.c(cu)" and "bar.c(cu)" are struct compunit_symtab objects,
  765.    and the files foo.c, etc. are struct symtab objects.  */

  766. struct compunit_symtab
  767. {
  768.   /* Unordered chain of all compunit symtabs of this objfile.  */
  769.   struct compunit_symtab *next;

  770.   /* Object file from which this symtab information was read.  */
  771.   struct objfile *objfile;

  772.   /* Name of the symtab.
  773.      This is *not* intended to be a usable filename, and is
  774.      for debugging purposes only.  */
  775.   const char *name;

  776.   /* Unordered list of file symtabs, except that by convention the "main"
  777.      source file (e.g., .c, .cc) is guaranteed to be first.
  778.      Each symtab is a file, either the "main" source file (e.g., .c, .cc)
  779.      or header (e.g., .h).  */
  780.   struct symtab *filetabs;

  781.   /* Last entry in FILETABS list.
  782.      Subfiles are added to the end of the list so they accumulate in order,
  783.      with the main source subfile living at the front.
  784.      The main reason is so that the main source file symtab is at the head
  785.      of the list, and the rest appear in order for debugging convenience.  */
  786.   struct symtab *last_filetab;

  787.   /* Non-NULL string that identifies the format of the debugging information,
  788.      such as "stabs", "dwarf 1", "dwarf 2", "coff", etc.  This is mostly useful
  789.      for automated testing of gdb but may also be information that is
  790.      useful to the user.  */
  791.   const char *debugformat;

  792.   /* String of producer version information, or NULL if we don't know.  */
  793.   const char *producer;

  794.   /* Directory in which it was compiled, or NULL if we don't know.  */
  795.   const char *dirname;

  796.   /* List of all symbol scope blocks for this symtab.  It is shared among
  797.      all symtabs in a given compilation unit.  */
  798.   const struct blockvector *blockvector;

  799.   /* Section in objfile->section_offsets for the blockvector and
  800.      the linetable.  Probably always SECT_OFF_TEXT.  */
  801.   int block_line_section;

  802.   /* Symtab has been compiled with both optimizations and debug info so that
  803.      GDB may stop skipping prologues as variables locations are valid already
  804.      at function entry points.  */
  805.   unsigned int locations_valid : 1;

  806.   /* DWARF unwinder for this CU is valid even for epilogues (PC at the return
  807.      instruction).  This is supported by GCC since 4.5.0.  */
  808.   unsigned int epilogue_unwind_valid : 1;

  809.   /* struct call_site entries for this compilation unit or NULL.  */
  810.   htab_t call_site_htab;

  811.   /* The macro table for this symtab.  Like the blockvector, this
  812.      is shared between different symtabs in a given compilation unit.
  813.      It's debatable whether it *should* be shared among all the symtabs in
  814.      the given compilation unit, but it currently is.  */
  815.   struct macro_table *macro_table;

  816.   /* If non-NULL, then this points to a NULL-terminated vector of
  817.      included compunits.  When searching the static or global
  818.      block of this compunit, the corresponding block of all
  819.      included compunits will also be searched.  Note that this
  820.      list must be flattened -- the symbol reader is responsible for
  821.      ensuring that this vector contains the transitive closure of all
  822.      included compunits.  */
  823.   struct compunit_symtab **includes;

  824.   /* If this is an included compunit, this points to one includer
  825.      of the table.  This user is considered the canonical compunit
  826.      containing this one.  An included compunit may itself be
  827.      included by another.  */
  828.   struct compunit_symtab *user;
  829. };

  830. #define COMPUNIT_OBJFILE(cust) ((cust)->objfile)
  831. #define COMPUNIT_FILETABS(cust) ((cust)->filetabs)
  832. #define COMPUNIT_DEBUGFORMAT(cust) ((cust)->debugformat)
  833. #define COMPUNIT_PRODUCER(cust) ((cust)->producer)
  834. #define COMPUNIT_DIRNAME(cust) ((cust)->dirname)
  835. #define COMPUNIT_BLOCKVECTOR(cust) ((cust)->blockvector)
  836. #define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section)
  837. #define COMPUNIT_LOCATIONS_VALID(cust) ((cust)->locations_valid)
  838. #define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid)
  839. #define COMPUNIT_CALL_SITE_HTAB(cust) ((cust)->call_site_htab)
  840. #define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table)

  841. /* Iterate over all file tables (struct symtab) within a compunit.  */

  842. #define ALL_COMPUNIT_FILETABS(cu, s) \
  843.   for ((s) = (cu) -> filetabs; (s) != NULL; (s) = (s) -> next)

  844. /* Return the primary symtab of CUST.  */

  845. extern struct symtab *
  846.   compunit_primary_filetab (const struct compunit_symtab *cust);

  847. /* Return the language of CUST.  */

  848. extern enum language compunit_language (const struct compunit_symtab *cust);

  849. typedef struct compunit_symtab *compunit_symtab_ptr;
  850. DEF_VEC_P (compunit_symtab_ptr);



  851. /* The virtual function table is now an array of structures which have the
  852.    form { int16 offset, delta; void *pfn; }.

  853.    In normal virtual function tables, OFFSET is unused.
  854.    DELTA is the amount which is added to the apparent object's base
  855.    address in order to point to the actual object to which the
  856.    virtual function should be applied.
  857.    PFN is a pointer to the virtual function.

  858.    Note that this macro is g++ specific (FIXME).  */

  859. #define VTBL_FNADDR_OFFSET 2

  860. /* External variables and functions for the objects described above.  */

  861. /* True if we are nested inside psymtab_to_symtab.  */

  862. extern int currently_reading_symtab;

  863. /* The block in which the most recently looked up symbol was found.  */

  864. extern const struct block *block_found;

  865. /* symtab.c lookup functions */

  866. extern const char multiple_symbols_ask[];
  867. extern const char multiple_symbols_all[];
  868. extern const char multiple_symbols_cancel[];

  869. const char *multiple_symbols_select_mode (void);

  870. int symbol_matches_domain (enum language symbol_language,
  871.                            domain_enum symbol_domain,
  872.                            domain_enum domain);

  873. /* lookup a symbol table by source file name.  */

  874. extern struct symtab *lookup_symtab (const char *);

  875. /* An object of this type is passed as the 'is_a_field_of_this'
  876.    argument to lookup_symbol and lookup_symbol_in_language.  */

  877. struct field_of_this_result
  878. {
  879.   /* The type in which the field was found.  If this is NULL then the
  880.      symbol was not found in 'this'.  If non-NULL, then one of the
  881.      other fields will be non-NULL as well.  */

  882.   struct type *type;

  883.   /* If the symbol was found as an ordinary field of 'this', then this
  884.      is non-NULL and points to the particular field.  */

  885.   struct field *field;

  886.   /* If the symbol was found as a function field of 'this', then this
  887.      is non-NULL and points to the particular field.  */

  888.   struct fn_fieldlist *fn_field;
  889. };

  890. /* Find the definition for a specified symbol name NAME
  891.    in domain DOMAIN in language LANGUAGE, visible from lexical block BLOCK
  892.    if non-NULL or from global/static blocks if BLOCK is NULL.
  893.    Returns the struct symbol pointer, or NULL if no symbol is found.
  894.    C++: if IS_A_FIELD_OF_THIS is non-NULL on entry, check to see if
  895.    NAME is a field of the current implied argument `this'.  If so fill in the
  896.    fields of IS_A_FIELD_OF_THIS, otherwise the fields are set to NULL.
  897.    BLOCK_FOUND is set to the block in which NAME is found (in the case of
  898.    a field of `this', value_of_this sets BLOCK_FOUND to the proper value).
  899.    The symbol's section is fixed up if necessary.  */

  900. extern struct symbol *lookup_symbol_in_language (const char *,
  901.                                                  const struct block *,
  902.                                                  const domain_enum,
  903.                                                  enum language,
  904.                                                  struct field_of_this_result *);

  905. /* Same as lookup_symbol_in_language, but using the current language.  */

  906. extern struct symbol *lookup_symbol (const char *, const struct block *,
  907.                                      const domain_enum,
  908.                                      struct field_of_this_result *);

  909. /* A default version of lookup_symbol_nonlocal for use by languages
  910.    that can't think of anything better to do.
  911.    This implements the C lookup rules.  */

  912. extern struct symbol *
  913.   basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
  914.                                 const char *,
  915.                                 const struct block *,
  916.                                 const domain_enum);

  917. /* Some helper functions for languages that need to write their own
  918.    lookup_symbol_nonlocal functions.  */

  919. /* Lookup a symbol in the static block associated to BLOCK, if there
  920.    is one; do nothing if BLOCK is NULL or a global block.
  921.    Upon success sets BLOCK_FOUND and fixes up the symbol's section
  922.    if necessary.  */

  923. extern struct symbol *lookup_symbol_in_static_block (const char *name,
  924.                                                      const struct block *block,
  925.                                                      const domain_enum domain);

  926. /* Search all static file-level symbols for NAME from DOMAIN.
  927.    Upon success sets BLOCK_FOUND and fixes up the symbol's section
  928.    if necessary.  */

  929. extern struct symbol *lookup_static_symbol (const char *name,
  930.                                             const domain_enum domain);

  931. /* Lookup a symbol in all files' global blocks.

  932.    If BLOCK is non-NULL then it is used for two things:
  933.    1) If a target-specific lookup routine for libraries exists, then use the
  934.       routine for the objfile of BLOCK, and
  935.    2) The objfile of BLOCK is used to assist in determining the search order
  936.       if the target requires it.
  937.       See gdbarch_iterate_over_objfiles_in_search_order.

  938.    Upon success sets BLOCK_FOUND and fixes up the symbol's section
  939.    if necessary.  */

  940. extern struct symbol *lookup_global_symbol (const char *name,
  941.                                             const struct block *block,
  942.                                             const domain_enum domain);

  943. /* Lookup a symbol in block BLOCK.
  944.    Upon success sets BLOCK_FOUND and fixes up the symbol's section
  945.    if necessary.  */

  946. extern struct symbol *lookup_symbol_in_block (const char *name,
  947.                                               const struct block *block,
  948.                                               const domain_enum domain);

  949. /* Look up the `this' symbol for LANG in BLOCK.  Return the symbol if
  950.    found, or NULL if not found.  */

  951. extern struct symbol *lookup_language_this (const struct language_defn *lang,
  952.                                             const struct block *block);

  953. /* Lookup a [struct, union, enum] by name, within a specified block.  */

  954. extern struct type *lookup_struct (const char *, const struct block *);

  955. extern struct type *lookup_union (const char *, const struct block *);

  956. extern struct type *lookup_enum (const char *, const struct block *);

  957. /* from blockframe.c: */

  958. /* lookup the function symbol corresponding to the address.  */

  959. extern struct symbol *find_pc_function (CORE_ADDR);

  960. /* lookup the function corresponding to the address and section.  */

  961. extern struct symbol *find_pc_sect_function (CORE_ADDR, struct obj_section *);

  962. extern int find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name,
  963.                                                CORE_ADDR *address,
  964.                                                CORE_ADDR *endaddr,
  965.                                                int *is_gnu_ifunc_p);

  966. /* lookup function from address, return name, start addr and end addr.  */

  967. extern int find_pc_partial_function (CORE_ADDR, const char **, CORE_ADDR *,
  968.                                      CORE_ADDR *);

  969. extern void clear_pc_function_cache (void);

  970. /* Expand symtab containing PC, SECTION if not already expanded.  */

  971. extern void expand_symtab_containing_pc (CORE_ADDR, struct obj_section *);

  972. /* lookup full symbol table by address.  */

  973. extern struct compunit_symtab *find_pc_compunit_symtab (CORE_ADDR);

  974. /* lookup full symbol table by address and section.  */

  975. extern struct compunit_symtab *
  976.   find_pc_sect_compunit_symtab (CORE_ADDR, struct obj_section *);

  977. extern int find_pc_line_pc_range (CORE_ADDR, CORE_ADDR *, CORE_ADDR *);

  978. extern void reread_symbols (void);

  979. /* Look up a type named NAME in STRUCT_DOMAIN in the current language.
  980.    The type returned must not be opaque -- i.e., must have at least one field
  981.    defined.  */

  982. extern struct type *lookup_transparent_type (const char *);

  983. extern struct type *basic_lookup_transparent_type (const char *);

  984. /* Macro for name of symbol to indicate a file compiled with gcc.  */
  985. #ifndef GCC_COMPILED_FLAG_SYMBOL
  986. #define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled."
  987. #endif

  988. /* Macro for name of symbol to indicate a file compiled with gcc2.  */
  989. #ifndef GCC2_COMPILED_FLAG_SYMBOL
  990. #define GCC2_COMPILED_FLAG_SYMBOL "gcc2_compiled."
  991. #endif

  992. extern int in_gnu_ifunc_stub (CORE_ADDR pc);

  993. /* Functions for resolving STT_GNU_IFUNC symbols which are implemented only
  994.    for ELF symbol files.  */

  995. struct gnu_ifunc_fns
  996. {
  997.   /* See elf_gnu_ifunc_resolve_addr for its real implementation.  */
  998.   CORE_ADDR (*gnu_ifunc_resolve_addr) (struct gdbarch *gdbarch, CORE_ADDR pc);

  999.   /* See elf_gnu_ifunc_resolve_name for its real implementation.  */
  1000.   int (*gnu_ifunc_resolve_name) (const char *function_name,
  1001.                                  CORE_ADDR *function_address_p);

  1002.   /* See elf_gnu_ifunc_resolver_stop for its real implementation.  */
  1003.   void (*gnu_ifunc_resolver_stop) (struct breakpoint *b);

  1004.   /* See elf_gnu_ifunc_resolver_return_stop for its real implementation.  */
  1005.   void (*gnu_ifunc_resolver_return_stop) (struct breakpoint *b);
  1006. };

  1007. #define gnu_ifunc_resolve_addr gnu_ifunc_fns_p->gnu_ifunc_resolve_addr
  1008. #define gnu_ifunc_resolve_name gnu_ifunc_fns_p->gnu_ifunc_resolve_name
  1009. #define gnu_ifunc_resolver_stop gnu_ifunc_fns_p->gnu_ifunc_resolver_stop
  1010. #define gnu_ifunc_resolver_return_stop \
  1011.   gnu_ifunc_fns_p->gnu_ifunc_resolver_return_stop

  1012. extern const struct gnu_ifunc_fns *gnu_ifunc_fns_p;

  1013. extern CORE_ADDR find_solib_trampoline_target (struct frame_info *, CORE_ADDR);

  1014. struct symtab_and_line
  1015. {
  1016.   /* The program space of this sal.  */
  1017.   struct program_space *pspace;

  1018.   struct symtab *symtab;
  1019.   struct obj_section *section;
  1020.   /* Line number.  Line numbers start at 1 and proceed through symtab->nlines.
  1021.      0 is never a valid line number; it is used to indicate that line number
  1022.      information is not available.  */
  1023.   int line;

  1024.   CORE_ADDR pc;
  1025.   CORE_ADDR end;
  1026.   int explicit_pc;
  1027.   int explicit_line;

  1028.   /* The probe associated with this symtab_and_line.  */
  1029.   struct probe *probe;
  1030.   /* If PROBE is not NULL, then this is the objfile in which the probe
  1031.      originated.  */
  1032.   struct objfile *objfile;
  1033. };

  1034. extern void init_sal (struct symtab_and_line *sal);

  1035. struct symtabs_and_lines
  1036. {
  1037.   struct symtab_and_line *sals;
  1038.   int nelts;
  1039. };


  1040. /* Given a pc value, return line number it is in.  Second arg nonzero means
  1041.    if pc is on the boundary use the previous statement's line number.  */

  1042. extern struct symtab_and_line find_pc_line (CORE_ADDR, int);

  1043. /* Same function, but specify a section as well as an address.  */

  1044. extern struct symtab_and_line find_pc_sect_line (CORE_ADDR,
  1045.                                                  struct obj_section *, int);

  1046. /* Wrapper around find_pc_line to just return the symtab.  */

  1047. extern struct symtab *find_pc_line_symtab (CORE_ADDR);

  1048. /* Given a symtab and line number, return the pc there.  */

  1049. extern int find_line_pc (struct symtab *, int, CORE_ADDR *);

  1050. extern int find_line_pc_range (struct symtab_and_line, CORE_ADDR *,
  1051.                                CORE_ADDR *);

  1052. extern void resolve_sal_pc (struct symtab_and_line *);

  1053. /* Symbol-reading stuff in symfile.c and solib.c.  */

  1054. extern void clear_solib (void);

  1055. /* source.c */

  1056. extern int identify_source_line (struct symtab *, int, int, CORE_ADDR);

  1057. /* Flags passed as 4th argument to print_source_lines.  */

  1058. enum print_source_lines_flags
  1059.   {
  1060.     /* Do not print an error message.  */
  1061.     PRINT_SOURCE_LINES_NOERROR = (1 << 0),

  1062.     /* Print the filename in front of the source lines.  */
  1063.     PRINT_SOURCE_LINES_FILENAME = (1 << 1)
  1064.   };

  1065. extern void print_source_lines (struct symtab *, int, int,
  1066.                                 enum print_source_lines_flags);

  1067. extern void forget_cached_source_info_for_objfile (struct objfile *);
  1068. extern void forget_cached_source_info (void);

  1069. extern void select_source_symtab (struct symtab *);

  1070. extern VEC (char_ptr) *default_make_symbol_completion_list_break_on
  1071.   (const char *text, const char *word, const char *break_on,
  1072.    enum type_code code);
  1073. extern VEC (char_ptr) *default_make_symbol_completion_list (const char *,
  1074.                                                             const char *,
  1075.                                                             enum type_code);
  1076. extern VEC (char_ptr) *make_symbol_completion_list (const char *, const char *);
  1077. extern VEC (char_ptr) *make_symbol_completion_type (const char *, const char *,
  1078.                                                     enum type_code);
  1079. extern VEC (char_ptr) *make_symbol_completion_list_fn (struct cmd_list_element *,
  1080.                                                        const char *,
  1081.                                                        const char *);

  1082. extern VEC (char_ptr) *make_file_symbol_completion_list (const char *,
  1083.                                                          const char *,
  1084.                                                          const char *);

  1085. extern VEC (char_ptr) *make_source_files_completion_list (const char *,
  1086.                                                           const char *);

  1087. /* symtab.c */

  1088. int matching_obj_sections (struct obj_section *, struct obj_section *);

  1089. extern struct symtab *find_line_symtab (struct symtab *, int, int *, int *);

  1090. extern struct symtab_and_line find_function_start_sal (struct symbol *sym,
  1091.                                                        int);

  1092. extern void skip_prologue_sal (struct symtab_and_line *);

  1093. /* symfile.c */

  1094. extern void clear_symtab_users (int add_flags);

  1095. extern enum language deduce_language_from_filename (const char *);

  1096. /* symtab.c */

  1097. extern CORE_ADDR skip_prologue_using_sal (struct gdbarch *gdbarch,
  1098.                                           CORE_ADDR func_addr);

  1099. extern struct symbol *fixup_symbol_section (struct symbol *,
  1100.                                             struct objfile *);

  1101. /* Symbol searching */
  1102. /* Note: struct symbol_search, search_symbols, et.al. are declared here,
  1103.    instead of making them local to symtab.c, for gdbtk's sake.  */

  1104. /* When using search_symbols, a list of the following structs is returned.
  1105.    Callers must free the search list using free_search_symbols!  */
  1106. struct symbol_search
  1107. {
  1108.   /* The block in which the match was found.  Could be, for example,
  1109.      STATIC_BLOCK or GLOBAL_BLOCK.  */
  1110.   int block;

  1111.   /* Information describing what was found.

  1112.      If symbol is NOT NULL, then information was found for this match.  */
  1113.   struct symbol *symbol;

  1114.   /* If msymbol is non-null, then a match was made on something for
  1115.      which only minimal_symbols exist.  */
  1116.   struct bound_minimal_symbol msymbol;

  1117.   /* A link to the next match, or NULL for the end.  */
  1118.   struct symbol_search *next;
  1119. };

  1120. extern void search_symbols (const char *, enum search_domain, int,
  1121.                             const char **, struct symbol_search **);
  1122. extern void free_search_symbols (struct symbol_search *);
  1123. extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search
  1124.                                                          **);

  1125. /* The name of the ``main'' function.
  1126.    FIXME: cagney/2001-03-20: Can't make main_name() const since some
  1127.    of the calling code currently assumes that the string isn't
  1128.    const.  */
  1129. extern /*const */ char *main_name (void);
  1130. extern enum language main_language (void);

  1131. /* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global blocks.
  1132.    This searches MAIN_OBJFILE as well as any associated separate debug info
  1133.    objfiles of MAIN_OBJFILE.
  1134.    Upon success sets BLOCK_FOUND and fixes up the symbol's section
  1135.    if necessary.  */

  1136. extern struct symbol *
  1137.   lookup_global_symbol_from_objfile (struct objfile *main_objfile,
  1138.                                      const char *name,
  1139.                                      const domain_enum domain);

  1140. /* Return 1 if the supplied producer string matches the ARM RealView
  1141.    compiler (armcc).  */
  1142. int producer_is_realview (const char *producer);

  1143. void fixup_section (struct general_symbol_info *ginfo,
  1144.                     CORE_ADDR addr, struct objfile *objfile);

  1145. /* Look up objfile containing BLOCK.  */

  1146. struct objfile *lookup_objfile_from_block (const struct block *block);

  1147. extern unsigned int symtab_create_debug;

  1148. extern unsigned int symbol_lookup_debug;

  1149. extern int basenames_may_differ;

  1150. int compare_filenames_for_search (const char *filename,
  1151.                                   const char *search_name);

  1152. int iterate_over_some_symtabs (const char *name,
  1153.                                const char *real_path,
  1154.                                int (*callback) (struct symtab *symtab,
  1155.                                                 void *data),
  1156.                                void *data,
  1157.                                struct compunit_symtab *first,
  1158.                                struct compunit_symtab *after_last);

  1159. void iterate_over_symtabs (const char *name,
  1160.                            int (*callback) (struct symtab *symtab,
  1161.                                             void *data),
  1162.                            void *data);

  1163. DEF_VEC_I (CORE_ADDR);

  1164. VEC (CORE_ADDR) *find_pcs_for_symtab_line (struct symtab *symtab, int line,
  1165.                                            struct linetable_entry **best_entry);

  1166. /* Callback for LA_ITERATE_OVER_SYMBOLS.  The callback will be called
  1167.    once per matching symbol SYM, with DATA being the argument of the
  1168.    same name that was passed to LA_ITERATE_OVER_SYMBOLS.  The callback
  1169.    should return nonzero to indicate that LA_ITERATE_OVER_SYMBOLS
  1170.    should continue iterating, or zero to indicate that the iteration
  1171.    should end.  */

  1172. typedef int (symbol_found_callback_ftype) (struct symbol *sym, void *data);

  1173. void iterate_over_symbols (const struct block *block, const char *name,
  1174.                            const domain_enum domain,
  1175.                            symbol_found_callback_ftype *callback,
  1176.                            void *data);

  1177. struct cleanup *demangle_for_lookup (const char *name, enum language lang,
  1178.                                      const char **result_name);

  1179. struct symbol *allocate_symbol (struct objfile *);

  1180. void initialize_objfile_symbol (struct symbol *);

  1181. struct template_symbol *allocate_template_symbol (struct objfile *);

  1182. #endif /* !defined(SYMTAB_H) */