Home | History | Annotate | Line # | Download | only in gdb
symtab.h revision 1.10
      1   1.1  christos /* Symbol table definitions for GDB.
      2   1.1  christos 
      3  1.10  christos    Copyright (C) 1986-2023 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.8  christos #include <array>
     24   1.7  christos #include <vector>
     25   1.8  christos #include <string>
     26   1.9  christos #include <set>
     27   1.9  christos #include "gdbsupport/gdb_vecs.h"
     28   1.1  christos #include "gdbtypes.h"
     29  1.10  christos #include "gdbsupport/gdb_obstack.h"
     30  1.10  christos #include "gdbsupport/gdb_regex.h"
     31   1.9  christos #include "gdbsupport/enum-flags.h"
     32   1.9  christos #include "gdbsupport/function-view.h"
     33   1.9  christos #include "gdbsupport/gdb_optional.h"
     34   1.9  christos #include "gdbsupport/gdb_string_view.h"
     35   1.9  christos #include "gdbsupport/next-iterator.h"
     36  1.10  christos #include "gdbsupport/iterator-range.h"
     37   1.8  christos #include "completer.h"
     38   1.9  christos #include "gdb-demangle.h"
     39  1.10  christos #include "split-name.h"
     40   1.1  christos 
     41   1.1  christos /* Opaque declarations.  */
     42   1.1  christos struct ui_file;
     43  1.10  christos class frame_info_ptr;
     44   1.1  christos struct symbol;
     45   1.1  christos struct obstack;
     46   1.1  christos struct objfile;
     47   1.1  christos struct block;
     48   1.1  christos struct blockvector;
     49   1.1  christos struct axs_value;
     50   1.1  christos struct agent_expr;
     51   1.1  christos struct program_space;
     52   1.1  christos struct language_defn;
     53   1.1  christos struct common_block;
     54   1.6  christos struct obj_section;
     55   1.6  christos struct cmd_list_element;
     56   1.8  christos class probe;
     57   1.8  christos struct lookup_name_info;
     58  1.10  christos struct code_breakpoint;
     59   1.8  christos 
     60   1.8  christos /* How to match a lookup name against a symbol search name.  */
     61   1.8  christos enum class symbol_name_match_type
     62   1.8  christos {
     63   1.8  christos   /* Wild matching.  Matches unqualified symbol names in all
     64   1.8  christos      namespace/module/packages, etc.  */
     65   1.8  christos   WILD,
     66   1.8  christos 
     67   1.8  christos   /* Full matching.  The lookup name indicates a fully-qualified name,
     68   1.8  christos      and only matches symbol search names in the specified
     69   1.8  christos      namespace/module/package.  */
     70   1.8  christos   FULL,
     71   1.8  christos 
     72   1.8  christos   /* Search name matching.  This is like FULL, but the search name did
     73   1.8  christos      not come from the user; instead it is already a search name
     74   1.9  christos      retrieved from a search_name () call.
     75   1.8  christos      For Ada, this avoids re-encoding an already-encoded search name
     76   1.8  christos      (which would potentially incorrectly lowercase letters in the
     77   1.8  christos      linkage/search name that should remain uppercase).  For C++, it
     78   1.8  christos      avoids trying to demangle a name we already know is
     79   1.8  christos      demangled.  */
     80   1.8  christos   SEARCH_NAME,
     81   1.8  christos 
     82   1.8  christos   /* Expression matching.  The same as FULL matching in most
     83   1.8  christos      languages.  The same as WILD matching in Ada.  */
     84   1.8  christos   EXPRESSION,
     85   1.8  christos };
     86   1.8  christos 
     87   1.8  christos /* Hash the given symbol search name according to LANGUAGE's
     88   1.8  christos    rules.  */
     89   1.8  christos extern unsigned int search_name_hash (enum language language,
     90   1.8  christos 				      const char *search_name);
     91   1.8  christos 
     92   1.8  christos /* Ada-specific bits of a lookup_name_info object.  This is lazily
     93   1.8  christos    constructed on demand.  */
     94   1.8  christos 
     95   1.8  christos class ada_lookup_name_info final
     96   1.8  christos {
     97   1.8  christos  public:
     98   1.8  christos   /* Construct.  */
     99   1.8  christos   explicit ada_lookup_name_info (const lookup_name_info &lookup_name);
    100   1.8  christos 
    101   1.8  christos   /* Compare SYMBOL_SEARCH_NAME with our lookup name, using MATCH_TYPE
    102   1.8  christos      as name match type.  Returns true if there's a match, false
    103   1.8  christos      otherwise.  If non-NULL, store the matching results in MATCH.  */
    104   1.8  christos   bool matches (const char *symbol_search_name,
    105   1.8  christos 		symbol_name_match_type match_type,
    106   1.8  christos 		completion_match_result *comp_match_res) const;
    107   1.8  christos 
    108   1.8  christos   /* The Ada-encoded lookup name.  */
    109   1.8  christos   const std::string &lookup_name () const
    110   1.8  christos   { return m_encoded_name; }
    111   1.8  christos 
    112   1.8  christos   /* Return true if we're supposed to be doing a wild match look
    113   1.8  christos      up.  */
    114   1.8  christos   bool wild_match_p () const
    115   1.8  christos   { return m_wild_match_p; }
    116   1.8  christos 
    117   1.8  christos   /* Return true if we're looking up a name inside package
    118   1.8  christos      Standard.  */
    119   1.8  christos   bool standard_p () const
    120   1.8  christos   { return m_standard_p; }
    121   1.8  christos 
    122   1.8  christos   /* Return true if doing a verbatim match.  */
    123   1.8  christos   bool verbatim_p () const
    124   1.8  christos   { return m_verbatim_p; }
    125   1.8  christos 
    126  1.10  christos   /* A wrapper for ::split_name that handles some Ada-specific
    127  1.10  christos      peculiarities.  */
    128  1.10  christos   std::vector<gdb::string_view> split_name () const
    129  1.10  christos   {
    130  1.10  christos     if (m_verbatim_p || m_standard_p)
    131  1.10  christos       {
    132  1.10  christos 	std::vector<gdb::string_view> result;
    133  1.10  christos 	if (m_standard_p)
    134  1.10  christos 	  result.emplace_back ("standard");
    135  1.10  christos 	result.emplace_back (m_encoded_name);
    136  1.10  christos 	return result;
    137  1.10  christos       }
    138  1.10  christos     return ::split_name (m_encoded_name.c_str (), split_style::UNDERSCORE);
    139  1.10  christos   }
    140  1.10  christos 
    141   1.8  christos private:
    142   1.8  christos   /* The Ada-encoded lookup name.  */
    143   1.8  christos   std::string m_encoded_name;
    144   1.8  christos 
    145   1.8  christos   /* Whether the user-provided lookup name was Ada encoded.  If so,
    146   1.8  christos      then return encoded names in the 'matches' method's 'completion
    147   1.8  christos      match result' output.  */
    148   1.8  christos   bool m_encoded_p : 1;
    149   1.8  christos 
    150   1.8  christos   /* True if really doing wild matching.  Even if the user requests
    151   1.8  christos      wild matching, some cases require full matching.  */
    152   1.8  christos   bool m_wild_match_p : 1;
    153   1.8  christos 
    154   1.8  christos   /* True if doing a verbatim match.  This is true if the decoded
    155   1.8  christos      version of the symbol name is wrapped in '<'/'>'.  This is an
    156   1.8  christos      escape hatch users can use to look up symbols the Ada encoding
    157   1.8  christos      does not understand.  */
    158   1.8  christos   bool m_verbatim_p : 1;
    159   1.8  christos 
    160   1.8  christos    /* True if the user specified a symbol name that is inside package
    161   1.8  christos       Standard.  Symbol names inside package Standard are handled
    162   1.8  christos       specially.  We always do a non-wild match of the symbol name
    163   1.8  christos       without the "standard__" prefix, and only search static and
    164   1.8  christos       global symbols.  This was primarily introduced in order to allow
    165   1.8  christos       the user to specifically access the standard exceptions using,
    166   1.8  christos       for instance, Standard.Constraint_Error when Constraint_Error is
    167   1.8  christos       ambiguous (due to the user defining its own Constraint_Error
    168   1.8  christos       entity inside its program).  */
    169   1.8  christos   bool m_standard_p : 1;
    170   1.8  christos };
    171   1.8  christos 
    172   1.8  christos /* Language-specific bits of a lookup_name_info object, for languages
    173   1.8  christos    that do name searching using demangled names (C++/D/Go).  This is
    174   1.8  christos    lazily constructed on demand.  */
    175   1.8  christos 
    176   1.8  christos struct demangle_for_lookup_info final
    177   1.8  christos {
    178   1.8  christos public:
    179   1.8  christos   demangle_for_lookup_info (const lookup_name_info &lookup_name,
    180   1.8  christos 			    language lang);
    181   1.8  christos 
    182   1.8  christos   /* The demangled lookup name.  */
    183   1.8  christos   const std::string &lookup_name () const
    184   1.8  christos   { return m_demangled_name; }
    185   1.8  christos 
    186   1.8  christos private:
    187   1.8  christos   /* The demangled lookup name.  */
    188   1.8  christos   std::string m_demangled_name;
    189   1.8  christos };
    190   1.8  christos 
    191   1.8  christos /* Object that aggregates all information related to a symbol lookup
    192   1.8  christos    name.  I.e., the name that is matched against the symbol's search
    193   1.8  christos    name.  Caches per-language information so that it doesn't require
    194   1.8  christos    recomputing it for every symbol comparison, like for example the
    195   1.8  christos    Ada encoded name and the symbol's name hash for a given language.
    196   1.8  christos    The object is conceptually immutable once constructed, and thus has
    197   1.8  christos    no setters.  This is to prevent some code path from tweaking some
    198   1.8  christos    property of the lookup name for some local reason and accidentally
    199   1.8  christos    altering the results of any continuing search(es).
    200   1.8  christos    lookup_name_info objects are generally passed around as a const
    201   1.8  christos    reference to reinforce that.  (They're not passed around by value
    202   1.8  christos    because they're not small.)  */
    203   1.8  christos class lookup_name_info final
    204   1.8  christos {
    205   1.8  christos  public:
    206   1.9  christos   /* We delete this overload so that the callers are required to
    207   1.9  christos      explicitly handle the lifetime of the name.  */
    208   1.9  christos   lookup_name_info (std::string &&name,
    209   1.9  christos 		    symbol_name_match_type match_type,
    210   1.9  christos 		    bool completion_mode = false,
    211   1.9  christos 		    bool ignore_parameters = false) = delete;
    212   1.9  christos 
    213   1.9  christos   /* This overload requires that NAME have a lifetime at least as long
    214   1.9  christos      as the lifetime of this object.  */
    215   1.9  christos   lookup_name_info (const std::string &name,
    216   1.9  christos 		    symbol_name_match_type match_type,
    217   1.9  christos 		    bool completion_mode = false,
    218   1.9  christos 		    bool ignore_parameters = false)
    219   1.9  christos     : m_match_type (match_type),
    220   1.9  christos       m_completion_mode (completion_mode),
    221   1.9  christos       m_ignore_parameters (ignore_parameters),
    222   1.9  christos       m_name (name)
    223   1.9  christos   {}
    224   1.9  christos 
    225   1.9  christos   /* This overload requires that NAME have a lifetime at least as long
    226   1.9  christos      as the lifetime of this object.  */
    227   1.9  christos   lookup_name_info (const char *name,
    228   1.8  christos 		    symbol_name_match_type match_type,
    229   1.8  christos 		    bool completion_mode = false,
    230   1.8  christos 		    bool ignore_parameters = false)
    231   1.8  christos     : m_match_type (match_type),
    232   1.8  christos       m_completion_mode (completion_mode),
    233   1.8  christos       m_ignore_parameters (ignore_parameters),
    234   1.9  christos       m_name (name)
    235   1.8  christos   {}
    236   1.8  christos 
    237   1.8  christos   /* Getters.  See description of each corresponding field.  */
    238   1.8  christos   symbol_name_match_type match_type () const { return m_match_type; }
    239   1.8  christos   bool completion_mode () const { return m_completion_mode; }
    240   1.9  christos   gdb::string_view name () const { return m_name; }
    241   1.8  christos   const bool ignore_parameters () const { return m_ignore_parameters; }
    242   1.8  christos 
    243   1.9  christos   /* Like the "name" method but guarantees that the returned string is
    244   1.9  christos      \0-terminated.  */
    245   1.9  christos   const char *c_str () const
    246   1.9  christos   {
    247   1.9  christos     /* Actually this is always guaranteed due to how the class is
    248   1.9  christos        constructed.  */
    249   1.9  christos     return m_name.data ();
    250   1.9  christos   }
    251   1.9  christos 
    252   1.8  christos   /* Return a version of this lookup name that is usable with
    253   1.8  christos      comparisons against symbols have no parameter info, such as
    254   1.8  christos      psymbols and GDB index symbols.  */
    255   1.8  christos   lookup_name_info make_ignore_params () const
    256   1.8  christos   {
    257   1.9  christos     return lookup_name_info (c_str (), m_match_type, m_completion_mode,
    258   1.8  christos 			     true /* ignore params */);
    259   1.8  christos   }
    260   1.8  christos 
    261   1.8  christos   /* Get the search name hash for searches in language LANG.  */
    262   1.8  christos   unsigned int search_name_hash (language lang) const
    263   1.8  christos   {
    264   1.8  christos     /* Only compute each language's hash once.  */
    265   1.8  christos     if (!m_demangled_hashes_p[lang])
    266   1.8  christos       {
    267   1.8  christos 	m_demangled_hashes[lang]
    268   1.9  christos 	  = ::search_name_hash (lang, language_lookup_name (lang));
    269   1.8  christos 	m_demangled_hashes_p[lang] = true;
    270   1.8  christos       }
    271   1.8  christos     return m_demangled_hashes[lang];
    272   1.8  christos   }
    273   1.8  christos 
    274   1.8  christos   /* Get the search name for searches in language LANG.  */
    275   1.9  christos   const char *language_lookup_name (language lang) const
    276   1.8  christos   {
    277   1.8  christos     switch (lang)
    278   1.8  christos       {
    279   1.8  christos       case language_ada:
    280   1.9  christos 	return ada ().lookup_name ().c_str ();
    281   1.8  christos       case language_cplus:
    282   1.9  christos 	return cplus ().lookup_name ().c_str ();
    283   1.8  christos       case language_d:
    284   1.9  christos 	return d ().lookup_name ().c_str ();
    285   1.8  christos       case language_go:
    286   1.9  christos 	return go ().lookup_name ().c_str ();
    287   1.8  christos       default:
    288   1.9  christos 	return m_name.data ();
    289   1.8  christos       }
    290   1.8  christos   }
    291   1.8  christos 
    292  1.10  christos   /* A wrapper for ::split_name (see split-name.h) that splits this
    293  1.10  christos      name, and that handles any language-specific peculiarities.  */
    294  1.10  christos   std::vector<gdb::string_view> split_name (language lang) const
    295  1.10  christos   {
    296  1.10  christos     if (lang == language_ada)
    297  1.10  christos       return ada ().split_name ();
    298  1.10  christos     split_style style = split_style::NONE;
    299  1.10  christos     switch (lang)
    300  1.10  christos       {
    301  1.10  christos       case language_cplus:
    302  1.10  christos       case language_rust:
    303  1.10  christos 	style = split_style::CXX;
    304  1.10  christos 	break;
    305  1.10  christos       case language_d:
    306  1.10  christos       case language_go:
    307  1.10  christos 	style = split_style::DOT;
    308  1.10  christos 	break;
    309  1.10  christos       }
    310  1.10  christos     return ::split_name (language_lookup_name (lang), style);
    311  1.10  christos   }
    312  1.10  christos 
    313   1.8  christos   /* Get the Ada-specific lookup info.  */
    314   1.8  christos   const ada_lookup_name_info &ada () const
    315   1.8  christos   {
    316   1.8  christos     maybe_init (m_ada);
    317   1.8  christos     return *m_ada;
    318   1.8  christos   }
    319   1.8  christos 
    320   1.8  christos   /* Get the C++-specific lookup info.  */
    321   1.8  christos   const demangle_for_lookup_info &cplus () const
    322   1.8  christos   {
    323   1.8  christos     maybe_init (m_cplus, language_cplus);
    324   1.8  christos     return *m_cplus;
    325   1.8  christos   }
    326   1.8  christos 
    327   1.8  christos   /* Get the D-specific lookup info.  */
    328   1.8  christos   const demangle_for_lookup_info &d () const
    329   1.8  christos   {
    330   1.8  christos     maybe_init (m_d, language_d);
    331   1.8  christos     return *m_d;
    332   1.8  christos   }
    333   1.8  christos 
    334   1.8  christos   /* Get the Go-specific lookup info.  */
    335   1.8  christos   const demangle_for_lookup_info &go () const
    336   1.8  christos   {
    337   1.8  christos     maybe_init (m_go, language_go);
    338   1.8  christos     return *m_go;
    339   1.8  christos   }
    340   1.8  christos 
    341   1.8  christos   /* Get a reference to a lookup_name_info object that matches any
    342   1.8  christos      symbol name.  */
    343   1.8  christos   static const lookup_name_info &match_any ();
    344   1.8  christos 
    345   1.8  christos private:
    346   1.8  christos   /* Initialize FIELD, if not initialized yet.  */
    347   1.8  christos   template<typename Field, typename... Args>
    348   1.8  christos   void maybe_init (Field &field, Args&&... args) const
    349   1.8  christos   {
    350   1.8  christos     if (!field)
    351   1.8  christos       field.emplace (*this, std::forward<Args> (args)...);
    352   1.8  christos   }
    353   1.8  christos 
    354   1.8  christos   /* The lookup info as passed to the ctor.  */
    355   1.8  christos   symbol_name_match_type m_match_type;
    356   1.8  christos   bool m_completion_mode;
    357   1.8  christos   bool m_ignore_parameters;
    358   1.9  christos   gdb::string_view m_name;
    359   1.8  christos 
    360   1.8  christos   /* Language-specific info.  These fields are filled lazily the first
    361   1.8  christos      time a lookup is done in the corresponding language.  They're
    362   1.8  christos      mutable because lookup_name_info objects are typically passed
    363   1.8  christos      around by const reference (see intro), and they're conceptually
    364   1.8  christos      "cache" that can always be reconstructed from the non-mutable
    365   1.8  christos      fields.  */
    366   1.8  christos   mutable gdb::optional<ada_lookup_name_info> m_ada;
    367   1.8  christos   mutable gdb::optional<demangle_for_lookup_info> m_cplus;
    368   1.8  christos   mutable gdb::optional<demangle_for_lookup_info> m_d;
    369   1.8  christos   mutable gdb::optional<demangle_for_lookup_info> m_go;
    370   1.8  christos 
    371   1.8  christos   /* The demangled hashes.  Stored in an array with one entry for each
    372   1.8  christos      possible language.  The second array records whether we've
    373   1.8  christos      already computed the each language's hash.  (These are separate
    374   1.8  christos      arrays instead of a single array of optional<unsigned> to avoid
    375   1.8  christos      alignment padding).  */
    376   1.8  christos   mutable std::array<unsigned int, nr_languages> m_demangled_hashes;
    377   1.8  christos   mutable std::array<bool, nr_languages> m_demangled_hashes_p {};
    378   1.8  christos };
    379   1.8  christos 
    380   1.8  christos /* Comparison function for completion symbol lookup.
    381   1.8  christos 
    382   1.8  christos    Returns true if the symbol name matches against LOOKUP_NAME.
    383   1.8  christos 
    384   1.8  christos    SYMBOL_SEARCH_NAME should be a symbol's "search" name.
    385   1.8  christos 
    386   1.8  christos    On success and if non-NULL, COMP_MATCH_RES->match is set to point
    387   1.8  christos    to the symbol name as should be presented to the user as a
    388   1.8  christos    completion match list element.  In most languages, this is the same
    389   1.8  christos    as the symbol's search name, but in some, like Ada, the display
    390   1.8  christos    name is dynamically computed within the comparison routine.
    391   1.8  christos 
    392   1.8  christos    Also, on success and if non-NULL, COMP_MATCH_RES->match_for_lcd
    393   1.8  christos    points the part of SYMBOL_SEARCH_NAME that was considered to match
    394   1.8  christos    LOOKUP_NAME.  E.g., in C++, in linespec/wild mode, if the symbol is
    395   1.8  christos    "foo::function()" and LOOKUP_NAME is "function(", MATCH_FOR_LCD
    396   1.8  christos    points to "function()" inside SYMBOL_SEARCH_NAME.  */
    397   1.8  christos typedef bool (symbol_name_matcher_ftype)
    398   1.8  christos   (const char *symbol_search_name,
    399   1.8  christos    const lookup_name_info &lookup_name,
    400   1.8  christos    completion_match_result *comp_match_res);
    401   1.1  christos 
    402   1.1  christos /* Some of the structures in this file are space critical.
    403   1.1  christos    The space-critical structures are:
    404   1.1  christos 
    405   1.1  christos      struct general_symbol_info
    406   1.1  christos      struct symbol
    407   1.1  christos      struct partial_symbol
    408   1.1  christos 
    409   1.1  christos    These structures are laid out to encourage good packing.
    410   1.1  christos    They use ENUM_BITFIELD and short int fields, and they order the
    411   1.1  christos    structure members so that fields less than a word are next
    412   1.1  christos    to each other so they can be packed together.  */
    413   1.1  christos 
    414   1.1  christos /* Rearranged: used ENUM_BITFIELD and rearranged field order in
    415   1.1  christos    all the space critical structures (plus struct minimal_symbol).
    416   1.1  christos    Memory usage dropped from 99360768 bytes to 90001408 bytes.
    417   1.1  christos    I measured this with before-and-after tests of
    418   1.1  christos    "HEAD-old-gdb -readnow HEAD-old-gdb" and
    419   1.1  christos    "HEAD-new-gdb -readnow HEAD-old-gdb" on native i686-pc-linux-gnu,
    420   1.1  christos    red hat linux 8, with LD_LIBRARY_PATH=/usr/lib/debug,
    421   1.1  christos    typing "maint space 1" at the first command prompt.
    422   1.1  christos 
    423   1.1  christos    Here is another measurement (from andrew c):
    424   1.1  christos      # no /usr/lib/debug, just plain glibc, like a normal user
    425   1.1  christos      gdb HEAD-old-gdb
    426   1.1  christos      (gdb) break internal_error
    427   1.1  christos      (gdb) run
    428   1.1  christos      (gdb) maint internal-error
    429   1.1  christos      (gdb) backtrace
    430   1.1  christos      (gdb) maint space 1
    431   1.1  christos 
    432   1.1  christos    gdb gdb_6_0_branch  2003-08-19  space used: 8896512
    433   1.1  christos    gdb HEAD            2003-08-19  space used: 8904704
    434   1.1  christos    gdb HEAD            2003-08-21  space used: 8396800 (+symtab.h)
    435   1.1  christos    gdb HEAD            2003-08-21  space used: 8265728 (+gdbtypes.h)
    436   1.1  christos 
    437   1.1  christos    The third line shows the savings from the optimizations in symtab.h.
    438   1.1  christos    The fourth line shows the savings from the optimizations in
    439   1.1  christos    gdbtypes.h.  Both optimizations are in gdb HEAD now.
    440   1.1  christos 
    441   1.1  christos    --chastain 2003-08-21  */
    442   1.1  christos 
    443   1.1  christos /* Define a structure for the information that is common to all symbol types,
    444   1.1  christos    including minimal symbols, partial symbols, and full symbols.  In a
    445   1.1  christos    multilanguage environment, some language specific information may need to
    446   1.1  christos    be recorded along with each symbol.  */
    447   1.1  christos 
    448   1.1  christos /* This structure is space critical.  See space comments at the top.  */
    449   1.1  christos 
    450   1.1  christos struct general_symbol_info
    451   1.1  christos {
    452   1.9  christos   /* Short version as to when to use which name accessor:
    453   1.9  christos      Use natural_name () to refer to the name of the symbol in the original
    454   1.9  christos      source code.  Use linkage_name () if you want to know what the linker
    455   1.9  christos      thinks the symbol's name is.  Use print_name () for output.  Use
    456   1.9  christos      demangled_name () if you specifically need to know whether natural_name ()
    457   1.9  christos      and linkage_name () are different.  */
    458   1.9  christos 
    459   1.9  christos   const char *linkage_name () const
    460   1.9  christos   { return m_name; }
    461   1.9  christos 
    462   1.9  christos   /* Return SYMBOL's "natural" name, i.e. the name that it was called in
    463   1.9  christos      the original source code.  In languages like C++ where symbols may
    464   1.9  christos      be mangled for ease of manipulation by the linker, this is the
    465   1.9  christos      demangled name.  */
    466   1.9  christos   const char *natural_name () const;
    467   1.9  christos 
    468   1.9  christos   /* Returns a version of the name of a symbol that is
    469   1.9  christos      suitable for output.  In C++ this is the "demangled" form of the
    470   1.9  christos      name if demangle is on and the "mangled" form of the name if
    471   1.9  christos      demangle is off.  In other languages this is just the symbol name.
    472   1.9  christos      The result should never be NULL.  Don't use this for internal
    473   1.9  christos      purposes (e.g. storing in a hashtable): it's only suitable for output.  */
    474   1.9  christos   const char *print_name () const
    475   1.9  christos   { return demangle ? natural_name () : linkage_name (); }
    476   1.9  christos 
    477   1.9  christos   /* Return the demangled name for a symbol based on the language for
    478   1.9  christos      that symbol.  If no demangled name exists, return NULL.  */
    479   1.9  christos   const char *demangled_name () const;
    480   1.9  christos 
    481   1.9  christos   /* Returns the name to be used when sorting and searching symbols.
    482   1.9  christos      In C++, we search for the demangled form of a name,
    483   1.9  christos      and so sort symbols accordingly.  In Ada, however, we search by mangled
    484   1.9  christos      name.  If there is no distinct demangled name, then this
    485   1.9  christos      returns the same value (same pointer) as linkage_name ().  */
    486   1.9  christos   const char *search_name () const;
    487   1.9  christos 
    488   1.9  christos   /* Set just the linkage name of a symbol; do not try to demangle
    489   1.9  christos      it.  Used for constructs which do not have a mangled name,
    490   1.9  christos      e.g. struct tags.  Unlike compute_and_set_names, linkage_name must
    491   1.9  christos      be terminated and either already on the objfile's obstack or
    492   1.9  christos      permanently allocated.  */
    493   1.9  christos   void set_linkage_name (const char *linkage_name)
    494   1.9  christos   { m_name = linkage_name; }
    495   1.9  christos 
    496   1.9  christos   /* Set the demangled name of this symbol to NAME.  NAME must be
    497   1.9  christos      already correctly allocated.  If the symbol's language is Ada,
    498   1.9  christos      then the name is ignored and the obstack is set.  */
    499   1.9  christos   void set_demangled_name (const char *name, struct obstack *obstack);
    500   1.9  christos 
    501   1.9  christos   enum language language () const
    502   1.9  christos   { return m_language; }
    503   1.9  christos 
    504   1.9  christos   /* Initializes the language dependent portion of a symbol
    505   1.9  christos      depending upon the language for the symbol.  */
    506   1.9  christos   void set_language (enum language language, struct obstack *obstack);
    507   1.9  christos 
    508   1.9  christos   /* Set the linkage and natural names of a symbol, by demangling
    509   1.9  christos      the linkage name.  If linkage_name may not be nullterminated,
    510   1.9  christos      copy_name must be set to true.  */
    511   1.9  christos   void compute_and_set_names (gdb::string_view linkage_name, bool copy_name,
    512   1.9  christos 			      struct objfile_per_bfd_storage *per_bfd,
    513   1.9  christos 			      gdb::optional<hashval_t> hash
    514  1.10  christos 				= gdb::optional<hashval_t> ());
    515  1.10  christos 
    516  1.10  christos   CORE_ADDR value_address () const
    517  1.10  christos   {
    518  1.10  christos     return m_value.address;
    519  1.10  christos   }
    520  1.10  christos 
    521  1.10  christos   void set_value_address (CORE_ADDR address)
    522  1.10  christos   {
    523  1.10  christos     m_value.address = address;
    524  1.10  christos   }
    525   1.9  christos 
    526   1.1  christos   /* Name of the symbol.  This is a required field.  Storage for the
    527   1.1  christos      name is allocated on the objfile_obstack for the associated
    528   1.1  christos      objfile.  For languages like C++ that make a distinction between
    529   1.1  christos      the mangled name and demangled name, this is the mangled
    530   1.1  christos      name.  */
    531   1.1  christos 
    532   1.9  christos   const char *m_name;
    533   1.1  christos 
    534   1.1  christos   /* Value of the symbol.  Which member of this union to use, and what
    535   1.1  christos      it means, depends on what kind of symbol this is and its
    536   1.1  christos      SYMBOL_CLASS.  See comments there for more details.  All of these
    537   1.1  christos      are in host byte order (though what they point to might be in
    538   1.1  christos      target byte order, e.g. LOC_CONST_BYTES).  */
    539   1.1  christos 
    540   1.1  christos   union
    541   1.1  christos   {
    542   1.1  christos     LONGEST ivalue;
    543   1.1  christos 
    544   1.3  christos     const struct block *block;
    545   1.1  christos 
    546   1.1  christos     const gdb_byte *bytes;
    547   1.1  christos 
    548   1.1  christos     CORE_ADDR address;
    549   1.1  christos 
    550   1.1  christos     /* A common block.  Used with LOC_COMMON_BLOCK.  */
    551   1.1  christos 
    552   1.3  christos     const struct common_block *common_block;
    553   1.1  christos 
    554   1.1  christos     /* For opaque typedef struct chain.  */
    555   1.1  christos 
    556   1.1  christos     struct symbol *chain;
    557   1.1  christos   }
    558  1.10  christos   m_value;
    559   1.1  christos 
    560   1.1  christos   /* Since one and only one language can apply, wrap the language specific
    561   1.1  christos      information inside a union.  */
    562   1.1  christos 
    563   1.1  christos   union
    564   1.1  christos   {
    565   1.1  christos     /* A pointer to an obstack that can be used for storage associated
    566   1.1  christos        with this symbol.  This is only used by Ada, and only when the
    567   1.1  christos        'ada_mangled' field is zero.  */
    568   1.1  christos     struct obstack *obstack;
    569   1.1  christos 
    570   1.1  christos     /* This is used by languages which wish to store a demangled name.
    571   1.7  christos        currently used by Ada, C++, and Objective C.  */
    572   1.6  christos     const char *demangled_name;
    573   1.1  christos   }
    574   1.1  christos   language_specific;
    575   1.1  christos 
    576   1.1  christos   /* Record the source code language that applies to this symbol.
    577   1.1  christos      This is used to select one of the fields from the language specific
    578   1.1  christos      union above.  */
    579   1.1  christos 
    580   1.9  christos   ENUM_BITFIELD(language) m_language : LANGUAGE_BITS;
    581   1.1  christos 
    582   1.6  christos   /* This is only used by Ada.  If set, then the 'demangled_name' field
    583   1.1  christos      of language_specific is valid.  Otherwise, the 'obstack' field is
    584   1.1  christos      valid.  */
    585   1.1  christos   unsigned int ada_mangled : 1;
    586   1.1  christos 
    587   1.1  christos   /* Which section is this symbol in?  This is an index into
    588   1.1  christos      section_offsets for this objfile.  Negative means that the symbol
    589   1.1  christos      does not get relocated relative to a section.  */
    590   1.1  christos 
    591  1.10  christos   short m_section;
    592  1.10  christos 
    593  1.10  christos   /* Set the index into the obj_section list (within the containing
    594  1.10  christos      objfile) for the section that contains this symbol.  See M_SECTION
    595  1.10  christos      for more details.  */
    596  1.10  christos 
    597  1.10  christos   void set_section_index (short idx)
    598  1.10  christos   { m_section = idx; }
    599  1.10  christos 
    600  1.10  christos   /* Return the index into the obj_section list (within the containing
    601  1.10  christos      objfile) for the section that contains this symbol.  See M_SECTION
    602  1.10  christos      for more details.  */
    603  1.10  christos 
    604  1.10  christos   short section_index () const
    605  1.10  christos   { return m_section; }
    606  1.10  christos 
    607  1.10  christos   /* Return the obj_section from OBJFILE for this symbol.  The symbol
    608  1.10  christos      returned is based on the SECTION member variable, and can be nullptr
    609  1.10  christos      if SECTION is negative.  */
    610  1.10  christos 
    611  1.10  christos   struct obj_section *obj_section (const struct objfile *objfile) const;
    612   1.1  christos };
    613   1.1  christos 
    614   1.1  christos extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
    615   1.1  christos 
    616   1.9  christos /* Return the address of SYM.  The MAYBE_COPIED flag must be set on
    617   1.9  christos    SYM.  If SYM appears in the main program's minimal symbols, then
    618   1.9  christos    that minsym's address is returned; otherwise, SYM's address is
    619   1.9  christos    returned.  This should generally only be used via the
    620   1.9  christos    SYMBOL_VALUE_ADDRESS macro.  */
    621   1.9  christos 
    622   1.9  christos extern CORE_ADDR get_symbol_address (const struct symbol *sym);
    623   1.9  christos 
    624   1.9  christos /* Try to determine the demangled name for a symbol, based on the
    625   1.9  christos    language of that symbol.  If the language is set to language_auto,
    626   1.9  christos    it will attempt to find any demangling algorithm that works and
    627   1.9  christos    then set the language appropriately.  The returned name is allocated
    628   1.9  christos    by the demangler and should be xfree'd.  */
    629   1.9  christos 
    630  1.10  christos extern gdb::unique_xmalloc_ptr<char> symbol_find_demangled_name
    631  1.10  christos      (struct general_symbol_info *gsymbol, const char *mangled);
    632   1.1  christos 
    633  1.10  christos /* Return true if NAME matches the "search" name of GSYMBOL, according
    634   1.8  christos    to the symbol's language.  */
    635   1.8  christos extern bool symbol_matches_search_name
    636   1.8  christos   (const struct general_symbol_info *gsymbol,
    637   1.8  christos    const lookup_name_info &name);
    638   1.8  christos 
    639   1.8  christos /* Compute the hash of the given symbol search name of a symbol of
    640   1.8  christos    language LANGUAGE.  */
    641   1.8  christos extern unsigned int search_name_hash (enum language language,
    642   1.8  christos 				      const char *search_name);
    643   1.1  christos 
    644   1.1  christos /* Classification types for a minimal symbol.  These should be taken as
    645   1.1  christos    "advisory only", since if gdb can't easily figure out a
    646   1.1  christos    classification it simply selects mst_unknown.  It may also have to
    647   1.1  christos    guess when it can't figure out which is a better match between two
    648   1.1  christos    types (mst_data versus mst_bss) for example.  Since the minimal
    649   1.1  christos    symbol info is sometimes derived from the BFD library's view of a
    650   1.1  christos    file, we need to live with what information bfd supplies.  */
    651   1.1  christos 
    652   1.1  christos enum minimal_symbol_type
    653   1.1  christos {
    654   1.1  christos   mst_unknown = 0,		/* Unknown type, the default */
    655   1.1  christos   mst_text,			/* Generally executable instructions */
    656   1.8  christos 
    657   1.8  christos   /* A GNU ifunc symbol, in the .text section.  GDB uses to know
    658   1.8  christos      whether the user is setting a breakpoint on a GNU ifunc function,
    659   1.8  christos      and thus GDB needs to actually set the breakpoint on the target
    660   1.8  christos      function.  It is also used to know whether the program stepped
    661   1.8  christos      into an ifunc resolver -- the resolver may get a separate
    662   1.8  christos      symbol/alias under a different name, but it'll have the same
    663   1.8  christos      address as the ifunc symbol.  */
    664   1.8  christos   mst_text_gnu_ifunc,           /* Executable code returning address
    665   1.8  christos 				   of executable code */
    666   1.8  christos 
    667   1.8  christos   /* A GNU ifunc function descriptor symbol, in a data section
    668   1.8  christos      (typically ".opd").  Seen on architectures that use function
    669   1.8  christos      descriptors, like PPC64/ELFv1.  In this case, this symbol's value
    670   1.8  christos      is the address of the descriptor.  There'll be a corresponding
    671   1.8  christos      mst_text_gnu_ifunc synthetic symbol for the text/entry
    672   1.8  christos      address.  */
    673   1.8  christos   mst_data_gnu_ifunc,		/* Executable code returning address
    674   1.1  christos 				   of executable code */
    675   1.8  christos 
    676   1.1  christos   mst_slot_got_plt,		/* GOT entries for .plt sections */
    677   1.1  christos   mst_data,			/* Generally initialized data */
    678   1.1  christos   mst_bss,			/* Generally uninitialized data */
    679   1.1  christos   mst_abs,			/* Generally absolute (nonrelocatable) */
    680   1.1  christos   /* GDB uses mst_solib_trampoline for the start address of a shared
    681   1.1  christos      library trampoline entry.  Breakpoints for shared library functions
    682   1.1  christos      are put there if the shared library is not yet loaded.
    683   1.1  christos      After the shared library is loaded, lookup_minimal_symbol will
    684   1.1  christos      prefer the minimal symbol from the shared library (usually
    685   1.1  christos      a mst_text symbol) over the mst_solib_trampoline symbol, and the
    686   1.1  christos      breakpoints will be moved to their true address in the shared
    687   1.1  christos      library via breakpoint_re_set.  */
    688   1.1  christos   mst_solib_trampoline,		/* Shared library trampoline code */
    689   1.1  christos   /* For the mst_file* types, the names are only guaranteed to be unique
    690   1.1  christos      within a given .o file.  */
    691   1.1  christos   mst_file_text,		/* Static version of mst_text */
    692   1.1  christos   mst_file_data,		/* Static version of mst_data */
    693   1.6  christos   mst_file_bss,			/* Static version of mst_bss */
    694   1.6  christos   nr_minsym_types
    695   1.1  christos };
    696   1.1  christos 
    697   1.6  christos /* The number of enum minimal_symbol_type values, with some padding for
    698   1.6  christos    reasonable growth.  */
    699   1.6  christos #define MINSYM_TYPE_BITS 4
    700   1.6  christos gdb_static_assert (nr_minsym_types <= (1 << MINSYM_TYPE_BITS));
    701   1.6  christos 
    702  1.10  christos /* Return the address of MINSYM, which comes from OBJF.  The
    703  1.10  christos    MAYBE_COPIED flag must be set on MINSYM.  If MINSYM appears in the
    704  1.10  christos    main program's minimal symbols, then that minsym's address is
    705  1.10  christos    returned; otherwise, MINSYM's address is returned.  This should
    706  1.10  christos    generally only be used via the MSYMBOL_VALUE_ADDRESS macro.  */
    707  1.10  christos 
    708  1.10  christos extern CORE_ADDR get_msymbol_address (struct objfile *objf,
    709  1.10  christos 				      const struct minimal_symbol *minsym);
    710  1.10  christos 
    711   1.1  christos /* Define a simple structure used to hold some very basic information about
    712   1.1  christos    all defined global symbols (text, data, bss, abs, etc).  The only required
    713   1.1  christos    information is the general_symbol_info.
    714   1.1  christos 
    715   1.1  christos    In many cases, even if a file was compiled with no special options for
    716   1.1  christos    debugging at all, as long as was not stripped it will contain sufficient
    717   1.1  christos    information to build a useful minimal symbol table using this structure.
    718   1.1  christos    Even when a file contains enough debugging information to build a full
    719   1.1  christos    symbol table, these minimal symbols are still useful for quickly mapping
    720   1.1  christos    between names and addresses, and vice versa.  They are also sometimes
    721   1.1  christos    used to figure out what full symbol table entries need to be read in.  */
    722   1.1  christos 
    723   1.9  christos struct minimal_symbol : public general_symbol_info
    724   1.1  christos {
    725  1.10  christos   LONGEST value_longest () const
    726  1.10  christos   {
    727  1.10  christos     return m_value.ivalue;
    728  1.10  christos   }
    729  1.10  christos 
    730  1.10  christos   /* The relocated address of the minimal symbol, using the section
    731  1.10  christos      offsets from OBJFILE.  */
    732  1.10  christos   CORE_ADDR value_address (objfile *objfile) const;
    733  1.10  christos 
    734  1.10  christos   /* The unrelocated address of the minimal symbol.  */
    735  1.10  christos   CORE_ADDR value_raw_address () const
    736  1.10  christos   {
    737  1.10  christos     return m_value.address;
    738  1.10  christos   }
    739  1.10  christos 
    740  1.10  christos   /* Return this minimal symbol's type.  */
    741  1.10  christos 
    742  1.10  christos   minimal_symbol_type type () const
    743  1.10  christos   {
    744  1.10  christos     return m_type;
    745  1.10  christos   }
    746  1.10  christos 
    747  1.10  christos   /* Set this minimal symbol's type.  */
    748  1.10  christos 
    749  1.10  christos   void set_type (minimal_symbol_type type)
    750  1.10  christos   {
    751  1.10  christos     m_type = type;
    752  1.10  christos   }
    753  1.10  christos 
    754  1.10  christos   /* Return this minimal symbol's size.  */
    755  1.10  christos 
    756  1.10  christos   unsigned long size () const
    757  1.10  christos   {
    758  1.10  christos     return m_size;
    759  1.10  christos   }
    760  1.10  christos 
    761  1.10  christos   /* Set this minimal symbol's size.  */
    762  1.10  christos 
    763  1.10  christos   void set_size (unsigned long size)
    764  1.10  christos   {
    765  1.10  christos     m_size = size;
    766  1.10  christos     m_has_size = 1;
    767  1.10  christos   }
    768  1.10  christos 
    769  1.10  christos   /* Return true if this minimal symbol's size is known.  */
    770  1.10  christos 
    771  1.10  christos   bool has_size () const
    772  1.10  christos   {
    773  1.10  christos     return m_has_size;
    774  1.10  christos   }
    775  1.10  christos 
    776  1.10  christos   /* Return this minimal symbol's first target-specific flag.  */
    777  1.10  christos 
    778  1.10  christos   bool target_flag_1 () const
    779  1.10  christos   {
    780  1.10  christos     return m_target_flag_1;
    781  1.10  christos   }
    782  1.10  christos 
    783  1.10  christos   /* Set this minimal symbol's first target-specific flag.  */
    784  1.10  christos 
    785  1.10  christos   void set_target_flag_1 (bool target_flag_1)
    786  1.10  christos   {
    787  1.10  christos     m_target_flag_1 = target_flag_1;
    788  1.10  christos   }
    789  1.10  christos 
    790  1.10  christos   /* Return this minimal symbol's second target-specific flag.  */
    791  1.10  christos 
    792  1.10  christos   bool target_flag_2 () const
    793  1.10  christos   {
    794  1.10  christos     return m_target_flag_2;
    795  1.10  christos   }
    796  1.10  christos 
    797  1.10  christos   /* Set this minimal symbol's second target-specific flag.  */
    798  1.10  christos 
    799  1.10  christos   void set_target_flag_2 (bool target_flag_2)
    800  1.10  christos   {
    801  1.10  christos     m_target_flag_2 = target_flag_2;
    802  1.10  christos   }
    803  1.10  christos 
    804   1.6  christos   /* Size of this symbol.  dbx_end_psymtab in dbxread.c uses this
    805   1.1  christos      information to calculate the end of the partial symtab based on the
    806   1.1  christos      address of the last symbol plus the size of the last symbol.  */
    807   1.1  christos 
    808  1.10  christos   unsigned long m_size;
    809   1.1  christos 
    810   1.1  christos   /* Which source file is this symbol in?  Only relevant for mst_file_*.  */
    811   1.1  christos   const char *filename;
    812   1.1  christos 
    813   1.1  christos   /* Classification type for this minimal symbol.  */
    814   1.1  christos 
    815  1.10  christos   ENUM_BITFIELD(minimal_symbol_type) m_type : MINSYM_TYPE_BITS;
    816   1.1  christos 
    817   1.1  christos   /* Non-zero if this symbol was created by gdb.
    818   1.1  christos      Such symbols do not appear in the output of "info var|fun".  */
    819   1.1  christos   unsigned int created_by_gdb : 1;
    820   1.1  christos 
    821   1.1  christos   /* Two flag bits provided for the use of the target.  */
    822  1.10  christos   unsigned int m_target_flag_1 : 1;
    823  1.10  christos   unsigned int m_target_flag_2 : 1;
    824   1.1  christos 
    825   1.1  christos   /* Nonzero iff the size of the minimal symbol has been set.
    826   1.1  christos      Symbol size information can sometimes not be determined, because
    827   1.1  christos      the object file format may not carry that piece of information.  */
    828  1.10  christos   unsigned int m_has_size : 1;
    829   1.1  christos 
    830   1.9  christos   /* For data symbols only, if this is set, then the symbol might be
    831   1.9  christos      subject to copy relocation.  In this case, a minimal symbol
    832   1.9  christos      matching the symbol's linkage name is first looked for in the
    833   1.9  christos      main objfile.  If found, then that address is used; otherwise the
    834   1.9  christos      address in this symbol is used.  */
    835   1.9  christos 
    836   1.9  christos   unsigned maybe_copied : 1;
    837   1.9  christos 
    838   1.9  christos   /* Non-zero if this symbol ever had its demangled name set (even if
    839   1.9  christos      it was set to NULL).  */
    840   1.9  christos   unsigned int name_set : 1;
    841   1.9  christos 
    842   1.1  christos   /* Minimal symbols with the same hash key are kept on a linked
    843   1.1  christos      list.  This is the link.  */
    844   1.1  christos 
    845   1.1  christos   struct minimal_symbol *hash_next;
    846   1.1  christos 
    847   1.1  christos   /* Minimal symbols are stored in two different hash tables.  This is
    848   1.1  christos      the `next' pointer for the demangled hash table.  */
    849   1.1  christos 
    850   1.1  christos   struct minimal_symbol *demangled_hash_next;
    851   1.8  christos 
    852   1.9  christos   /* True if this symbol is of some data type.  */
    853   1.8  christos 
    854   1.8  christos   bool data_p () const;
    855   1.8  christos 
    856   1.8  christos   /* True if MSYMBOL is of some text type.  */
    857   1.8  christos 
    858   1.8  christos   bool text_p () const;
    859   1.1  christos };
    860   1.1  christos 
    861   1.1  christos #include "minsyms.h"
    862   1.1  christos 
    863   1.1  christos 
    864   1.1  christos 
    866   1.1  christos /* Represent one symbol name; a variable, constant, function or typedef.  */
    867   1.1  christos 
    868   1.1  christos /* Different name domains for symbols.  Looking up a symbol specifies a
    869   1.1  christos    domain and ignores symbol definitions in other name domains.  */
    870  1.10  christos 
    871   1.1  christos enum domain_enum
    872   1.1  christos {
    873   1.1  christos   /* UNDEF_DOMAIN is used when a domain has not been discovered or
    874   1.1  christos      none of the following apply.  This usually indicates an error either
    875   1.1  christos      in the symbol information or in gdb's handling of symbols.  */
    876   1.1  christos 
    877   1.1  christos   UNDEF_DOMAIN,
    878   1.1  christos 
    879   1.1  christos   /* VAR_DOMAIN is the usual domain.  In C, this contains variables,
    880   1.1  christos      function names, typedef names and enum type values.  */
    881   1.1  christos 
    882   1.1  christos   VAR_DOMAIN,
    883   1.1  christos 
    884   1.1  christos   /* STRUCT_DOMAIN is used in C to hold struct, union and enum type names.
    885   1.1  christos      Thus, if `struct foo' is used in a C program, it produces a symbol named
    886   1.1  christos      `foo' in the STRUCT_DOMAIN.  */
    887   1.1  christos 
    888   1.1  christos   STRUCT_DOMAIN,
    889   1.1  christos 
    890   1.1  christos   /* MODULE_DOMAIN is used in Fortran to hold module type names.  */
    891   1.1  christos 
    892   1.1  christos   MODULE_DOMAIN,
    893   1.1  christos 
    894   1.1  christos   /* LABEL_DOMAIN may be used for names of labels (for gotos).  */
    895   1.1  christos 
    896   1.1  christos   LABEL_DOMAIN,
    897   1.1  christos 
    898   1.1  christos   /* Fortran common blocks.  Their naming must be separate from VAR_DOMAIN.
    899   1.6  christos      They also always use LOC_COMMON_BLOCK.  */
    900   1.6  christos   COMMON_BLOCK_DOMAIN,
    901   1.6  christos 
    902   1.6  christos   /* This must remain last.  */
    903  1.10  christos   NR_DOMAINS
    904   1.1  christos };
    905   1.3  christos 
    906   1.3  christos /* The number of bits in a symbol used to represent the domain.  */
    907   1.6  christos 
    908   1.6  christos #define SYMBOL_DOMAIN_BITS 3
    909   1.3  christos gdb_static_assert (NR_DOMAINS <= (1 << SYMBOL_DOMAIN_BITS));
    910   1.1  christos 
    911   1.1  christos extern const char *domain_name (domain_enum);
    912   1.9  christos 
    913   1.1  christos /* Searching domains, used when searching for symbols.  Element numbers are
    914   1.1  christos    hardcoded in GDB, check all enum uses before changing it.  */
    915   1.1  christos 
    916   1.1  christos enum search_domain
    917   1.1  christos {
    918   1.1  christos   /* Everything in VAR_DOMAIN minus FUNCTIONS_DOMAIN and
    919   1.1  christos      TYPES_DOMAIN.  */
    920   1.1  christos   VARIABLES_DOMAIN = 0,
    921   1.1  christos 
    922   1.1  christos   /* All functions -- for some reason not methods, though.  */
    923   1.1  christos   FUNCTIONS_DOMAIN = 1,
    924   1.1  christos 
    925   1.1  christos   /* All defined types */
    926   1.1  christos   TYPES_DOMAIN = 2,
    927   1.9  christos 
    928   1.9  christos   /* All modules.  */
    929   1.9  christos   MODULES_DOMAIN = 3,
    930   1.1  christos 
    931   1.9  christos   /* Any type.  */
    932   1.1  christos   ALL_DOMAIN = 4
    933   1.1  christos };
    934   1.1  christos 
    935   1.1  christos extern const char *search_domain_name (enum search_domain);
    936   1.1  christos 
    937   1.1  christos /* An address-class says where to find the value of a symbol.  */
    938   1.1  christos 
    939   1.1  christos enum address_class
    940   1.1  christos {
    941   1.1  christos   /* Not used; catches errors.  */
    942   1.1  christos 
    943   1.1  christos   LOC_UNDEF,
    944   1.1  christos 
    945   1.1  christos   /* Value is constant int SYMBOL_VALUE, host byteorder.  */
    946   1.1  christos 
    947   1.1  christos   LOC_CONST,
    948   1.1  christos 
    949   1.1  christos   /* Value is at fixed address SYMBOL_VALUE_ADDRESS.  */
    950   1.1  christos 
    951   1.1  christos   LOC_STATIC,
    952   1.1  christos 
    953   1.1  christos   /* Value is in register.  SYMBOL_VALUE is the register number
    954   1.1  christos      in the original debug format.  SYMBOL_REGISTER_OPS holds a
    955   1.1  christos      function that can be called to transform this into the
    956   1.1  christos      actual register number this represents in a specific target
    957   1.1  christos      architecture (gdbarch).
    958   1.1  christos 
    959   1.1  christos      For some symbol formats (stabs, for some compilers at least),
    960   1.1  christos      the compiler generates two symbols, an argument and a register.
    961   1.1  christos      In some cases we combine them to a single LOC_REGISTER in symbol
    962   1.1  christos      reading, but currently not for all cases (e.g. it's passed on the
    963   1.1  christos      stack and then loaded into a register).  */
    964   1.1  christos 
    965   1.1  christos   LOC_REGISTER,
    966   1.1  christos 
    967   1.1  christos   /* It's an argument; the value is at SYMBOL_VALUE offset in arglist.  */
    968   1.1  christos 
    969   1.1  christos   LOC_ARG,
    970   1.1  christos 
    971   1.1  christos   /* Value address is at SYMBOL_VALUE offset in arglist.  */
    972   1.1  christos 
    973   1.1  christos   LOC_REF_ARG,
    974   1.1  christos 
    975   1.1  christos   /* Value is in specified register.  Just like LOC_REGISTER except the
    976   1.1  christos      register holds the address of the argument instead of the argument
    977   1.1  christos      itself.  This is currently used for the passing of structs and unions
    978   1.1  christos      on sparc and hppa.  It is also used for call by reference where the
    979   1.1  christos      address is in a register, at least by mipsread.c.  */
    980   1.1  christos 
    981   1.1  christos   LOC_REGPARM_ADDR,
    982   1.1  christos 
    983   1.1  christos   /* Value is a local variable at SYMBOL_VALUE offset in stack frame.  */
    984   1.1  christos 
    985   1.1  christos   LOC_LOCAL,
    986   1.1  christos 
    987   1.1  christos   /* Value not used; definition in SYMBOL_TYPE.  Symbols in the domain
    988   1.1  christos      STRUCT_DOMAIN all have this class.  */
    989   1.1  christos 
    990   1.1  christos   LOC_TYPEDEF,
    991   1.1  christos 
    992   1.1  christos   /* Value is address SYMBOL_VALUE_ADDRESS in the code.  */
    993   1.1  christos 
    994   1.1  christos   LOC_LABEL,
    995   1.1  christos 
    996   1.1  christos   /* In a symbol table, value is SYMBOL_BLOCK_VALUE of a `struct block'.
    997   1.1  christos      In a partial symbol table, SYMBOL_VALUE_ADDRESS is the start address
    998   1.1  christos      of the block.  Function names have this class.  */
    999   1.1  christos 
   1000   1.1  christos   LOC_BLOCK,
   1001   1.1  christos 
   1002   1.1  christos   /* Value is a constant byte-sequence pointed to by SYMBOL_VALUE_BYTES, in
   1003   1.1  christos      target byte order.  */
   1004   1.1  christos 
   1005   1.1  christos   LOC_CONST_BYTES,
   1006   1.1  christos 
   1007   1.1  christos   /* Value is at fixed address, but the address of the variable has
   1008   1.1  christos      to be determined from the minimal symbol table whenever the
   1009   1.1  christos      variable is referenced.
   1010   1.1  christos      This happens if debugging information for a global symbol is
   1011   1.1  christos      emitted and the corresponding minimal symbol is defined
   1012   1.1  christos      in another object file or runtime common storage.
   1013   1.1  christos      The linker might even remove the minimal symbol if the global
   1014   1.1  christos      symbol is never referenced, in which case the symbol remains
   1015   1.1  christos      unresolved.
   1016   1.1  christos 
   1017   1.1  christos      GDB would normally find the symbol in the minimal symbol table if it will
   1018   1.1  christos      not find it in the full symbol table.  But a reference to an external
   1019   1.1  christos      symbol in a local block shadowing other definition requires full symbol
   1020   1.6  christos      without possibly having its address available for LOC_STATIC.  Testcase
   1021   1.6  christos      is provided as `gdb.dwarf2/dw2-unresolved.exp'.
   1022   1.6  christos 
   1023   1.6  christos      This is also used for thread local storage (TLS) variables.  In this case,
   1024   1.6  christos      the address of the TLS variable must be determined when the variable is
   1025   1.6  christos      referenced, from the MSYMBOL_VALUE_RAW_ADDRESS, which is the offset
   1026   1.6  christos      of the TLS variable in the thread local storage of the shared
   1027   1.1  christos      library/object.  */
   1028   1.1  christos 
   1029   1.1  christos   LOC_UNRESOLVED,
   1030   1.1  christos 
   1031   1.1  christos   /* The variable does not actually exist in the program.
   1032   1.1  christos      The value is ignored.  */
   1033   1.1  christos 
   1034   1.1  christos   LOC_OPTIMIZED_OUT,
   1035   1.1  christos 
   1036   1.1  christos   /* The variable's address is computed by a set of location
   1037   1.1  christos      functions (see "struct symbol_computed_ops" below).  */
   1038   1.1  christos   LOC_COMPUTED,
   1039   1.1  christos 
   1040   1.1  christos   /* The variable uses general_symbol_info->value->common_block field.
   1041   1.1  christos      It also always uses COMMON_BLOCK_DOMAIN.  */
   1042   1.1  christos   LOC_COMMON_BLOCK,
   1043   1.1  christos 
   1044   1.1  christos   /* Not used, just notes the boundary of the enum.  */
   1045   1.1  christos   LOC_FINAL_VALUE
   1046   1.1  christos };
   1047   1.6  christos 
   1048   1.6  christos /* The number of bits needed for values in enum address_class, with some
   1049   1.6  christos    padding for reasonable growth, and room for run-time registered address
   1050   1.6  christos    classes. See symtab.c:MAX_SYMBOL_IMPLS.
   1051   1.6  christos    This is a #define so that we can have a assertion elsewhere to
   1052   1.6  christos    verify that we have reserved enough space for synthetic address
   1053   1.6  christos    classes.  */
   1054   1.6  christos #define SYMBOL_ACLASS_BITS 5
   1055   1.6  christos gdb_static_assert (LOC_FINAL_VALUE <= (1 << SYMBOL_ACLASS_BITS));
   1056   1.1  christos 
   1057   1.1  christos /* The methods needed to implement LOC_COMPUTED.  These methods can
   1058   1.1  christos    use the symbol's .aux_value for additional per-symbol information.
   1059   1.1  christos 
   1060   1.1  christos    At present this is only used to implement location expressions.  */
   1061   1.1  christos 
   1062   1.1  christos struct symbol_computed_ops
   1063   1.1  christos {
   1064   1.1  christos 
   1065   1.1  christos   /* Return the value of the variable SYMBOL, relative to the stack
   1066   1.1  christos      frame FRAME.  If the variable has been optimized out, return
   1067   1.1  christos      zero.
   1068   1.6  christos 
   1069   1.6  christos      Iff `read_needs_frame (SYMBOL)' is not SYMBOL_NEEDS_FRAME, then
   1070   1.1  christos      FRAME may be zero.  */
   1071   1.1  christos 
   1072  1.10  christos   struct value *(*read_variable) (struct symbol * symbol,
   1073   1.1  christos 				  frame_info_ptr frame);
   1074   1.1  christos 
   1075   1.1  christos   /* Read variable SYMBOL like read_variable at (callee) FRAME's function
   1076   1.1  christos      entry.  SYMBOL should be a function parameter, otherwise
   1077   1.1  christos      NO_ENTRY_VALUE_ERROR will be thrown.  */
   1078  1.10  christos   struct value *(*read_variable_at_entry) (struct symbol *symbol,
   1079   1.1  christos 					   frame_info_ptr frame);
   1080   1.6  christos 
   1081   1.6  christos   /* Find the "symbol_needs_kind" value for the given symbol.  This
   1082   1.6  christos      value determines whether reading the symbol needs memory (e.g., a
   1083   1.6  christos      global variable), just registers (a thread-local), or a frame (a
   1084   1.6  christos      local variable).  */
   1085   1.1  christos   enum symbol_needs_kind (*get_symbol_read_needs) (struct symbol * symbol);
   1086   1.1  christos 
   1087   1.1  christos   /* Write to STREAM a natural-language description of the location of
   1088   1.1  christos      SYMBOL, in the context of ADDR.  */
   1089   1.1  christos   void (*describe_location) (struct symbol * symbol, CORE_ADDR addr,
   1090   1.1  christos 			     struct ui_file * stream);
   1091   1.1  christos 
   1092   1.1  christos   /* Non-zero if this symbol's address computation is dependent on PC.  */
   1093   1.1  christos   unsigned char location_has_loclist;
   1094   1.1  christos 
   1095   1.1  christos   /* Tracepoint support.  Append bytecodes to the tracepoint agent
   1096   1.1  christos      expression AX that push the address of the object SYMBOL.  Set
   1097   1.1  christos      VALUE appropriately.  Note --- for objects in registers, this
   1098   1.1  christos      needn't emit any code; as long as it sets VALUE properly, then
   1099   1.1  christos      the caller will generate the right code in the process of
   1100   1.1  christos      treating this as an lvalue or rvalue.  */
   1101   1.8  christos 
   1102   1.8  christos   void (*tracepoint_var_ref) (struct symbol *symbol, struct agent_expr *ax,
   1103   1.3  christos 			      struct axs_value *value);
   1104   1.3  christos 
   1105   1.3  christos   /* Generate C code to compute the location of SYMBOL.  The C code is
   1106   1.3  christos      emitted to STREAM.  GDBARCH is the current architecture and PC is
   1107   1.3  christos      the PC at which SYMBOL's location should be evaluated.
   1108   1.3  christos      REGISTERS_USED is a vector indexed by register number; the
   1109   1.3  christos      generator function should set an element in this vector if the
   1110   1.3  christos      corresponding register is needed by the location computation.
   1111   1.3  christos      The generated C code must assign the location to a local
   1112   1.3  christos      variable; this variable's name is RESULT_NAME.  */
   1113   1.8  christos 
   1114   1.3  christos   void (*generate_c_location) (struct symbol *symbol, string_file *stream,
   1115  1.10  christos 			       struct gdbarch *gdbarch,
   1116   1.3  christos 			       std::vector<bool> &registers_used,
   1117   1.3  christos 			       CORE_ADDR pc, const char *result_name);
   1118   1.1  christos 
   1119   1.1  christos };
   1120   1.1  christos 
   1121   1.1  christos /* The methods needed to implement LOC_BLOCK for inferior functions.
   1122   1.1  christos    These methods can use the symbol's .aux_value for additional
   1123   1.1  christos    per-symbol information.  */
   1124   1.1  christos 
   1125   1.1  christos struct symbol_block_ops
   1126   1.1  christos {
   1127   1.1  christos   /* Fill in *START and *LENGTH with DWARF block data of function
   1128   1.1  christos      FRAMEFUNC valid for inferior context address PC.  Set *LENGTH to
   1129   1.1  christos      zero if such location is not valid for PC; *START is left
   1130   1.1  christos      uninitialized in such case.  */
   1131   1.1  christos   void (*find_frame_base_location) (struct symbol *framefunc, CORE_ADDR pc,
   1132   1.6  christos 				    const gdb_byte **start, size_t *length);
   1133   1.6  christos 
   1134   1.6  christos   /* Return the frame base address.  FRAME is the frame for which we want to
   1135   1.6  christos      compute the base address while FRAMEFUNC is the symbol for the
   1136   1.6  christos      corresponding function.  Return 0 on failure (FRAMEFUNC may not hold the
   1137   1.6  christos      information we need).
   1138   1.6  christos 
   1139   1.6  christos      This method is designed to work with static links (nested functions
   1140   1.6  christos      handling).  Static links are function properties whose evaluation returns
   1141   1.6  christos      the frame base address for the enclosing frame.  However, there are
   1142   1.6  christos      multiple definitions for "frame base": the content of the frame base
   1143   1.6  christos      register, the CFA as defined by DWARF unwinding information, ...
   1144   1.6  christos 
   1145   1.9  christos      So this specific method is supposed to compute the frame base address such
   1146   1.6  christos      as for nested functions, the static link computes the same address.  For
   1147   1.6  christos      instance, considering DWARF debugging information, the static link is
   1148   1.6  christos      computed with DW_AT_static_link and this method must be used to compute
   1149   1.6  christos      the corresponding DW_AT_frame_base attribute.  */
   1150  1.10  christos   CORE_ADDR (*get_frame_base) (struct symbol *framefunc,
   1151   1.1  christos 			       frame_info_ptr frame);
   1152   1.1  christos };
   1153   1.1  christos 
   1154   1.1  christos /* Functions used with LOC_REGISTER and LOC_REGPARM_ADDR.  */
   1155   1.1  christos 
   1156   1.1  christos struct symbol_register_ops
   1157   1.1  christos {
   1158   1.1  christos   int (*register_number) (struct symbol *symbol, struct gdbarch *gdbarch);
   1159   1.1  christos };
   1160   1.1  christos 
   1161   1.1  christos /* Objects of this type are used to find the address class and the
   1162   1.1  christos    various computed ops vectors of a symbol.  */
   1163   1.1  christos 
   1164   1.1  christos struct symbol_impl
   1165   1.1  christos {
   1166   1.1  christos   enum address_class aclass;
   1167   1.1  christos 
   1168   1.1  christos   /* Used with LOC_COMPUTED.  */
   1169   1.1  christos   const struct symbol_computed_ops *ops_computed;
   1170   1.1  christos 
   1171   1.1  christos   /* Used with LOC_BLOCK.  */
   1172   1.1  christos   const struct symbol_block_ops *ops_block;
   1173   1.1  christos 
   1174   1.1  christos   /* Used with LOC_REGISTER and LOC_REGPARM_ADDR.  */
   1175   1.1  christos   const struct symbol_register_ops *ops_register;
   1176   1.1  christos };
   1177   1.8  christos 
   1178   1.8  christos /* struct symbol has some subclasses.  This enum is used to
   1179   1.8  christos    differentiate between them.  */
   1180   1.8  christos 
   1181   1.8  christos enum symbol_subclass_kind
   1182   1.8  christos {
   1183   1.8  christos   /* Plain struct symbol.  */
   1184   1.8  christos   SYMBOL_NONE,
   1185   1.8  christos 
   1186   1.8  christos   /* struct template_symbol.  */
   1187   1.8  christos   SYMBOL_TEMPLATE,
   1188   1.8  christos 
   1189   1.8  christos   /* struct rust_vtable_symbol.  */
   1190   1.8  christos   SYMBOL_RUST_VTABLE
   1191   1.8  christos };
   1192  1.10  christos 
   1193  1.10  christos extern gdb::array_view<const struct symbol_impl> symbol_impls;
   1194   1.1  christos 
   1195   1.1  christos /* This structure is space critical.  See space comments at the top.  */
   1196   1.9  christos 
   1197   1.1  christos struct symbol : public general_symbol_info, public allocate_on_obstack
   1198   1.9  christos {
   1199   1.9  christos   symbol ()
   1200  1.10  christos     /* Class-initialization of bitfields is only allowed in C++20.  */
   1201  1.10  christos     : m_domain (UNDEF_DOMAIN),
   1202  1.10  christos       m_aclass_index (0),
   1203  1.10  christos       m_is_objfile_owned (1),
   1204  1.10  christos       m_is_argument (0),
   1205   1.9  christos       m_is_inlined (0),
   1206  1.10  christos       maybe_copied (0),
   1207  1.10  christos       subclass (SYMBOL_NONE),
   1208   1.9  christos       m_artificial (false)
   1209   1.9  christos     {
   1210  1.10  christos       /* We can't use an initializer list for members of a base class, and
   1211   1.9  christos 	 general_symbol_info needs to stay a POD type.  */
   1212  1.10  christos       m_name = nullptr;
   1213   1.9  christos       m_value.ivalue = 0;
   1214   1.9  christos       language_specific.obstack = nullptr;
   1215   1.9  christos       m_language = language_unknown;
   1216  1.10  christos       ada_mangled = 0;
   1217   1.9  christos       m_section = -1;
   1218  1.10  christos       /* GCC 4.8.5 (on CentOS 7) does not correctly compile class-
   1219   1.9  christos 	 initialization of unions, so we initialize it manually here.  */
   1220   1.9  christos       owner.symtab = nullptr;
   1221   1.1  christos     }
   1222   1.9  christos 
   1223  1.10  christos   symbol (const symbol &) = default;
   1224  1.10  christos   symbol &operator= (const symbol &) = default;
   1225  1.10  christos 
   1226  1.10  christos   void set_aclass_index (unsigned int aclass_index)
   1227  1.10  christos   {
   1228  1.10  christos     m_aclass_index = aclass_index;
   1229  1.10  christos   }
   1230  1.10  christos 
   1231  1.10  christos   const symbol_impl &impl () const
   1232  1.10  christos   {
   1233  1.10  christos     return symbol_impls[this->m_aclass_index];
   1234  1.10  christos   }
   1235  1.10  christos 
   1236  1.10  christos   address_class aclass () const
   1237  1.10  christos   {
   1238  1.10  christos     return this->impl ().aclass;
   1239  1.10  christos   }
   1240  1.10  christos 
   1241  1.10  christos   domain_enum domain () const
   1242  1.10  christos   {
   1243  1.10  christos     return m_domain;
   1244  1.10  christos   }
   1245  1.10  christos 
   1246  1.10  christos   void set_domain (domain_enum domain)
   1247  1.10  christos   {
   1248  1.10  christos     m_domain = domain;
   1249  1.10  christos   }
   1250  1.10  christos 
   1251  1.10  christos   bool is_objfile_owned () const
   1252  1.10  christos   {
   1253  1.10  christos     return m_is_objfile_owned;
   1254  1.10  christos   }
   1255  1.10  christos 
   1256  1.10  christos   void set_is_objfile_owned (bool is_objfile_owned)
   1257  1.10  christos   {
   1258  1.10  christos     m_is_objfile_owned = is_objfile_owned;
   1259  1.10  christos   }
   1260  1.10  christos 
   1261  1.10  christos   bool is_argument () const
   1262  1.10  christos   {
   1263  1.10  christos     return m_is_argument;
   1264  1.10  christos   }
   1265  1.10  christos 
   1266  1.10  christos   void set_is_argument (bool is_argument)
   1267  1.10  christos   {
   1268  1.10  christos     m_is_argument = is_argument;
   1269  1.10  christos   }
   1270  1.10  christos 
   1271  1.10  christos   bool is_inlined () const
   1272  1.10  christos   {
   1273  1.10  christos     return m_is_inlined;
   1274  1.10  christos   }
   1275  1.10  christos 
   1276  1.10  christos   void set_is_inlined (bool is_inlined)
   1277  1.10  christos   {
   1278  1.10  christos     m_is_inlined = is_inlined;
   1279  1.10  christos   }
   1280  1.10  christos 
   1281  1.10  christos   bool is_cplus_template_function () const
   1282  1.10  christos   {
   1283  1.10  christos     return this->subclass == SYMBOL_TEMPLATE;
   1284  1.10  christos   }
   1285  1.10  christos 
   1286  1.10  christos   struct type *type () const
   1287  1.10  christos   {
   1288  1.10  christos     return m_type;
   1289  1.10  christos   }
   1290  1.10  christos 
   1291  1.10  christos   void set_type (struct type *type)
   1292  1.10  christos   {
   1293  1.10  christos     m_type = type;
   1294  1.10  christos   }
   1295  1.10  christos 
   1296  1.10  christos   unsigned short line () const
   1297  1.10  christos   {
   1298  1.10  christos     return m_line;
   1299  1.10  christos   }
   1300  1.10  christos 
   1301  1.10  christos   void set_line (unsigned short line)
   1302  1.10  christos   {
   1303  1.10  christos     m_line = line;
   1304  1.10  christos   }
   1305  1.10  christos 
   1306  1.10  christos   LONGEST value_longest () const
   1307  1.10  christos   {
   1308  1.10  christos     return m_value.ivalue;
   1309  1.10  christos   }
   1310  1.10  christos 
   1311  1.10  christos   void set_value_longest (LONGEST value)
   1312  1.10  christos   {
   1313  1.10  christos     m_value.ivalue = value;
   1314  1.10  christos   }
   1315  1.10  christos 
   1316  1.10  christos   CORE_ADDR value_address () const
   1317  1.10  christos   {
   1318  1.10  christos     if (this->maybe_copied)
   1319  1.10  christos       return get_symbol_address (this);
   1320  1.10  christos     else
   1321  1.10  christos       return m_value.address;
   1322  1.10  christos   }
   1323  1.10  christos 
   1324  1.10  christos   void set_value_address (CORE_ADDR address)
   1325  1.10  christos   {
   1326  1.10  christos     m_value.address = address;
   1327  1.10  christos   }
   1328  1.10  christos 
   1329  1.10  christos   const gdb_byte *value_bytes () const
   1330  1.10  christos   {
   1331  1.10  christos     return m_value.bytes;
   1332  1.10  christos   }
   1333  1.10  christos 
   1334  1.10  christos   void set_value_bytes (const gdb_byte *bytes)
   1335  1.10  christos   {
   1336  1.10  christos     m_value.bytes = bytes;
   1337  1.10  christos   }
   1338  1.10  christos 
   1339  1.10  christos   const common_block *value_common_block () const
   1340  1.10  christos   {
   1341  1.10  christos     return m_value.common_block;
   1342  1.10  christos   }
   1343  1.10  christos 
   1344  1.10  christos   void set_value_common_block (const common_block *common_block)
   1345  1.10  christos   {
   1346  1.10  christos     m_value.common_block = common_block;
   1347  1.10  christos   }
   1348  1.10  christos 
   1349  1.10  christos   const block *value_block () const
   1350  1.10  christos   {
   1351  1.10  christos     return m_value.block;
   1352  1.10  christos   }
   1353  1.10  christos 
   1354  1.10  christos   void set_value_block (const block *block)
   1355  1.10  christos   {
   1356  1.10  christos     m_value.block = block;
   1357  1.10  christos   }
   1358  1.10  christos 
   1359  1.10  christos   symbol *value_chain () const
   1360  1.10  christos   {
   1361  1.10  christos     return m_value.chain;
   1362  1.10  christos   }
   1363  1.10  christos 
   1364  1.10  christos   void set_value_chain (symbol *sym)
   1365  1.10  christos   {
   1366  1.10  christos     m_value.chain = sym;
   1367  1.10  christos   }
   1368  1.10  christos 
   1369  1.10  christos   /* Return true if this symbol was marked as artificial.  */
   1370  1.10  christos   bool is_artificial () const
   1371  1.10  christos   {
   1372  1.10  christos     return m_artificial;
   1373  1.10  christos   }
   1374  1.10  christos 
   1375  1.10  christos   /* Set the 'artificial' flag on this symbol.  */
   1376  1.10  christos   void set_is_artificial (bool artificial)
   1377  1.10  christos   {
   1378  1.10  christos     m_artificial = artificial;
   1379  1.10  christos   }
   1380  1.10  christos 
   1381  1.10  christos   /* Return the OBJFILE of this symbol.  It is an error to call this
   1382  1.10  christos      if is_objfile_owned is false, which only happens for
   1383  1.10  christos      architecture-provided types.  */
   1384  1.10  christos 
   1385  1.10  christos   struct objfile *objfile () const;
   1386  1.10  christos 
   1387  1.10  christos   /* Return the ARCH of this symbol.  */
   1388  1.10  christos 
   1389  1.10  christos   struct gdbarch *arch () const;
   1390  1.10  christos 
   1391  1.10  christos   /* Return the symtab of this symbol.  It is an error to call this if
   1392  1.10  christos      is_objfile_owned is false, which only happens for
   1393  1.10  christos      architecture-provided types.  */
   1394  1.10  christos 
   1395  1.10  christos   struct symtab *symtab () const;
   1396  1.10  christos 
   1397  1.10  christos   /* Set the symtab of this symbol to SYMTAB.  It is an error to call
   1398  1.10  christos      this if is_objfile_owned is false, which only happens for
   1399  1.10  christos      architecture-provided types.  */
   1400  1.10  christos 
   1401   1.1  christos   void set_symtab (struct symtab *symtab);
   1402   1.1  christos 
   1403   1.1  christos   /* Data type of value */
   1404  1.10  christos 
   1405   1.1  christos   struct type *m_type = nullptr;
   1406   1.3  christos 
   1407   1.3  christos   /* The owner of this symbol.
   1408   1.3  christos      Which one to use is defined by symbol.is_objfile_owned.  */
   1409   1.3  christos 
   1410   1.3  christos   union
   1411   1.3  christos   {
   1412   1.3  christos     /* The symbol table containing this symbol.  This is the file associated
   1413   1.3  christos        with LINE.  It can be NULL during symbols read-in but it is never NULL
   1414   1.3  christos        during normal operation.  */
   1415   1.3  christos     struct symtab *symtab;
   1416   1.3  christos 
   1417   1.3  christos     /* For types defined by the architecture.  */
   1418   1.3  christos     struct gdbarch *arch;
   1419   1.1  christos   } owner;
   1420   1.1  christos 
   1421   1.1  christos   /* Domain code.  */
   1422  1.10  christos 
   1423   1.1  christos   ENUM_BITFIELD(domain_enum) m_domain : SYMBOL_DOMAIN_BITS;
   1424   1.1  christos 
   1425   1.1  christos   /* Address class.  This holds an index into the 'symbol_impls'
   1426   1.1  christos      table.  The actual enum address_class value is stored there,
   1427   1.1  christos      alongside any per-class ops vectors.  */
   1428  1.10  christos 
   1429   1.1  christos   unsigned int m_aclass_index : SYMBOL_ACLASS_BITS;
   1430   1.3  christos 
   1431   1.9  christos   /* If non-zero then symbol is objfile-owned, use owner.symtab.
   1432   1.3  christos        Otherwise symbol is arch-owned, use owner.arch.  */
   1433  1.10  christos 
   1434   1.3  christos   unsigned int m_is_objfile_owned : 1;
   1435   1.1  christos 
   1436   1.1  christos   /* Whether this is an argument.  */
   1437  1.10  christos 
   1438   1.1  christos   unsigned m_is_argument : 1;
   1439   1.1  christos 
   1440  1.10  christos   /* Whether this is an inlined function (class LOC_BLOCK only).  */
   1441   1.1  christos   unsigned m_is_inlined : 1;
   1442   1.9  christos 
   1443   1.9  christos   /* For LOC_STATIC only, if this is set, then the symbol might be
   1444   1.9  christos      subject to copy relocation.  In this case, a minimal symbol
   1445   1.9  christos      matching the symbol's linkage name is first looked for in the
   1446   1.9  christos      main objfile.  If found, then that address is used; otherwise the
   1447   1.9  christos      address in this symbol is used.  */
   1448   1.9  christos 
   1449   1.9  christos   unsigned maybe_copied : 1;
   1450   1.8  christos 
   1451   1.8  christos   /* The concrete type of this symbol.  */
   1452   1.8  christos 
   1453   1.1  christos   ENUM_BITFIELD (symbol_subclass_kind) subclass : 2;
   1454  1.10  christos 
   1455  1.10  christos   /* Whether this symbol is artificial.  */
   1456  1.10  christos 
   1457  1.10  christos   bool m_artificial : 1;
   1458   1.1  christos 
   1459   1.1  christos   /* Line number of this symbol's definition, except for inlined
   1460   1.1  christos      functions.  For an inlined function (class LOC_BLOCK and
   1461   1.1  christos      SYMBOL_INLINED set) this is the line number of the function's call
   1462   1.1  christos      site.  Inlined function symbols are not definitions, and they are
   1463   1.3  christos      never found by symbol table lookup.
   1464   1.1  christos      If this symbol is arch-owned, LINE shall be zero.
   1465   1.1  christos 
   1466   1.1  christos      FIXME: Should we really make the assumption that nobody will try
   1467   1.1  christos      to debug files longer than 64K lines?  What about machine
   1468   1.1  christos      generated programs?  */
   1469  1.10  christos 
   1470   1.1  christos   unsigned short m_line = 0;
   1471   1.1  christos 
   1472   1.1  christos   /* An arbitrary data pointer, allowing symbol readers to record
   1473   1.1  christos      additional information on a per-symbol basis.  Note that this data
   1474   1.6  christos      must be allocated using the same obstack as the symbol itself.  */
   1475   1.6  christos   /* So far it is only used by:
   1476   1.6  christos      LOC_COMPUTED: to find the location information
   1477   1.6  christos      LOC_BLOCK (DWARF2 function): information used internally by the
   1478   1.1  christos      DWARF 2 code --- specifically, the location expression for the frame
   1479   1.1  christos      base for this function.  */
   1480   1.1  christos   /* FIXME drow/2003-02-21: For the LOC_BLOCK case, it might be better
   1481   1.1  christos      to add a magic symbol to the block containing this information,
   1482   1.1  christos      or to have a generic debug info annotation slot for symbols.  */
   1483   1.9  christos 
   1484   1.1  christos   void *aux_value = nullptr;
   1485   1.9  christos 
   1486   1.1  christos   struct symbol *hash_next = nullptr;
   1487   1.1  christos };
   1488   1.6  christos 
   1489   1.6  christos /* Several lookup functions return both a symbol and the block in which the
   1490   1.6  christos    symbol is found.  This structure is used in these cases.  */
   1491   1.6  christos 
   1492   1.6  christos struct block_symbol
   1493   1.6  christos {
   1494   1.6  christos   /* The symbol that was found, or NULL if no symbol was found.  */
   1495   1.6  christos   struct symbol *symbol;
   1496   1.6  christos 
   1497   1.6  christos   /* If SYMBOL is not NULL, then this is the block in which the symbol is
   1498   1.6  christos      defined.  */
   1499   1.6  christos   const struct block *block;
   1500   1.6  christos };
   1501   1.3  christos 
   1502   1.3  christos /* Note: There is no accessor macro for symbol.owner because it is
   1503   1.3  christos    "private".  */
   1504  1.10  christos 
   1505  1.10  christos #define SYMBOL_COMPUTED_OPS(symbol)	((symbol)->impl ().ops_computed)
   1506  1.10  christos #define SYMBOL_BLOCK_OPS(symbol)	((symbol)->impl ().ops_block)
   1507   1.1  christos #define SYMBOL_REGISTER_OPS(symbol)	((symbol)->impl ().ops_register)
   1508   1.1  christos #define SYMBOL_LOCATION_BATON(symbol)   (symbol)->aux_value
   1509   1.1  christos 
   1510   1.1  christos extern int register_symbol_computed_impl (enum address_class,
   1511   1.1  christos 					  const struct symbol_computed_ops *);
   1512   1.1  christos 
   1513   1.1  christos extern int register_symbol_block_impl (enum address_class aclass,
   1514   1.1  christos 				       const struct symbol_block_ops *ops);
   1515   1.1  christos 
   1516   1.1  christos extern int register_symbol_register_impl (enum address_class,
   1517   1.1  christos 					  const struct symbol_register_ops *);
   1518   1.1  christos 
   1519   1.8  christos /* An instance of this type is used to represent a C++ template
   1520  1.10  christos    function.  A symbol is really of this type iff
   1521   1.1  christos    symbol::is_cplus_template_function is true.  */
   1522   1.8  christos 
   1523   1.1  christos struct template_symbol : public symbol
   1524   1.1  christos {
   1525   1.9  christos   /* The number of template arguments.  */
   1526   1.1  christos   int n_template_arguments = 0;
   1527   1.1  christos 
   1528   1.1  christos   /* The template arguments.  This is an array with
   1529   1.9  christos      N_TEMPLATE_ARGUMENTS elements.  */
   1530   1.1  christos   struct symbol **template_arguments = nullptr;
   1531   1.1  christos };
   1532   1.8  christos 
   1533   1.8  christos /* A symbol that represents a Rust virtual table object.  */
   1534   1.8  christos 
   1535   1.8  christos struct rust_vtable_symbol : public symbol
   1536   1.8  christos {
   1537   1.8  christos   /* The concrete type for which this vtable was created; that is, in
   1538   1.9  christos      "impl Trait for Type", this is "Type".  */
   1539   1.8  christos   struct type *concrete_type = nullptr;
   1540   1.8  christos };
   1541   1.1  christos 
   1542   1.1  christos 
   1543   1.1  christos /* Each item represents a line-->pc (or the reverse) mapping.  This is
   1545   1.1  christos    somewhat more wasteful of space than one might wish, but since only
   1546   1.1  christos    the files which are actually debugged are read in to core, we don't
   1547   1.1  christos    waste much space.  */
   1548   1.1  christos 
   1549   1.9  christos struct linetable_entry
   1550   1.1  christos {
   1551   1.9  christos   /* The line number for this entry.  */
   1552   1.9  christos   int line;
   1553   1.9  christos 
   1554   1.9  christos   /* True if this PC is a good location to place a breakpoint for LINE.  */
   1555  1.10  christos   unsigned is_stmt : 1;
   1556  1.10  christos 
   1557  1.10  christos   /* True if this location is a good location to place a breakpoint after a
   1558  1.10  christos      function prologue.  */
   1559   1.9  christos   bool prologue_end : 1;
   1560   1.1  christos 
   1561   1.1  christos   /* The address for this entry.  */
   1562   1.1  christos   CORE_ADDR pc;
   1563   1.1  christos };
   1564   1.1  christos 
   1565   1.1  christos /* The order of entries in the linetable is significant.  They should
   1566   1.1  christos    be sorted by increasing values of the pc field.  If there is more than
   1567   1.1  christos    one entry for a given pc, then I'm not sure what should happen (and
   1568   1.1  christos    I not sure whether we currently handle it the best way).
   1569   1.1  christos 
   1570   1.1  christos    Example: a C for statement generally looks like this
   1571   1.1  christos 
   1572   1.1  christos    10   0x100   - for the init/test part of a for stmt.
   1573   1.1  christos    20   0x200
   1574   1.1  christos    30   0x300
   1575   1.1  christos    10   0x400   - for the increment part of a for stmt.
   1576   1.1  christos 
   1577   1.1  christos    If an entry has a line number of zero, it marks the start of a PC
   1578   1.1  christos    range for which no line number information is available.  It is
   1579   1.1  christos    acceptable, though wasteful of table space, for such a range to be
   1580   1.1  christos    zero length.  */
   1581   1.1  christos 
   1582   1.1  christos struct linetable
   1583   1.1  christos {
   1584   1.1  christos   int nitems;
   1585   1.1  christos 
   1586   1.1  christos   /* Actually NITEMS elements.  If you don't like this use of the
   1587   1.1  christos      `struct hack', you can shove it up your ANSI (seriously, if the
   1588   1.1  christos      committee tells us how to do it, we can probably go along).  */
   1589   1.1  christos   struct linetable_entry item[1];
   1590   1.1  christos };
   1591   1.1  christos 
   1592   1.1  christos /* How to relocate the symbols from each section in a symbol file.
   1593   1.9  christos    The ordering and meaning of the offsets is file-type-dependent;
   1594   1.1  christos    typically it is indexed by section numbers or symbol types or
   1595   1.9  christos    something like that.  */
   1596   1.1  christos 
   1597   1.1  christos typedef std::vector<CORE_ADDR> section_offsets;
   1598   1.3  christos 
   1599   1.1  christos /* Each source file or header is represented by a struct symtab.
   1600   1.1  christos    The name "symtab" is historical, another name for it is "filetab".
   1601   1.1  christos    These objects are chained through the `next' field.  */
   1602   1.1  christos 
   1603  1.10  christos struct symtab
   1604  1.10  christos {
   1605  1.10  christos   struct compunit_symtab *compunit () const
   1606  1.10  christos   {
   1607  1.10  christos     return m_compunit;
   1608  1.10  christos   }
   1609  1.10  christos 
   1610  1.10  christos   void set_compunit (struct compunit_symtab *compunit)
   1611  1.10  christos   {
   1612  1.10  christos     m_compunit = compunit;
   1613  1.10  christos   }
   1614  1.10  christos 
   1615  1.10  christos   struct linetable *linetable () const
   1616  1.10  christos   {
   1617  1.10  christos     return m_linetable;
   1618  1.10  christos   }
   1619  1.10  christos 
   1620  1.10  christos   void set_linetable (struct linetable *linetable)
   1621  1.10  christos   {
   1622  1.10  christos     m_linetable = linetable;
   1623  1.10  christos   }
   1624  1.10  christos 
   1625  1.10  christos   enum language language () const
   1626  1.10  christos   {
   1627  1.10  christos     return m_language;
   1628  1.10  christos   }
   1629  1.10  christos 
   1630  1.10  christos   void set_language (enum language language)
   1631  1.10  christos   {
   1632  1.10  christos     m_language = language;
   1633   1.5  christos   }
   1634   1.5  christos 
   1635   1.1  christos   /* Unordered chain of all filetabs in the compunit,  with the exception
   1636   1.1  christos      that the "main" source file is the first entry in the list.  */
   1637   1.1  christos 
   1638   1.3  christos   struct symtab *next;
   1639   1.1  christos 
   1640  1.10  christos   /* Backlink to containing compunit symtab.  */
   1641   1.1  christos 
   1642   1.1  christos   struct compunit_symtab *m_compunit;
   1643   1.1  christos 
   1644   1.1  christos   /* Table mapping core addresses to line numbers for this file.
   1645  1.10  christos      Can be NULL if none.  Never shared between different symtabs.  */
   1646   1.1  christos 
   1647  1.10  christos   struct linetable *m_linetable;
   1648  1.10  christos 
   1649  1.10  christos   /* Name of this source file, in a form appropriate to print to the user.
   1650   1.1  christos 
   1651   1.1  christos      This pointer is never nullptr.  */
   1652   1.1  christos 
   1653  1.10  christos   const char *filename;
   1654  1.10  christos 
   1655  1.10  christos   /* Filename for this source file, used as an identifier to link with
   1656  1.10  christos      related objects such as associated macro_source_file objects.  It must
   1657  1.10  christos      therefore match the name of any macro_source_file object created for this
   1658  1.10  christos      source file.  The value can be the same as FILENAME if it is known to
   1659  1.10  christos      follow that rule, or another form of the same file name, this is up to
   1660  1.10  christos      the specific debug info reader.
   1661  1.10  christos 
   1662  1.10  christos      This pointer is never nullptr.*/
   1663   1.1  christos   const char *filename_for_id;
   1664   1.1  christos 
   1665  1.10  christos   /* Language of this source file.  */
   1666   1.1  christos 
   1667   1.3  christos   enum language m_language;
   1668   1.3  christos 
   1669   1.3  christos   /* Full name of file as found by searching the source path.
   1670   1.3  christos      NULL if not yet known.  */
   1671   1.3  christos 
   1672   1.3  christos   char *fullname;
   1673  1.10  christos };
   1674  1.10  christos 
   1675  1.10  christos /* A range adapter to allowing iterating over all the file tables in a list.  */
   1676   1.3  christos 
   1677   1.3  christos using symtab_range = next_range<symtab>;
   1678   1.3  christos 
   1679   1.3  christos /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well
   1680   1.3  christos    as the list of all source files (what gdb has historically associated with
   1681   1.3  christos    the term "symtab").
   1682   1.3  christos    Additional information is recorded here that is common to all symtabs in a
   1683   1.3  christos    compilation unit (DWARF or otherwise).
   1684   1.3  christos 
   1685   1.3  christos    Example:
   1686   1.3  christos    For the case of a program built out of these files:
   1687   1.3  christos 
   1688   1.3  christos    foo.c
   1689   1.3  christos      foo1.h
   1690   1.3  christos      foo2.h
   1691   1.3  christos    bar.c
   1692   1.3  christos      foo1.h
   1693   1.3  christos      bar.h
   1694   1.3  christos 
   1695   1.3  christos    This is recorded as:
   1696  1.10  christos 
   1697  1.10  christos    objfile -> foo.c(cu) -> bar.c(cu) -> NULL
   1698  1.10  christos 		|            |
   1699  1.10  christos 		v            v
   1700  1.10  christos 	      foo.c        bar.c
   1701  1.10  christos 		|            |
   1702  1.10  christos 		v            v
   1703  1.10  christos 	      foo1.h       foo1.h
   1704  1.10  christos 		|            |
   1705  1.10  christos 		v            v
   1706  1.10  christos 	      foo2.h       bar.h
   1707  1.10  christos 		|            |
   1708   1.3  christos 		v            v
   1709   1.3  christos 	       NULL         NULL
   1710   1.3  christos 
   1711   1.3  christos    where "foo.c(cu)" and "bar.c(cu)" are struct compunit_symtab objects,
   1712   1.3  christos    and the files foo.c, etc. are struct symtab objects.  */
   1713   1.3  christos 
   1714  1.10  christos struct compunit_symtab
   1715  1.10  christos {
   1716  1.10  christos   struct objfile *objfile () const
   1717  1.10  christos   {
   1718  1.10  christos     return m_objfile;
   1719  1.10  christos   }
   1720  1.10  christos 
   1721  1.10  christos   void set_objfile (struct objfile *objfile)
   1722  1.10  christos   {
   1723  1.10  christos     m_objfile = objfile;
   1724  1.10  christos   }
   1725  1.10  christos 
   1726  1.10  christos   symtab_range filetabs () const
   1727  1.10  christos   {
   1728  1.10  christos     return symtab_range (m_filetabs);
   1729  1.10  christos   }
   1730  1.10  christos 
   1731  1.10  christos   void add_filetab (symtab *filetab)
   1732  1.10  christos   {
   1733  1.10  christos     if (m_filetabs == nullptr)
   1734  1.10  christos       {
   1735  1.10  christos 	m_filetabs = filetab;
   1736  1.10  christos 	m_last_filetab = filetab;
   1737  1.10  christos       }
   1738  1.10  christos     else
   1739  1.10  christos       {
   1740  1.10  christos 	m_last_filetab->next = filetab;
   1741  1.10  christos 	m_last_filetab = filetab;
   1742  1.10  christos       }
   1743  1.10  christos   }
   1744  1.10  christos 
   1745  1.10  christos   const char *debugformat () const
   1746  1.10  christos   {
   1747  1.10  christos     return m_debugformat;
   1748  1.10  christos   }
   1749  1.10  christos 
   1750  1.10  christos   void set_debugformat (const char *debugformat)
   1751  1.10  christos   {
   1752  1.10  christos     m_debugformat = debugformat;
   1753  1.10  christos   }
   1754  1.10  christos 
   1755  1.10  christos   const char *producer () const
   1756  1.10  christos   {
   1757  1.10  christos     return m_producer;
   1758  1.10  christos   }
   1759  1.10  christos 
   1760  1.10  christos   void set_producer (const char *producer)
   1761  1.10  christos   {
   1762  1.10  christos     m_producer = producer;
   1763  1.10  christos   }
   1764  1.10  christos 
   1765  1.10  christos   const char *dirname () const
   1766  1.10  christos   {
   1767  1.10  christos     return m_dirname;
   1768  1.10  christos   }
   1769  1.10  christos 
   1770  1.10  christos   void set_dirname (const char *dirname)
   1771  1.10  christos   {
   1772  1.10  christos     m_dirname = dirname;
   1773  1.10  christos   }
   1774  1.10  christos 
   1775  1.10  christos   struct blockvector *blockvector ()
   1776  1.10  christos   {
   1777  1.10  christos     return m_blockvector;
   1778  1.10  christos   }
   1779  1.10  christos 
   1780  1.10  christos   const struct blockvector *blockvector () const
   1781  1.10  christos   {
   1782  1.10  christos     return m_blockvector;
   1783  1.10  christos   }
   1784  1.10  christos 
   1785  1.10  christos   void set_blockvector (struct blockvector *blockvector)
   1786  1.10  christos   {
   1787  1.10  christos     m_blockvector = blockvector;
   1788  1.10  christos   }
   1789  1.10  christos 
   1790  1.10  christos   int block_line_section () const
   1791  1.10  christos   {
   1792  1.10  christos     return m_block_line_section;
   1793  1.10  christos   }
   1794  1.10  christos 
   1795  1.10  christos   void set_block_line_section (int block_line_section)
   1796  1.10  christos   {
   1797  1.10  christos     m_block_line_section = block_line_section;
   1798  1.10  christos   }
   1799  1.10  christos 
   1800  1.10  christos   bool locations_valid () const
   1801  1.10  christos   {
   1802  1.10  christos     return m_locations_valid;
   1803  1.10  christos   }
   1804  1.10  christos 
   1805  1.10  christos   void set_locations_valid (bool locations_valid)
   1806  1.10  christos   {
   1807  1.10  christos     m_locations_valid = locations_valid;
   1808  1.10  christos   }
   1809  1.10  christos 
   1810  1.10  christos   bool epilogue_unwind_valid () const
   1811  1.10  christos   {
   1812  1.10  christos     return m_epilogue_unwind_valid;
   1813  1.10  christos   }
   1814  1.10  christos 
   1815  1.10  christos   void set_epilogue_unwind_valid (bool epilogue_unwind_valid)
   1816  1.10  christos   {
   1817  1.10  christos     m_epilogue_unwind_valid = epilogue_unwind_valid;
   1818  1.10  christos   }
   1819  1.10  christos 
   1820  1.10  christos   struct macro_table *macro_table () const
   1821  1.10  christos   {
   1822  1.10  christos     return m_macro_table;
   1823  1.10  christos   }
   1824  1.10  christos 
   1825  1.10  christos   void set_macro_table (struct macro_table *macro_table)
   1826  1.10  christos   {
   1827  1.10  christos     m_macro_table = macro_table;
   1828  1.10  christos   }
   1829  1.10  christos 
   1830  1.10  christos   /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
   1831  1.10  christos 
   1832  1.10  christos      PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
   1833  1.10  christos 
   1834  1.10  christos   void set_primary_filetab (symtab *primary_filetab);
   1835  1.10  christos 
   1836  1.10  christos   /* Return the primary filetab of the compunit.  */
   1837  1.10  christos   symtab *primary_filetab () const;
   1838  1.10  christos 
   1839  1.10  christos   /* Set m_call_site_htab.  */
   1840  1.10  christos   void set_call_site_htab (htab_t call_site_htab);
   1841  1.10  christos 
   1842  1.10  christos   /* Find call_site info for PC.  */
   1843  1.10  christos   call_site *find_call_site (CORE_ADDR pc) const;
   1844  1.10  christos 
   1845  1.10  christos   /* Return the language of this compunit_symtab.  */
   1846   1.3  christos   enum language language () const;
   1847   1.3  christos 
   1848   1.3  christos   /* Unordered chain of all compunit symtabs of this objfile.  */
   1849   1.3  christos   struct compunit_symtab *next;
   1850  1.10  christos 
   1851   1.3  christos   /* Object file from which this symtab information was read.  */
   1852   1.3  christos   struct objfile *m_objfile;
   1853   1.3  christos 
   1854   1.3  christos   /* Name of the symtab.
   1855   1.3  christos      This is *not* intended to be a usable filename, and is
   1856   1.3  christos      for debugging purposes only.  */
   1857   1.3  christos   const char *name;
   1858   1.3  christos 
   1859   1.3  christos   /* Unordered list of file symtabs, except that by convention the "main"
   1860   1.3  christos      source file (e.g., .c, .cc) is guaranteed to be first.
   1861  1.10  christos      Each symtab is a file, either the "main" source file (e.g., .c, .cc)
   1862   1.3  christos      or header (e.g., .h).  */
   1863   1.3  christos   symtab *m_filetabs;
   1864   1.3  christos 
   1865   1.3  christos   /* Last entry in FILETABS list.
   1866   1.3  christos      Subfiles are added to the end of the list so they accumulate in order,
   1867   1.3  christos      with the main source subfile living at the front.
   1868  1.10  christos      The main reason is so that the main source file symtab is at the head
   1869   1.3  christos      of the list, and the rest appear in order for debugging convenience.  */
   1870   1.3  christos   symtab *m_last_filetab;
   1871   1.3  christos 
   1872   1.1  christos   /* Non-NULL string that identifies the format of the debugging information,
   1873   1.1  christos      such as "stabs", "dwarf 1", "dwarf 2", "coff", etc.  This is mostly useful
   1874  1.10  christos      for automated testing of gdb but may also be information that is
   1875   1.1  christos      useful to the user.  */
   1876   1.3  christos   const char *m_debugformat;
   1877  1.10  christos 
   1878   1.1  christos   /* String of producer version information, or NULL if we don't know.  */
   1879   1.3  christos   const char *m_producer;
   1880  1.10  christos 
   1881   1.1  christos   /* Directory in which it was compiled, or NULL if we don't know.  */
   1882   1.3  christos   const char *m_dirname;
   1883   1.3  christos 
   1884  1.10  christos   /* List of all symbol scope blocks for this symtab.  It is shared among
   1885   1.1  christos      all symtabs in a given compilation unit.  */
   1886   1.3  christos   struct blockvector *m_blockvector;
   1887   1.3  christos 
   1888  1.10  christos   /* Section in objfile->section_offsets for the blockvector and
   1889   1.1  christos      the linetable.  Probably always SECT_OFF_TEXT.  */
   1890   1.3  christos   int m_block_line_section;
   1891   1.3  christos 
   1892   1.3  christos   /* Symtab has been compiled with both optimizations and debug info so that
   1893  1.10  christos      GDB may stop skipping prologues as variables locations are valid already
   1894   1.1  christos      at function entry points.  */
   1895   1.3  christos   unsigned int m_locations_valid : 1;
   1896   1.3  christos 
   1897  1.10  christos   /* DWARF unwinder for this CU is valid even for epilogues (PC at the return
   1898   1.1  christos      instruction).  This is supported by GCC since 4.5.0.  */
   1899   1.1  christos   unsigned int m_epilogue_unwind_valid : 1;
   1900  1.10  christos 
   1901   1.1  christos   /* struct call_site entries for this compilation unit or NULL.  */
   1902   1.3  christos   htab_t m_call_site_htab;
   1903   1.3  christos 
   1904   1.3  christos   /* The macro table for this symtab.  Like the blockvector, this
   1905   1.3  christos      is shared between different symtabs in a given compilation unit.
   1906  1.10  christos      It's debatable whether it *should* be shared among all the symtabs in
   1907   1.1  christos      the given compilation unit, but it currently is.  */
   1908   1.1  christos   struct macro_table *m_macro_table;
   1909   1.3  christos 
   1910   1.3  christos   /* If non-NULL, then this points to a NULL-terminated vector of
   1911   1.3  christos      included compunits.  When searching the static or global
   1912   1.1  christos      block of this compunit, the corresponding block of all
   1913   1.1  christos      included compunits will also be searched.  Note that this
   1914   1.3  christos      list must be flattened -- the symbol reader is responsible for
   1915   1.3  christos      ensuring that this vector contains the transitive closure of all
   1916   1.3  christos      included compunits.  */
   1917   1.3  christos   struct compunit_symtab **includes;
   1918   1.3  christos 
   1919   1.3  christos   /* If this is an included compunit, this points to one includer
   1920   1.3  christos      of the table.  This user is considered the canonical compunit
   1921   1.3  christos      containing this one.  An included compunit may itself be
   1922   1.3  christos      included by another.  */
   1923   1.1  christos   struct compunit_symtab *user;
   1924  1.10  christos };
   1925   1.1  christos 
   1926   1.9  christos using compunit_symtab_range = next_range<compunit_symtab>;
   1927   1.9  christos 
   1928   1.9  christos /* Return true if this symtab is the "main" symtab of its compunit_symtab.  */
   1929   1.9  christos 
   1930   1.9  christos static inline bool
   1931  1.10  christos is_main_symtab_of_compunit_symtab (struct symtab *symtab)
   1932   1.9  christos {
   1933   1.1  christos   return symtab == symtab->compunit ()->primary_filetab ();
   1934   1.1  christos }
   1935   1.1  christos 
   1936   1.1  christos 
   1938   1.1  christos /* The virtual function table is now an array of structures which have the
   1939   1.1  christos    form { int16 offset, delta; void *pfn; }.
   1940   1.1  christos 
   1941   1.1  christos    In normal virtual function tables, OFFSET is unused.
   1942   1.1  christos    DELTA is the amount which is added to the apparent object's base
   1943   1.1  christos    address in order to point to the actual object to which the
   1944   1.1  christos    virtual function should be applied.
   1945   1.1  christos    PFN is a pointer to the virtual function.
   1946   1.1  christos 
   1947   1.1  christos    Note that this macro is g++ specific (FIXME).  */
   1948   1.1  christos 
   1949   1.1  christos #define VTBL_FNADDR_OFFSET 2
   1950   1.1  christos 
   1951   1.1  christos /* External variables and functions for the objects described above.  */
   1952   1.1  christos 
   1953   1.1  christos /* True if we are nested inside psymtab_to_symtab.  */
   1954   1.1  christos 
   1955   1.1  christos extern int currently_reading_symtab;
   1956   1.1  christos 
   1957   1.1  christos /* symtab.c lookup functions */
   1958   1.1  christos 
   1959   1.1  christos extern const char multiple_symbols_ask[];
   1960   1.1  christos extern const char multiple_symbols_all[];
   1961   1.1  christos extern const char multiple_symbols_cancel[];
   1962   1.9  christos 
   1963   1.9  christos const char *multiple_symbols_select_mode (void);
   1964   1.9  christos 
   1965   1.1  christos bool symbol_matches_domain (enum language symbol_language,
   1966   1.1  christos 			    domain_enum symbol_domain,
   1967   1.1  christos 			    domain_enum domain);
   1968   1.1  christos 
   1969   1.1  christos /* lookup a symbol table by source file name.  */
   1970   1.1  christos 
   1971   1.1  christos extern struct symtab *lookup_symtab (const char *);
   1972   1.1  christos 
   1973   1.1  christos /* An object of this type is passed as the 'is_a_field_of_this'
   1974   1.1  christos    argument to lookup_symbol and lookup_symbol_in_language.  */
   1975   1.1  christos 
   1976   1.1  christos struct field_of_this_result
   1977   1.1  christos {
   1978   1.1  christos   /* The type in which the field was found.  If this is NULL then the
   1979   1.1  christos      symbol was not found in 'this'.  If non-NULL, then one of the
   1980   1.1  christos      other fields will be non-NULL as well.  */
   1981   1.1  christos 
   1982   1.1  christos   struct type *type;
   1983   1.1  christos 
   1984   1.1  christos   /* If the symbol was found as an ordinary field of 'this', then this
   1985   1.1  christos      is non-NULL and points to the particular field.  */
   1986   1.3  christos 
   1987   1.1  christos   struct field *field;
   1988   1.1  christos 
   1989   1.1  christos   /* If the symbol was found as a function field of 'this', then this
   1990   1.1  christos      is non-NULL and points to the particular field.  */
   1991   1.1  christos 
   1992   1.3  christos   struct fn_fieldlist *fn_field;
   1993   1.3  christos };
   1994   1.3  christos 
   1995   1.3  christos /* Find the definition for a specified symbol name NAME
   1996   1.3  christos    in domain DOMAIN in language LANGUAGE, visible from lexical block BLOCK
   1997   1.3  christos    if non-NULL or from global/static blocks if BLOCK is NULL.
   1998   1.3  christos    Returns the struct symbol pointer, or NULL if no symbol is found.
   1999   1.3  christos    C++: if IS_A_FIELD_OF_THIS is non-NULL on entry, check to see if
   2000   1.1  christos    NAME is a field of the current implied argument `this'.  If so fill in the
   2001   1.6  christos    fields of IS_A_FIELD_OF_THIS, otherwise the fields are set to NULL.
   2002   1.6  christos    The symbol's section is fixed up if necessary.  */
   2003   1.6  christos 
   2004   1.6  christos extern struct block_symbol
   2005   1.6  christos   lookup_symbol_in_language (const char *,
   2006   1.6  christos 			     const struct block *,
   2007   1.1  christos 			     const domain_enum,
   2008   1.3  christos 			     enum language,
   2009   1.1  christos 			     struct field_of_this_result *);
   2010   1.6  christos 
   2011   1.6  christos /* Same as lookup_symbol_in_language, but using the current language.  */
   2012   1.6  christos 
   2013   1.6  christos extern struct block_symbol lookup_symbol (const char *,
   2014   1.1  christos 					  const struct block *,
   2015   1.8  christos 					  const domain_enum,
   2016   1.8  christos 					  struct field_of_this_result *);
   2017   1.8  christos 
   2018   1.8  christos /* Find the definition for a specified symbol search name in domain
   2019   1.9  christos    DOMAIN, visible from lexical block BLOCK if non-NULL or from
   2020   1.8  christos    global/static blocks if BLOCK is NULL.  The passed-in search name
   2021   1.8  christos    should not come from the user; instead it should already be a
   2022   1.8  christos    search name as retrieved from a search_name () call.  See definition of
   2023   1.8  christos    symbol_name_match_type::SEARCH_NAME.  Returns the struct symbol
   2024   1.8  christos    pointer, or NULL if no symbol is found.  The symbol's section is
   2025   1.8  christos    fixed up if necessary.  */
   2026   1.8  christos 
   2027   1.8  christos extern struct block_symbol lookup_symbol_search_name (const char *search_name,
   2028   1.1  christos 						      const struct block *block,
   2029   1.1  christos 						      domain_enum domain);
   2030   1.1  christos 
   2031   1.1  christos /* Some helper functions for languages that need to write their own
   2032   1.3  christos    lookup_symbol_nonlocal functions.  */
   2033   1.6  christos 
   2034   1.3  christos /* Lookup a symbol in the static block associated to BLOCK, if there
   2035   1.6  christos    is one; do nothing if BLOCK is NULL or a global block.
   2036   1.6  christos    Upon success fixes up the symbol's section if necessary.  */
   2037   1.6  christos 
   2038   1.6  christos extern struct block_symbol
   2039   1.3  christos   lookup_symbol_in_static_block (const char *name,
   2040   1.3  christos 				 const struct block *block,
   2041   1.6  christos 				 const domain_enum domain);
   2042   1.1  christos 
   2043   1.6  christos /* Search all static file-level symbols for NAME from DOMAIN.
   2044   1.6  christos    Upon success fixes up the symbol's section if necessary.  */
   2045   1.1  christos 
   2046   1.3  christos extern struct block_symbol lookup_static_symbol (const char *name,
   2047   1.3  christos 						 const domain_enum domain);
   2048   1.3  christos 
   2049   1.3  christos /* Lookup a symbol in all files' global blocks.
   2050   1.3  christos 
   2051   1.3  christos    If BLOCK is non-NULL then it is used for two things:
   2052   1.3  christos    1) If a target-specific lookup routine for libraries exists, then use the
   2053   1.3  christos       routine for the objfile of BLOCK, and
   2054   1.1  christos    2) The objfile of BLOCK is used to assist in determining the search order
   2055   1.6  christos       if the target requires it.
   2056   1.3  christos       See gdbarch_iterate_over_objfiles_in_search_order.
   2057   1.6  christos 
   2058   1.6  christos    Upon success fixes up the symbol's section if necessary.  */
   2059   1.6  christos 
   2060   1.6  christos extern struct block_symbol
   2061   1.1  christos   lookup_global_symbol (const char *name,
   2062   1.3  christos 			const struct block *block,
   2063   1.6  christos 			const domain_enum domain);
   2064   1.3  christos 
   2065   1.6  christos /* Lookup a symbol in block BLOCK.
   2066   1.6  christos    Upon success fixes up the symbol's section if necessary.  */
   2067   1.8  christos 
   2068   1.6  christos extern struct symbol *
   2069   1.6  christos   lookup_symbol_in_block (const char *name,
   2070   1.3  christos 			  symbol_name_match_type match_type,
   2071   1.3  christos 			  const struct block *block,
   2072   1.3  christos 			  const domain_enum domain);
   2073   1.1  christos 
   2074   1.6  christos /* Look up the `this' symbol for LANG in BLOCK.  Return the symbol if
   2075   1.6  christos    found, or NULL if not found.  */
   2076   1.6  christos 
   2077   1.1  christos extern struct block_symbol
   2078   1.3  christos   lookup_language_this (const struct language_defn *lang,
   2079   1.1  christos 			const struct block *block);
   2080   1.1  christos 
   2081   1.1  christos /* Lookup a [struct, union, enum] by name, within a specified block.  */
   2082   1.1  christos 
   2083   1.1  christos extern struct type *lookup_struct (const char *, const struct block *);
   2084   1.1  christos 
   2085   1.1  christos extern struct type *lookup_union (const char *, const struct block *);
   2086   1.1  christos 
   2087   1.1  christos extern struct type *lookup_enum (const char *, const struct block *);
   2088   1.8  christos 
   2089   1.8  christos /* from blockframe.c: */
   2090   1.8  christos 
   2091   1.1  christos /* lookup the function symbol corresponding to the address.  The
   2092   1.1  christos    return value will not be an inlined function; the containing
   2093   1.1  christos    function will be returned instead.  */
   2094   1.8  christos 
   2095   1.8  christos extern struct symbol *find_pc_function (CORE_ADDR);
   2096   1.8  christos 
   2097   1.1  christos /* lookup the function corresponding to the address and section.  The
   2098   1.1  christos    return value will not be an inlined function; the containing
   2099   1.1  christos    function will be returned instead.  */
   2100   1.8  christos 
   2101   1.8  christos extern struct symbol *find_pc_sect_function (CORE_ADDR, struct obj_section *);
   2102   1.8  christos 
   2103   1.8  christos /* lookup the function symbol corresponding to the address and
   2104   1.8  christos    section.  The return value will be the closest enclosing function,
   2105   1.8  christos    which might be an inline function.  */
   2106   1.8  christos 
   2107   1.8  christos extern struct symbol *find_pc_sect_containing_function
   2108   1.8  christos   (CORE_ADDR pc, struct obj_section *section);
   2109   1.8  christos 
   2110   1.8  christos /* Find the symbol at the given address.  Returns NULL if no symbol
   2111   1.8  christos    found.  Only exact matches for ADDRESS are considered.  */
   2112   1.8  christos 
   2113   1.8  christos extern struct symbol *find_symbol_at_address (CORE_ADDR);
   2114   1.8  christos 
   2115   1.8  christos /* Finds the "function" (text symbol) that is smaller than PC but
   2116   1.8  christos    greatest of all of the potential text symbols in SECTION.  Sets
   2117   1.8  christos    *NAME and/or *ADDRESS conditionally if that pointer is non-null.
   2118   1.8  christos    If ENDADDR is non-null, then set *ENDADDR to be the end of the
   2119   1.8  christos    function (exclusive).  If the optional parameter BLOCK is non-null,
   2120   1.8  christos    then set *BLOCK to the address of the block corresponding to the
   2121   1.8  christos    function symbol, if such a symbol could be found during the lookup;
   2122   1.9  christos    nullptr is used as a return value for *BLOCK if no block is found.
   2123   1.9  christos    This function either succeeds or fails (not halfway succeeds).  If
   2124   1.8  christos    it succeeds, it sets *NAME, *ADDRESS, and *ENDADDR to real
   2125   1.8  christos    information and returns true.  If it fails, it sets *NAME, *ADDRESS
   2126   1.8  christos    and *ENDADDR to zero and returns false.
   2127   1.8  christos 
   2128   1.8  christos    If the function in question occupies non-contiguous ranges,
   2129   1.8  christos    *ADDRESS and *ENDADDR are (subject to the conditions noted above) set
   2130   1.8  christos    to the start and end of the range in which PC is found.  Thus
   2131   1.8  christos    *ADDRESS <= PC < *ENDADDR with no intervening gaps (in which ranges
   2132   1.8  christos    from other functions might be found).
   2133   1.8  christos 
   2134   1.8  christos    This property allows find_pc_partial_function to be used (as it had
   2135   1.8  christos    been prior to the introduction of non-contiguous range support) by
   2136   1.8  christos    various tdep files for finding a start address and limit address
   2137   1.8  christos    for prologue analysis.  This still isn't ideal, however, because we
   2138   1.8  christos    probably shouldn't be doing prologue analysis (in which
   2139   1.8  christos    instructions are scanned to determine frame size and stack layout)
   2140   1.8  christos    for any range that doesn't contain the entry pc.  Moreover, a good
   2141   1.8  christos    argument can be made that prologue analysis ought to be performed
   2142   1.8  christos    starting from the entry pc even when PC is within some other range.
   2143   1.8  christos    This might suggest that *ADDRESS and *ENDADDR ought to be set to the
   2144   1.8  christos    limits of the entry pc range, but that will cause the
   2145   1.8  christos    *ADDRESS <= PC < *ENDADDR condition to be violated; many of the
   2146   1.8  christos    callers of find_pc_partial_function expect this condition to hold.
   2147   1.8  christos 
   2148   1.8  christos    Callers which require the start and/or end addresses for the range
   2149   1.9  christos    containing the entry pc should instead call
   2150   1.9  christos    find_function_entry_range_from_pc.  */
   2151   1.9  christos 
   2152   1.9  christos extern bool find_pc_partial_function (CORE_ADDR pc, const char **name,
   2153   1.9  christos 				      CORE_ADDR *address, CORE_ADDR *endaddr,
   2154   1.9  christos 				      const struct block **block = nullptr);
   2155   1.9  christos 
   2156   1.9  christos /* Like find_pc_partial_function, above, but returns the underlying
   2157   1.9  christos    general_symbol_info (rather than the name) as an out parameter.  */
   2158   1.9  christos 
   2159   1.9  christos extern bool find_pc_partial_function_sym
   2160   1.8  christos   (CORE_ADDR pc, const general_symbol_info **sym,
   2161   1.8  christos    CORE_ADDR *address, CORE_ADDR *endaddr,
   2162   1.8  christos    const struct block **block = nullptr);
   2163   1.8  christos 
   2164   1.8  christos /* Like find_pc_partial_function, above, but *ADDRESS and *ENDADDR are
   2165   1.8  christos    set to start and end addresses of the range containing the entry pc.
   2166   1.8  christos 
   2167   1.8  christos    Note that it is not necessarily the case that (for non-NULL ADDRESS
   2168   1.8  christos    and ENDADDR arguments) the *ADDRESS <= PC < *ENDADDR condition will
   2169   1.8  christos    hold.
   2170   1.8  christos 
   2171   1.8  christos    See comment for find_pc_partial_function, above, for further
   2172   1.8  christos    explanation.  */
   2173   1.1  christos 
   2174   1.8  christos extern bool find_function_entry_range_from_pc (CORE_ADDR pc,
   2175   1.1  christos 					       const char **name,
   2176   1.8  christos 					       CORE_ADDR *address,
   2177   1.8  christos 					       CORE_ADDR *endaddr);
   2178   1.1  christos 
   2179   1.8  christos /* Return the type of a function with its first instruction exactly at
   2180   1.8  christos    the PC address.  Return NULL otherwise.  */
   2181   1.8  christos 
   2182   1.8  christos extern struct type *find_function_type (CORE_ADDR pc);
   2183   1.8  christos 
   2184   1.8  christos /* See if we can figure out the function's actual type from the type
   2185   1.8  christos    that the resolver returns.  RESOLVER_FUNADDR is the address of the
   2186   1.8  christos    ifunc resolver.  */
   2187   1.8  christos 
   2188   1.8  christos extern struct type *find_gnu_ifunc_target_type (CORE_ADDR resolver_funaddr);
   2189   1.1  christos 
   2190   1.1  christos /* Find the GNU ifunc minimal symbol that matches SYM.  */
   2191   1.1  christos extern bound_minimal_symbol find_gnu_ifunc (const symbol *sym);
   2192   1.3  christos 
   2193   1.1  christos extern void clear_pc_function_cache (void);
   2194   1.3  christos 
   2195   1.1  christos /* Expand symtab containing PC, SECTION if not already expanded.  */
   2196   1.1  christos 
   2197   1.1  christos extern void expand_symtab_containing_pc (CORE_ADDR, struct obj_section *);
   2198   1.3  christos 
   2199   1.1  christos /* lookup full symbol table by address.  */
   2200   1.1  christos 
   2201   1.1  christos extern struct compunit_symtab *find_pc_compunit_symtab (CORE_ADDR);
   2202   1.3  christos 
   2203   1.3  christos /* lookup full symbol table by address and section.  */
   2204   1.1  christos 
   2205   1.9  christos extern struct compunit_symtab *
   2206   1.1  christos   find_pc_sect_compunit_symtab (CORE_ADDR, struct obj_section *);
   2207  1.10  christos 
   2208   1.1  christos extern bool find_pc_line_pc_range (CORE_ADDR, CORE_ADDR *, CORE_ADDR *);
   2209   1.3  christos 
   2210   1.3  christos extern void reread_symbols (int from_tty);
   2211   1.3  christos 
   2212   1.3  christos /* Look up a type named NAME in STRUCT_DOMAIN in the current language.
   2213   1.1  christos    The type returned must not be opaque -- i.e., must have at least one field
   2214   1.3  christos    defined.  */
   2215   1.1  christos 
   2216   1.1  christos extern struct type *lookup_transparent_type (const char *);
   2217   1.1  christos 
   2218   1.1  christos extern struct type *basic_lookup_transparent_type (const char *);
   2219   1.1  christos 
   2220   1.1  christos /* Macro for name of symbol to indicate a file compiled with gcc.  */
   2221   1.1  christos #ifndef GCC_COMPILED_FLAG_SYMBOL
   2222   1.1  christos #define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled."
   2223   1.1  christos #endif
   2224   1.1  christos 
   2225   1.1  christos /* Macro for name of symbol to indicate a file compiled with gcc2.  */
   2226   1.1  christos #ifndef GCC2_COMPILED_FLAG_SYMBOL
   2227   1.9  christos #define GCC2_COMPILED_FLAG_SYMBOL "gcc2_compiled."
   2228   1.1  christos #endif
   2229   1.1  christos 
   2230   1.1  christos extern bool in_gnu_ifunc_stub (CORE_ADDR pc);
   2231   1.1  christos 
   2232   1.1  christos /* Functions for resolving STT_GNU_IFUNC symbols which are implemented only
   2233   1.1  christos    for ELF symbol files.  */
   2234   1.1  christos 
   2235   1.1  christos struct gnu_ifunc_fns
   2236   1.1  christos {
   2237   1.1  christos   /* See elf_gnu_ifunc_resolve_addr for its real implementation.  */
   2238   1.9  christos   CORE_ADDR (*gnu_ifunc_resolve_addr) (struct gdbarch *gdbarch, CORE_ADDR pc);
   2239   1.1  christos 
   2240   1.1  christos   /* See elf_gnu_ifunc_resolve_name for its real implementation.  */
   2241   1.1  christos   bool (*gnu_ifunc_resolve_name) (const char *function_name,
   2242  1.10  christos 				 CORE_ADDR *function_address_p);
   2243   1.1  christos 
   2244   1.1  christos   /* See elf_gnu_ifunc_resolver_stop for its real implementation.  */
   2245  1.10  christos   void (*gnu_ifunc_resolver_stop) (code_breakpoint *b);
   2246   1.1  christos 
   2247   1.1  christos   /* See elf_gnu_ifunc_resolver_return_stop for its real implementation.  */
   2248   1.1  christos   void (*gnu_ifunc_resolver_return_stop) (code_breakpoint *b);
   2249   1.1  christos };
   2250   1.1  christos 
   2251   1.1  christos #define gnu_ifunc_resolve_addr gnu_ifunc_fns_p->gnu_ifunc_resolve_addr
   2252   1.1  christos #define gnu_ifunc_resolve_name gnu_ifunc_fns_p->gnu_ifunc_resolve_name
   2253   1.1  christos #define gnu_ifunc_resolver_stop gnu_ifunc_fns_p->gnu_ifunc_resolver_stop
   2254   1.1  christos #define gnu_ifunc_resolver_return_stop \
   2255   1.1  christos   gnu_ifunc_fns_p->gnu_ifunc_resolver_return_stop
   2256  1.10  christos 
   2257   1.1  christos extern const struct gnu_ifunc_fns *gnu_ifunc_fns_p;
   2258   1.1  christos 
   2259   1.1  christos extern CORE_ADDR find_solib_trampoline_target (frame_info_ptr, CORE_ADDR);
   2260   1.1  christos 
   2261   1.8  christos struct symtab_and_line
   2262   1.1  christos {
   2263   1.8  christos   /* The program space of this sal.  */
   2264   1.8  christos   struct program_space *pspace = NULL;
   2265   1.8  christos 
   2266   1.8  christos   struct symtab *symtab = NULL;
   2267   1.1  christos   struct symbol *symbol = NULL;
   2268   1.1  christos   struct obj_section *section = NULL;
   2269   1.1  christos   struct minimal_symbol *msymbol = NULL;
   2270   1.8  christos   /* Line number.  Line numbers start at 1 and proceed through symtab->nlines.
   2271   1.1  christos      0 is never a valid line number; it is used to indicate that line number
   2272   1.8  christos      information is not available.  */
   2273   1.8  christos   int line = 0;
   2274   1.8  christos 
   2275   1.8  christos   CORE_ADDR pc = 0;
   2276   1.1  christos   CORE_ADDR end = 0;
   2277   1.9  christos   bool explicit_pc = false;
   2278   1.9  christos   bool explicit_line = false;
   2279   1.9  christos 
   2280   1.9  christos   /* If the line number information is valid, then this indicates if this
   2281   1.1  christos      line table entry had the is-stmt flag set or not.  */
   2282   1.8  christos   bool is_stmt = false;
   2283   1.3  christos 
   2284   1.3  christos   /* The probe associated with this symtab_and_line.  */
   2285   1.8  christos   probe *prob = NULL;
   2286   1.1  christos   /* If PROBE is not NULL, then this is the objfile in which the probe
   2287   1.1  christos      originated.  */
   2288   1.1  christos   struct objfile *objfile = NULL;
   2289   1.1  christos };
   2290   1.1  christos 
   2291   1.1  christos 
   2292   1.1  christos 
   2294   1.1  christos /* Given a pc value, return line number it is in.  Second arg nonzero means
   2295   1.1  christos    if pc is on the boundary use the previous statement's line number.  */
   2296   1.1  christos 
   2297   1.1  christos extern struct symtab_and_line find_pc_line (CORE_ADDR, int);
   2298   1.1  christos 
   2299   1.1  christos /* Same function, but specify a section as well as an address.  */
   2300   1.3  christos 
   2301   1.3  christos extern struct symtab_and_line find_pc_sect_line (CORE_ADDR,
   2302   1.3  christos 						 struct obj_section *, int);
   2303   1.3  christos 
   2304   1.1  christos /* Wrapper around find_pc_line to just return the symtab.  */
   2305   1.1  christos 
   2306   1.9  christos extern struct symtab *find_pc_line_symtab (CORE_ADDR);
   2307   1.1  christos 
   2308   1.9  christos /* Given a symtab and line number, return the pc there.  */
   2309   1.9  christos 
   2310   1.1  christos extern bool find_line_pc (struct symtab *, int, CORE_ADDR *);
   2311   1.1  christos 
   2312   1.1  christos extern bool find_line_pc_range (struct symtab_and_line, CORE_ADDR *,
   2313   1.5  christos 				CORE_ADDR *);
   2314   1.1  christos 
   2315   1.1  christos extern void resolve_sal_pc (struct symtab_and_line *);
   2316   1.1  christos 
   2317   1.8  christos /* solib.c */
   2318   1.8  christos 
   2319   1.8  christos extern void clear_solib (void);
   2320   1.8  christos 
   2321   1.8  christos /* The reason we're calling into a completion match list collector
   2322   1.8  christos    function.  */
   2323   1.8  christos enum class complete_symbol_mode
   2324   1.8  christos   {
   2325   1.8  christos     /* Completing an expression.  */
   2326   1.8  christos     EXPRESSION,
   2327   1.1  christos 
   2328   1.8  christos     /* Completing a linespec.  */
   2329   1.8  christos     LINESPEC,
   2330   1.8  christos   };
   2331   1.8  christos 
   2332   1.8  christos extern void default_collect_symbol_completion_matches_break_on
   2333   1.8  christos   (completion_tracker &tracker,
   2334   1.8  christos    complete_symbol_mode mode,
   2335   1.8  christos    symbol_name_match_type name_match_type,
   2336   1.8  christos    const char *text, const char *word, const char *break_on,
   2337   1.8  christos    enum type_code code);
   2338   1.8  christos extern void collect_symbol_completion_matches
   2339   1.8  christos   (completion_tracker &tracker,
   2340   1.8  christos    complete_symbol_mode mode,
   2341   1.8  christos    symbol_name_match_type name_match_type,
   2342   1.1  christos    const char *, const char *);
   2343   1.8  christos extern void collect_symbol_completion_matches_type (completion_tracker &tracker,
   2344   1.8  christos 						    const char *, const char *,
   2345   1.8  christos 						    enum type_code);
   2346   1.8  christos 
   2347   1.8  christos extern void collect_file_symbol_completion_matches
   2348   1.1  christos   (completion_tracker &tracker,
   2349   1.8  christos    complete_symbol_mode,
   2350   1.8  christos    symbol_name_match_type name_match_type,
   2351   1.1  christos    const char *, const char *, const char *);
   2352   1.8  christos 
   2353   1.1  christos extern completion_list
   2354   1.8  christos   make_source_files_completion_list (const char *, const char *);
   2355   1.1  christos 
   2356   1.8  christos /* Return whether SYM is a function/method, as opposed to a data symbol.  */
   2357   1.8  christos 
   2358   1.1  christos extern bool symbol_is_function_or_method (symbol *sym);
   2359   1.8  christos 
   2360   1.1  christos /* Return whether MSYMBOL is a function/method, as opposed to a data
   2361   1.8  christos    symbol */
   2362   1.8  christos 
   2363   1.1  christos extern bool symbol_is_function_or_method (minimal_symbol *msymbol);
   2364   1.8  christos 
   2365   1.8  christos /* Return whether SYM should be skipped in completion mode MODE.  In
   2366   1.8  christos    linespec mode, we're only interested in functions/methods.  */
   2367   1.8  christos 
   2368   1.8  christos template<typename Symbol>
   2369   1.8  christos static bool
   2370   1.8  christos completion_skip_symbol (complete_symbol_mode mode, Symbol *sym)
   2371   1.1  christos {
   2372   1.1  christos   return (mode == complete_symbol_mode::LINESPEC
   2373   1.1  christos 	  && !symbol_is_function_or_method (sym));
   2374   1.9  christos }
   2375   1.1  christos 
   2376   1.9  christos /* symtab.c */
   2377   1.1  christos 
   2378   1.8  christos bool matching_obj_sections (struct obj_section *, struct obj_section *);
   2379   1.8  christos 
   2380   1.8  christos extern struct symtab *find_line_symtab (struct symtab *, int, int *, bool *);
   2381   1.8  christos 
   2382   1.8  christos /* Given a function symbol SYM, find the symtab and line for the start
   2383   1.8  christos    of the function.  If FUNFIRSTLINE is true, we want the first line
   2384   1.8  christos    of real code inside the function.  */
   2385   1.8  christos extern symtab_and_line find_function_start_sal (symbol *sym, bool
   2386   1.8  christos 						funfirstline);
   2387   1.8  christos 
   2388   1.8  christos /* Same, but start with a function address/section instead of a
   2389   1.1  christos    symbol.  */
   2390   1.1  christos extern symtab_and_line find_function_start_sal (CORE_ADDR func_addr,
   2391   1.1  christos 						obj_section *section,
   2392   1.1  christos 						bool funfirstline);
   2393   1.1  christos 
   2394   1.1  christos extern void skip_prologue_sal (struct symtab_and_line *);
   2395   1.1  christos 
   2396   1.1  christos /* symtab.c */
   2397   1.1  christos 
   2398   1.1  christos extern CORE_ADDR skip_prologue_using_sal (struct gdbarch *gdbarch,
   2399   1.1  christos 					  CORE_ADDR func_addr);
   2400   1.8  christos 
   2401   1.8  christos extern struct symbol *fixup_symbol_section (struct symbol *,
   2402   1.8  christos 					    struct objfile *);
   2403   1.8  christos 
   2404   1.8  christos /* If MSYMBOL is an text symbol, look for a function debug symbol with
   2405   1.8  christos    the same address.  Returns NULL if not found.  This is necessary in
   2406   1.8  christos    case a function is an alias to some other function, because debug
   2407   1.1  christos    information is only emitted for the alias target function's
   2408   1.1  christos    definition, not for the alias.  */
   2409   1.9  christos extern symbol *find_function_alias_target (bound_minimal_symbol msymbol);
   2410   1.9  christos 
   2411   1.1  christos /* Symbol searching */
   2412   1.1  christos 
   2413   1.8  christos /* When using the symbol_searcher struct to search for symbols, a vector of
   2414   1.8  christos    the following structs is returned.  */
   2415   1.8  christos struct symbol_search
   2416   1.8  christos {
   2417   1.8  christos   symbol_search (int block_, struct symbol *symbol_)
   2418   1.8  christos     : block (block_),
   2419   1.8  christos       symbol (symbol_)
   2420   1.8  christos   {
   2421   1.8  christos     msymbol.minsym = nullptr;
   2422   1.8  christos     msymbol.objfile = nullptr;
   2423   1.8  christos   }
   2424   1.8  christos 
   2425   1.8  christos   symbol_search (int block_, struct minimal_symbol *minsym,
   2426   1.8  christos 		 struct objfile *objfile)
   2427   1.8  christos     : block (block_),
   2428   1.8  christos       symbol (nullptr)
   2429   1.8  christos   {
   2430   1.8  christos     msymbol.minsym = minsym;
   2431   1.8  christos     msymbol.objfile = objfile;
   2432   1.8  christos   }
   2433   1.8  christos 
   2434   1.8  christos   bool operator< (const symbol_search &other) const
   2435   1.8  christos   {
   2436   1.8  christos     return compare_search_syms (*this, other) < 0;
   2437   1.8  christos   }
   2438   1.8  christos 
   2439   1.8  christos   bool operator== (const symbol_search &other) const
   2440   1.1  christos   {
   2441   1.1  christos     return compare_search_syms (*this, other) == 0;
   2442   1.1  christos   }
   2443   1.1  christos 
   2444   1.1  christos   /* The block in which the match was found.  Could be, for example,
   2445   1.1  christos      STATIC_BLOCK or GLOBAL_BLOCK.  */
   2446   1.3  christos   int block;
   2447   1.1  christos 
   2448   1.1  christos   /* Information describing what was found.
   2449   1.1  christos 
   2450   1.1  christos      If symbol is NOT NULL, then information was found for this match.  */
   2451   1.1  christos   struct symbol *symbol;
   2452   1.1  christos 
   2453   1.8  christos   /* If msymbol is non-null, then a match was made on something for
   2454   1.8  christos      which only minimal_symbols exist.  */
   2455   1.8  christos   struct bound_minimal_symbol msymbol;
   2456   1.8  christos 
   2457   1.1  christos private:
   2458   1.1  christos 
   2459   1.9  christos   static int compare_search_syms (const symbol_search &sym_a,
   2460   1.9  christos 				  const symbol_search &sym_b);
   2461   1.9  christos };
   2462   1.9  christos 
   2463   1.9  christos /* In order to search for global symbols of a particular kind matching
   2464   1.9  christos    particular regular expressions, create an instance of this structure and
   2465   1.9  christos    call the SEARCH member function.  */
   2466   1.9  christos class global_symbol_searcher
   2467   1.9  christos {
   2468   1.9  christos public:
   2469   1.9  christos 
   2470   1.9  christos   /* Constructor.  */
   2471   1.9  christos   global_symbol_searcher (enum search_domain kind,
   2472   1.9  christos 			  const char *symbol_name_regexp)
   2473   1.9  christos     : m_kind (kind),
   2474   1.9  christos       m_symbol_name_regexp (symbol_name_regexp)
   2475   1.9  christos   {
   2476   1.9  christos     /* The symbol searching is designed to only find one kind of thing.  */
   2477   1.9  christos     gdb_assert (m_kind != ALL_DOMAIN);
   2478   1.9  christos   }
   2479   1.9  christos 
   2480   1.9  christos   /* Set the optional regexp that matches against the symbol type.  */
   2481   1.9  christos   void set_symbol_type_regexp (const char *regexp)
   2482   1.9  christos   {
   2483   1.9  christos     m_symbol_type_regexp = regexp;
   2484   1.9  christos   }
   2485   1.9  christos 
   2486   1.9  christos   /* Set the flag to exclude minsyms from the search results.  */
   2487   1.9  christos   void set_exclude_minsyms (bool exclude_minsyms)
   2488   1.9  christos   {
   2489   1.9  christos     m_exclude_minsyms = exclude_minsyms;
   2490   1.9  christos   }
   2491   1.9  christos 
   2492   1.9  christos   /* Set the maximum number of search results to be returned.  */
   2493   1.9  christos   void set_max_search_results (size_t max_search_results)
   2494   1.9  christos   {
   2495   1.9  christos     m_max_search_results = max_search_results;
   2496   1.9  christos   }
   2497   1.9  christos 
   2498   1.9  christos   /* Search the symbols from all objfiles in the current program space
   2499   1.9  christos      looking for matches as defined by the current state of this object.
   2500   1.9  christos 
   2501   1.9  christos      Within each file the results are sorted locally; each symtab's global
   2502   1.9  christos      and static blocks are separately alphabetized.  Duplicate entries are
   2503   1.9  christos      removed.  */
   2504   1.9  christos   std::vector<symbol_search> search () const;
   2505   1.9  christos 
   2506   1.9  christos   /* The set of source files to search in for matching symbols.  This is
   2507   1.9  christos      currently public so that it can be populated after this object has
   2508   1.9  christos      been constructed.  */
   2509   1.9  christos   std::vector<const char *> filenames;
   2510  1.10  christos 
   2511   1.9  christos private:
   2512   1.9  christos   /* The kind of symbols are we searching for.
   2513   1.9  christos      VARIABLES_DOMAIN - Search all symbols, excluding functions, type
   2514   1.9  christos 			names, and constants (enums).
   2515   1.9  christos      FUNCTIONS_DOMAIN - Search all functions..
   2516   1.9  christos      TYPES_DOMAIN     - Search all type names.
   2517   1.9  christos      MODULES_DOMAIN   - Search all Fortran modules.
   2518   1.9  christos      ALL_DOMAIN       - Not valid for this function.  */
   2519   1.9  christos   enum search_domain m_kind;
   2520   1.9  christos 
   2521   1.9  christos   /* Regular expression to match against the symbol name.  */
   2522   1.9  christos   const char *m_symbol_name_regexp = nullptr;
   2523   1.9  christos 
   2524   1.9  christos   /* Regular expression to match against the symbol type.  */
   2525   1.9  christos   const char *m_symbol_type_regexp = nullptr;
   2526   1.9  christos 
   2527   1.9  christos   /* When this flag is false then minsyms that match M_SYMBOL_REGEXP will
   2528   1.9  christos      be included in the results, otherwise they are excluded.  */
   2529   1.9  christos   bool m_exclude_minsyms = false;
   2530   1.9  christos 
   2531   1.9  christos   /* Maximum number of search results.  We currently impose a hard limit
   2532   1.9  christos      of SIZE_MAX, there is no "unlimited".  */
   2533   1.9  christos   size_t m_max_search_results = SIZE_MAX;
   2534   1.9  christos 
   2535   1.9  christos   /* Expand symtabs in OBJFILE that match PREG, are of type M_KIND.  Return
   2536   1.9  christos      true if any msymbols were seen that we should later consider adding to
   2537   1.9  christos      the results list.  */
   2538   1.9  christos   bool expand_symtabs (objfile *objfile,
   2539   1.9  christos 		       const gdb::optional<compiled_regex> &preg) const;
   2540   1.9  christos 
   2541   1.9  christos   /* Add symbols from symtabs in OBJFILE that match PREG, and TREG, and are
   2542   1.9  christos      of type M_KIND, to the results set RESULTS_SET.  Return false if we
   2543   1.9  christos      stop adding results early due to having already found too many results
   2544   1.9  christos      (based on M_MAX_SEARCH_RESULTS limit), otherwise return true.
   2545   1.9  christos      Returning true does not indicate that any results were added, just
   2546   1.9  christos      that we didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS.  */
   2547   1.9  christos   bool add_matching_symbols (objfile *objfile,
   2548   1.9  christos 			     const gdb::optional<compiled_regex> &preg,
   2549   1.9  christos 			     const gdb::optional<compiled_regex> &treg,
   2550   1.9  christos 			     std::set<symbol_search> *result_set) const;
   2551   1.9  christos 
   2552   1.9  christos   /* Add msymbols from OBJFILE that match PREG and M_KIND, to the results
   2553   1.9  christos      vector RESULTS.  Return false if we stop adding results early due to
   2554   1.9  christos      having already found too many results (based on max search results
   2555   1.9  christos      limit M_MAX_SEARCH_RESULTS), otherwise return true.  Returning true
   2556   1.9  christos      does not indicate that any results were added, just that we didn't
   2557   1.9  christos      _not_ add a result due to reaching MAX_SEARCH_RESULTS.  */
   2558   1.9  christos   bool add_matching_msymbols (objfile *objfile,
   2559   1.9  christos 			      const gdb::optional<compiled_regex> &preg,
   2560   1.9  christos 			      std::vector<symbol_search> *results) const;
   2561   1.9  christos 
   2562   1.9  christos   /* Return true if MSYMBOL is of type KIND.  */
   2563   1.9  christos   static bool is_suitable_msymbol (const enum search_domain kind,
   2564   1.9  christos 				   const minimal_symbol *msymbol);
   2565   1.9  christos };
   2566   1.9  christos 
   2567   1.9  christos /* When searching for Fortran symbols within modules (functions/variables)
   2568   1.9  christos    we return a vector of this type.  The first item in the pair is the
   2569   1.9  christos    module symbol, and the second item is the symbol for the function or
   2570   1.9  christos    variable we found.  */
   2571   1.9  christos typedef std::pair<symbol_search, symbol_search> module_symbol_search;
   2572   1.9  christos 
   2573   1.9  christos /* Searches the symbols to find function and variables symbols (depending
   2574   1.9  christos    on KIND) within Fortran modules.  The MODULE_REGEXP matches against the
   2575   1.9  christos    name of the module, REGEXP matches against the name of the symbol within
   2576   1.9  christos    the module, and TYPE_REGEXP matches against the type of the symbol
   2577   1.9  christos    within the module.  */
   2578   1.9  christos extern std::vector<module_symbol_search> search_module_symbols
   2579   1.9  christos 	(const char *module_regexp, const char *regexp,
   2580   1.9  christos 	 const char *type_regexp, search_domain kind);
   2581   1.9  christos 
   2582   1.9  christos /* Convert a global or static symbol SYM (based on BLOCK, which should be
   2583   1.9  christos    either GLOBAL_BLOCK or STATIC_BLOCK) into a string for use in 'info'
   2584   1.9  christos    type commands (e.g. 'info variables', 'info functions', etc).  KIND is
   2585   1.9  christos    the type of symbol that was searched for which gave us SYM.  */
   2586   1.8  christos 
   2587   1.8  christos extern std::string symbol_to_info_string (struct symbol *sym, int block,
   2588   1.1  christos 					  enum search_domain kind);
   2589   1.9  christos 
   2590   1.9  christos extern bool treg_matches_sym_type_name (const compiled_regex &treg,
   2591   1.3  christos 					const struct symbol *sym);
   2592   1.1  christos 
   2593   1.9  christos /* The name of the ``main'' function.  */
   2594   1.9  christos extern const char *main_name ();
   2595   1.3  christos extern enum language main_language (void);
   2596   1.3  christos 
   2597   1.9  christos /* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global or static blocks,
   2598   1.6  christos    as specified by BLOCK_INDEX.
   2599   1.3  christos    This searches MAIN_OBJFILE as well as any associated separate debug info
   2600   1.6  christos    objfiles of MAIN_OBJFILE.
   2601   1.3  christos    BLOCK_INDEX can be GLOBAL_BLOCK or STATIC_BLOCK.
   2602   1.9  christos    Upon success fixes up the symbol's section if necessary.  */
   2603   1.3  christos 
   2604   1.3  christos extern struct block_symbol
   2605   1.1  christos   lookup_global_symbol_from_objfile (struct objfile *main_objfile,
   2606   1.1  christos 				     enum block_enum block_index,
   2607   1.1  christos 				     const char *name,
   2608   1.9  christos 				     const domain_enum domain);
   2609   1.1  christos 
   2610   1.1  christos /* Return 1 if the supplied producer string matches the ARM RealView
   2611   1.1  christos    compiler (armcc).  */
   2612   1.1  christos bool producer_is_realview (const char *producer);
   2613   1.1  christos 
   2614   1.1  christos void fixup_section (struct general_symbol_info *ginfo,
   2615  1.10  christos 		    CORE_ADDR addr, struct objfile *objfile);
   2616  1.10  christos 
   2617  1.10  christos extern unsigned int symtab_create_debug;
   2618  1.10  christos 
   2619  1.10  christos /* Print a "symtab-create" debug statement.  */
   2620  1.10  christos 
   2621  1.10  christos #define symtab_create_debug_printf(fmt, ...) \
   2622  1.10  christos   debug_prefixed_printf_cond (symtab_create_debug >= 1, "symtab-create", fmt, ##__VA_ARGS__)
   2623  1.10  christos 
   2624  1.10  christos /* Print a verbose "symtab-create" debug statement, only if
   2625  1.10  christos    "set debug symtab-create" is set to 2 or higher.  */
   2626   1.3  christos 
   2627   1.3  christos #define symtab_create_debug_printf_v(fmt, ...) \
   2628  1.10  christos   debug_prefixed_printf_cond (symtab_create_debug >= 2, "symtab-create", fmt, ##__VA_ARGS__)
   2629  1.10  christos 
   2630  1.10  christos extern unsigned int symbol_lookup_debug;
   2631  1.10  christos 
   2632  1.10  christos /* Return true if symbol-lookup debug is turned on at all.  */
   2633  1.10  christos 
   2634  1.10  christos static inline bool
   2635  1.10  christos symbol_lookup_debug_enabled ()
   2636  1.10  christos {
   2637  1.10  christos   return symbol_lookup_debug > 0;
   2638  1.10  christos }
   2639  1.10  christos 
   2640  1.10  christos /* Return true if symbol-lookup debug is turned to verbose mode.  */
   2641  1.10  christos 
   2642  1.10  christos static inline bool
   2643  1.10  christos symbol_lookup_debug_enabled_v ()
   2644  1.10  christos {
   2645  1.10  christos   return symbol_lookup_debug > 1;
   2646  1.10  christos }
   2647  1.10  christos 
   2648  1.10  christos /* Print a "symbol-lookup" debug statement if symbol_lookup_debug is >= 1.  */
   2649  1.10  christos 
   2650  1.10  christos #define symbol_lookup_debug_printf(fmt, ...) \
   2651  1.10  christos   debug_prefixed_printf_cond (symbol_lookup_debug_enabled (),	\
   2652  1.10  christos 			      "symbol-lookup", fmt, ##__VA_ARGS__)
   2653  1.10  christos 
   2654  1.10  christos /* Print a "symbol-lookup" debug statement if symbol_lookup_debug is >= 2.  */
   2655  1.10  christos 
   2656  1.10  christos #define symbol_lookup_debug_printf_v(fmt, ...) \
   2657  1.10  christos   debug_prefixed_printf_cond (symbol_lookup_debug_enabled_v (), \
   2658  1.10  christos 			      "symbol-lookup", fmt, ##__VA_ARGS__)
   2659  1.10  christos 
   2660  1.10  christos /* Print "symbol-lookup" enter/exit debug statements.  */
   2661   1.9  christos 
   2662   1.1  christos #define SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT \
   2663   1.9  christos   scoped_debug_enter_exit (symbol_lookup_debug_enabled, "symbol-lookup")
   2664   1.9  christos 
   2665   1.1  christos extern bool basenames_may_differ;
   2666   1.9  christos 
   2667   1.9  christos bool compare_filenames_for_search (const char *filename,
   2668   1.6  christos 				   const char *search_name);
   2669   1.7  christos 
   2670   1.7  christos bool compare_glob_filenames_for_search (const char *filename,
   2671   1.7  christos 					const char *search_name);
   2672   1.7  christos 
   2673   1.7  christos bool iterate_over_some_symtabs (const char *name,
   2674   1.1  christos 				const char *real_path,
   2675   1.1  christos 				struct compunit_symtab *first,
   2676   1.7  christos 				struct compunit_symtab *after_last,
   2677   1.1  christos 				gdb::function_view<bool (symtab *)> callback);
   2678   1.7  christos 
   2679   1.7  christos void iterate_over_symtabs (const char *name,
   2680   1.7  christos 			   gdb::function_view<bool (symtab *)> callback);
   2681   1.7  christos 
   2682   1.7  christos 
   2683   1.7  christos std::vector<CORE_ADDR> find_pcs_for_symtab_line
   2684   1.7  christos     (struct symtab *symtab, int line, struct linetable_entry **best_entry);
   2685   1.7  christos 
   2686   1.7  christos /* Prototype for callbacks for LA_ITERATE_OVER_SYMBOLS.  The callback
   2687   1.8  christos    is called once per matching symbol SYM.  The callback should return
   2688   1.1  christos    true to indicate that LA_ITERATE_OVER_SYMBOLS should continue
   2689   1.9  christos    iterating, or false to indicate that the iteration should end.  */
   2690   1.9  christos 
   2691   1.9  christos typedef bool (symbol_found_callback_ftype) (struct block_symbol *bsym);
   2692   1.9  christos 
   2693   1.9  christos /* Iterate over the symbols named NAME, matching DOMAIN, in BLOCK.
   2694   1.9  christos 
   2695   1.9  christos    For each symbol that matches, CALLBACK is called.  The symbol is
   2696   1.9  christos    passed to the callback.
   2697   1.9  christos 
   2698   1.9  christos    If CALLBACK returns false, the iteration ends and this function
   2699   1.8  christos    returns false.  Otherwise, the search continues, and the function
   2700   1.1  christos    eventually returns true.  */
   2701   1.7  christos 
   2702   1.7  christos bool iterate_over_symbols (const struct block *block,
   2703   1.9  christos 			   const lookup_name_info &name,
   2704   1.9  christos 			   const domain_enum domain,
   2705   1.9  christos 			   gdb::function_view<symbol_found_callback_ftype> callback);
   2706   1.9  christos 
   2707   1.9  christos /* Like iterate_over_symbols, but if all calls to CALLBACK return
   2708   1.9  christos    true, then calls CALLBACK one additional time with a block_symbol
   2709   1.9  christos    that has a valid block but a NULL symbol.  */
   2710   1.9  christos 
   2711   1.9  christos bool iterate_over_symbols_terminated
   2712   1.9  christos   (const struct block *block,
   2713   1.7  christos    const lookup_name_info &name,
   2714   1.7  christos    const domain_enum domain,
   2715   1.7  christos    gdb::function_view<symbol_found_callback_ftype> callback);
   2716   1.9  christos 
   2717   1.9  christos /* Storage type used by demangle_for_lookup.  demangle_for_lookup
   2718   1.7  christos    either returns a const char * pointer that points to either of the
   2719   1.7  christos    fields of this type, or a pointer to the input NAME.  This is done
   2720   1.7  christos    this way to avoid depending on the precise details of the storage
   2721   1.7  christos    for the string.  */
   2722   1.9  christos class demangle_result_storage
   2723   1.9  christos {
   2724   1.9  christos public:
   2725   1.7  christos 
   2726   1.9  christos   /* Swap the malloc storage to STR, and return a pointer to the
   2727   1.9  christos      beginning of the new string.  */
   2728   1.7  christos   const char *set_malloc_ptr (gdb::unique_xmalloc_ptr<char> &&str)
   2729   1.7  christos   {
   2730   1.7  christos     m_malloc = std::move (str);
   2731   1.7  christos     return m_malloc.get ();
   2732   1.7  christos   }
   2733   1.7  christos 
   2734   1.7  christos   /* Set the malloc storage to now point at PTR.  Any previous malloc
   2735   1.7  christos      storage is released.  */
   2736   1.7  christos   const char *set_malloc_ptr (char *ptr)
   2737   1.7  christos   {
   2738   1.7  christos     m_malloc.reset (ptr);
   2739   1.7  christos     return ptr;
   2740   1.7  christos   }
   2741   1.7  christos 
   2742   1.7  christos private:
   2743   1.1  christos 
   2744   1.7  christos   /* The storage.  */
   2745   1.7  christos   gdb::unique_xmalloc_ptr<char> m_malloc;
   2746   1.7  christos };
   2747   1.1  christos 
   2748   1.8  christos const char *
   2749   1.8  christos   demangle_for_lookup (const char *name, enum language lang,
   2750   1.8  christos 		       demangle_result_storage &storage);
   2751   1.9  christos 
   2752   1.9  christos /* Test to see if the symbol of language SYMBOL_LANGUAGE specified by
   2753   1.9  christos    SYMNAME (which is already demangled for C++ symbols) matches
   2754   1.8  christos    SYM_TEXT in the first SYM_TEXT_LEN characters.  If so, add it to
   2755   1.8  christos    the current completion list and return true.  Otherwise, return
   2756   1.8  christos    false.  */
   2757   1.8  christos bool completion_list_add_name (completion_tracker &tracker,
   2758   1.8  christos 			       language symbol_language,
   2759   1.8  christos 			       const char *symname,
   2760   1.8  christos 			       const lookup_name_info &lookup_name,
   2761   1.8  christos 			       const char *text, const char *word);
   2762   1.8  christos 
   2763   1.8  christos /* A simple symbol searching class.  */
   2764   1.8  christos 
   2765   1.8  christos class symbol_searcher
   2766   1.8  christos {
   2767   1.8  christos public:
   2768   1.8  christos   /* Returns the symbols found for the search.  */
   2769   1.8  christos   const std::vector<block_symbol> &
   2770   1.8  christos   matching_symbols () const
   2771   1.8  christos   {
   2772   1.8  christos     return m_symbols;
   2773   1.8  christos   }
   2774   1.8  christos 
   2775   1.8  christos   /* Returns the minimal symbols found for the search.  */
   2776   1.8  christos   const std::vector<bound_minimal_symbol> &
   2777   1.8  christos   matching_msymbols () const
   2778   1.8  christos   {
   2779   1.8  christos     return m_minimal_symbols;
   2780   1.8  christos   }
   2781   1.8  christos 
   2782   1.8  christos   /* Search for all symbols named NAME in LANGUAGE with DOMAIN, restricting
   2783   1.8  christos      search to FILE_SYMTABS and SEARCH_PSPACE, both of which may be NULL
   2784   1.8  christos      to search all symtabs and program spaces.  */
   2785   1.8  christos   void find_all_symbols (const std::string &name,
   2786   1.8  christos 			 const struct language_defn *language,
   2787   1.8  christos 			 enum search_domain search_domain,
   2788   1.8  christos 			 std::vector<symtab *> *search_symtabs,
   2789   1.8  christos 			 struct program_space *search_pspace);
   2790   1.8  christos 
   2791   1.8  christos   /* Reset this object to perform another search.  */
   2792   1.8  christos   void reset ()
   2793   1.8  christos   {
   2794   1.8  christos     m_symbols.clear ();
   2795   1.8  christos     m_minimal_symbols.clear ();
   2796   1.8  christos   }
   2797   1.8  christos 
   2798   1.8  christos private:
   2799   1.8  christos   /* Matching debug symbols.  */
   2800   1.8  christos   std::vector<block_symbol>  m_symbols;
   2801   1.8  christos 
   2802  1.10  christos   /* Matching non-debug symbols.  */
   2803  1.10  christos   std::vector<bound_minimal_symbol> m_minimal_symbols;
   2804  1.10  christos };
   2805  1.10  christos 
   2806  1.10  christos /* Class used to encapsulate the filename filtering for the "info sources"
   2807  1.10  christos    command.  */
   2808  1.10  christos 
   2809  1.10  christos struct info_sources_filter
   2810  1.10  christos {
   2811  1.10  christos   /* If filename filtering is being used (see M_C_REGEXP) then which part
   2812  1.10  christos      of the filename is being filtered against?  */
   2813  1.10  christos   enum class match_on
   2814  1.10  christos   {
   2815  1.10  christos     /* Match against the full filename.  */
   2816  1.10  christos     FULLNAME,
   2817  1.10  christos 
   2818  1.10  christos     /* Match only against the directory part of the full filename.  */
   2819  1.10  christos     DIRNAME,
   2820  1.10  christos 
   2821  1.10  christos     /* Match only against the basename part of the full filename.  */
   2822  1.10  christos     BASENAME
   2823  1.10  christos   };
   2824  1.10  christos 
   2825  1.10  christos   /* Create a filter of MATCH_TYPE using regular expression REGEXP.  If
   2826  1.10  christos      REGEXP is nullptr then all files will match the filter and MATCH_TYPE
   2827  1.10  christos      is ignored.
   2828  1.10  christos 
   2829  1.10  christos      The string pointed too by REGEXP must remain live and unchanged for
   2830  1.10  christos      this lifetime of this object as the object only retains a copy of the
   2831  1.10  christos      pointer.  */
   2832  1.10  christos   info_sources_filter (match_on match_type, const char *regexp);
   2833  1.10  christos 
   2834  1.10  christos   DISABLE_COPY_AND_ASSIGN (info_sources_filter);
   2835  1.10  christos 
   2836  1.10  christos   /* Does FULLNAME match the filter defined by this object, return true if
   2837  1.10  christos      it does, otherwise, return false.  If there is no filtering defined
   2838  1.10  christos      then this function will always return true.  */
   2839  1.10  christos   bool matches (const char *fullname) const;
   2840  1.10  christos 
   2841  1.10  christos private:
   2842  1.10  christos 
   2843  1.10  christos   /* The type of filtering in place.  */
   2844  1.10  christos   match_on m_match_type;
   2845  1.10  christos 
   2846  1.10  christos   /* Points to the original regexp used to create this filter.  */
   2847  1.10  christos   const char *m_regexp;
   2848  1.10  christos 
   2849  1.10  christos   /* A compiled version of M_REGEXP.  This object is only given a value if
   2850  1.10  christos      M_REGEXP is not nullptr and is not the empty string.  */
   2851  1.10  christos   gdb::optional<compiled_regex> m_c_regexp;
   2852  1.10  christos };
   2853  1.10  christos 
   2854  1.10  christos /* Perform the core of the 'info sources' command.
   2855  1.10  christos 
   2856  1.10  christos    FILTER is used to perform regular expression based filtering on the
   2857  1.10  christos    source files that will be displayed.
   2858  1.10  christos 
   2859  1.10  christos    Output is written to UIOUT in CLI or MI style as appropriate.  */
   2860  1.10  christos 
   2861   1.1  christos extern void info_sources_worker (struct ui_out *uiout,
   2862                 				 bool group_by_objfile,
   2863                 				 const info_sources_filter &filter);
   2864                 
   2865                 #endif /* !defined(SYMTAB_H) */
   2866