2008-03-25 Pedro Alves <pedro@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / symtab.h
index 3723559cbc3bb8a6df6480203314db1f2cc85f79..c19e74124c2cc9abf84ad252a4668f62bd480a5e 100644 (file)
@@ -1,14 +1,14 @@
 /* Symbol table definitions for GDB.
 
-   Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
-   Foundation, Inc.
+   Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -17,9 +17,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #if !defined (SYMTAB_H)
 #define SYMTAB_H 1
@@ -42,7 +40,7 @@ struct agent_expr;
      struct symbol
      struct partial_symbol
 
-   These structures are layed out to encourage good packing.
+   These structures are laid out to encourage good packing.
    They use ENUM_BITFIELD and short int fields, and they order the
    structure members so that fields less than a word are next
    to each other so they can be packed together. */
@@ -88,10 +86,10 @@ struct agent_expr;
 struct general_symbol_info
 {
   /* Name of the symbol.  This is a required field.  Storage for the
-     name is allocated on the psymbol_obstack or symbol_obstack for
-     the associated objfile.  For languages like C++ that make a
-     distinction between the mangled name and demangled name, this is
-     the mangled name.  */
+     name is allocated on the objfile_obstack for the associated
+     objfile.  For languages like C++ that make a distinction between
+     the mangled name and demangled name, this is the mangled
+     name.  */
 
   char *name;
 
@@ -110,7 +108,7 @@ struct general_symbol_info
 
     struct block *block;
 
-    char *bytes;
+    gdb_byte *bytes;
 
     CORE_ADDR address;
 
@@ -258,6 +256,20 @@ extern char *symbol_demangled_name (struct general_symbol_info *symbol);
 #define SYMBOL_MATCHES_NATURAL_NAME(symbol, name)                      \
   (strcmp_iw (SYMBOL_NATURAL_NAME (symbol), (name)) == 0)
 
+/* Macro that returns the name to be used when sorting and searching symbols. 
+   In  C++, Chill, and Java, we search for the demangled form of a name,
+   and so sort symbols accordingly.  In Ada, however, we search by mangled
+   name.  If there is no distinct demangled name, then SYMBOL_SEARCH_NAME
+   returns the same value (same pointer) as SYMBOL_LINKAGE_NAME. */
+#define SYMBOL_SEARCH_NAME(symbol)                                      \
+   (symbol_search_name (&(symbol)->ginfo))
+extern char *symbol_search_name (const struct general_symbol_info *);
+
+/* Analogous to SYMBOL_MATCHES_NATURAL_NAME, but uses the search
+   name.  */
+#define SYMBOL_MATCHES_SEARCH_NAME(symbol, name)                       \
+  (strcmp_iw (SYMBOL_SEARCH_NAME (symbol), (name)) == 0)
+
 /* Classification types for a minimal symbol.  These should be taken as
    "advisory only", since if gdb can't easily figure out a
    classification it simply selects mst_unknown.  It may also have to
@@ -311,12 +323,13 @@ struct minimal_symbol
 
   struct general_symbol_info ginfo;
 
-  /* The info field is available for caching machine-specific information
-     so it doesn't have to rederive the info constantly (over a serial line).
-     It is initialized to zero and stays that way until target-dependent code
-     sets it.  Storage for any data pointed to by this field should be allo-
-     cated on the symbol_obstack for the associated objfile.  
-     The type would be "void *" except for reasons of compatibility with older
+  /* The info field is available for caching machine-specific
+     information so it doesn't have to rederive the info constantly
+     (over a serial line).  It is initialized to zero and stays that
+     way until target-dependent code sets it.  Storage for any data
+     pointed to by this field should be allocated on the
+     objfile_obstack for the associated objfile.  The type would be
+     "void *" except for reasons of compatibility with older
      compilers.  This field is optional.
 
      Currently, the AMD 29000 tdep.c uses it to remember things it has decoded
@@ -325,10 +338,14 @@ struct minimal_symbol
 
   char *info;
 
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
+  /* Size of this symbol.  end_psymtab in dbxread.c uses this
+     information to calculate the end of the partial symtab based on the
+     address of the last symbol plus the size of the last symbol.  */
+
+  unsigned long size;
+
   /* Which source file is this symbol in?  Only relevant for mst_file_*.  */
   char *filename;
-#endif
 
   /* Classification type for this minimal symbol.  */
 
@@ -346,6 +363,7 @@ struct minimal_symbol
 };
 
 #define MSYMBOL_INFO(msymbol)          (msymbol)->info
+#define MSYMBOL_SIZE(msymbol)          (msymbol)->size
 #define MSYMBOL_TYPE(msymbol)          (msymbol)->type
 
 \f
@@ -532,28 +550,19 @@ enum address_class
   LOC_INDIRECT,
 
   /* The variable's address is computed by a set of location
-     functions (see "struct location_funcs" below).  */
+     functions (see "struct symbol_ops" below).  */
   LOC_COMPUTED,
 
   /* Same as LOC_COMPUTED, but for function arguments.  */
   LOC_COMPUTED_ARG
 };
 
-/* A structure of function pointers describing the location of a
-   variable, structure member, or structure base class.
-
-   These functions' BATON arguments are generic data pointers, holding
-   whatever data the functions need --- the code which provides this
-   structure also provides the actual contents of the baton, and
-   decides its form.  However, there may be other rules about where
-   the baton data must be allocated; whoever is pointing to this
-   `struct location_funcs' object will know the rules.  For example,
-   when a symbol S's location is LOC_COMPUTED, then
-   SYMBOL_LOCATION_FUNCS(S) is pointing to a location_funcs structure,
-   and SYMBOL_LOCATION_BATON(S) is the baton, which must be allocated
-   on the same obstack as the symbol itself.  */
-
-struct location_funcs
+/* The methods needed to implement a symbol class.  These methods can
+   use the symbol's .aux_value for additional per-symbol information.
+
+   At present this is only used to implement location expressions.  */
+
+struct symbol_ops
 {
 
   /* Return the value of the variable SYMBOL, relative to the stack
@@ -583,22 +592,6 @@ struct location_funcs
                              struct axs_value * value);
 };
 
-/* Linked list of symbol's live ranges. */
-
-struct range_list
-{
-  CORE_ADDR start;
-  CORE_ADDR end;
-  struct range_list *next;
-};
-
-/* Linked list of aliases for a particular main/primary symbol.  */
-struct alias_list
-{
-  struct symbol *sym;
-  struct alias_list *next;
-};
-
 /* This structure is space critical.  See space comments at the top. */
 
 struct symbol
@@ -612,11 +605,21 @@ struct symbol
 
   struct type *type;
 
+  /* The symbol table containing this symbol.  This is the file
+     associated with LINE.  */
+  struct symtab *symtab;
+
   /* Domain code.  */
 
   ENUM_BITFIELD(domain_enum_tag) domain : 6;
 
   /* Address class */
+  /* NOTE: cagney/2003-11-02: The fields "aclass" and "ops" contain
+     overlapping information.  By creating a per-aclass ops vector, or
+     using the aclass as an index into an ops table, the aclass and
+     ops fields can be merged.  The latter, for instance, would shave
+     32-bits from each symbol (relative to a symbol lookup, any table
+     index overhead would be in the noise).  */
 
   ENUM_BITFIELD(address_class) aclass : 6;
 
@@ -626,40 +629,33 @@ struct symbol
 
   unsigned short line;
 
-  /* Some symbols require an additional value to be recorded on a per-
-     symbol basis.  Stash those values here. */
+  /* Method's for symbol's of this class.  */
+  /* NOTE: cagney/2003-11-02: See comment above attached to "aclass".  */
+
+  const struct symbol_ops *ops;
+
+  /* Some symbols require additional information to be recorded on a
+     per- symbol basis.  Stash those values here. */
 
   union
   {
     /* Used by LOC_BASEREG and LOC_BASEREG_ARG.  */
     short basereg;
-
-    /* For a LOC_COMPUTED or LOC_COMPUTED_ARG symbol, this is the
-       baton and location_funcs structure to find its location.  For a
-       LOC_BLOCK symbol for a function in a compilation unit compiled
-       with DWARF 2 information, this is information used internally
-       by the DWARF 2 code --- specifically, the location expression
-       for the frame base for this function.  */
+    /* An arbitrary data pointer.  Note that this data must be
+       allocated using the same obstack as the symbol itself.  */
+    /* So far it is only used by LOC_COMPUTED and LOC_COMPUTED_ARG to
+       find the location location information.  For a LOC_BLOCK symbol
+       for a function in a compilation unit compiled with DWARF 2
+       information, this is information used internally by the DWARF 2
+       code --- specifically, the location expression for the frame
+       base for this function.  */
     /* FIXME drow/2003-02-21: For the LOC_BLOCK case, it might be better
        to add a magic symbol to the block containing this information,
        or to have a generic debug info annotation slot for symbols.  */
-    struct
-    {
-      void *baton;
-      struct location_funcs *funcs;
-    } loc;
+    void *ptr;
   }
   aux_value;
 
-
-  /* Link to a list of aliases for this symbol.
-     Only a "primary/main symbol may have aliases.  */
-  struct alias_list *aliases;
-
-  /* List of ranges where this symbol is active.  This is only
-     used by alias symbols at the current time.  */
-  struct range_list *ranges;
-
   struct symbol *hash_next;
 };
 
@@ -668,12 +664,11 @@ struct symbol
 #define SYMBOL_CLASS(symbol)           (symbol)->aclass
 #define SYMBOL_TYPE(symbol)            (symbol)->type
 #define SYMBOL_LINE(symbol)            (symbol)->line
+#define SYMBOL_SYMTAB(symbol)          (symbol)->symtab
 #define SYMBOL_BASEREG(symbol)         (symbol)->aux_value.basereg
 #define SYMBOL_OBJFILE(symbol)          (symbol)->aux_value.objfile
-#define SYMBOL_ALIASES(symbol)         (symbol)->aliases
-#define SYMBOL_RANGES(symbol)          (symbol)->ranges
-#define SYMBOL_LOCATION_BATON(symbol)   (symbol)->aux_value.loc.baton
-#define SYMBOL_LOCATION_FUNCS(symbol)   (symbol)->aux_value.loc.funcs
+#define SYMBOL_OPS(symbol)              (symbol)->ops
+#define SYMBOL_LOCATION_BATON(symbol)   (symbol)->aux_value.ptr
 \f
 /* A partial_symbol records the name, domain, and address class of
    symbols whose types we have not parsed yet.  For functions, it also
@@ -760,7 +755,7 @@ struct section_offsets
 
 #define        ANOFFSET(secoff, whichone) \
    ((whichone == -1) \
-    ? (internal_error (__FILE__, __LINE__, "Section index is uninitialized"), -1) \
+    ? (internal_error (__FILE__, __LINE__, _("Section index is uninitialized")), -1) \
     : secoff->offsets[whichone])
 
 /* The size of a section_offsets table for N sections.  */
@@ -852,9 +847,9 @@ struct symtab
 
   char *debugformat;
 
-  /* String of version information.  May be zero.  */
+  /* String of producer version information.  May be zero.  */
 
-  char *version;
+  char *producer;
 
   /* Full name of file as found by searching the source path.
      NULL if not yet known.  */
@@ -879,7 +874,7 @@ struct symtab
 
    Even after the source file has been read into a symtab, the
    partial_symtab remains around.  They are allocated on an obstack,
-   psymbol_obstack.  FIXME, this is bad for dynamic linking or VxWorks-
+   objfile_obstack.  FIXME, this is bad for dynamic linking or VxWorks-
    style execution of a bunch of .o's.  */
 
 struct partial_symtab
@@ -897,6 +892,10 @@ struct partial_symtab
 
   char *fullname;
 
+  /* Directory in which it was compiled, or NULL if we don't know.  */
+
+  char *dirname;
+
   /* Information about the object file from which symbols should be read.  */
 
   struct objfile *objfile;
@@ -1004,7 +1003,17 @@ extern int asm_demangle;
 
 extern struct symtab *lookup_symtab (const char *);
 
-/* lookup a symbol by name (optional block, optional symtab) */
+/* lookup a symbol by name (optional block, optional symtab) in language */
+
+extern struct symbol *lookup_symbol_in_language (const char *,
+                                                const struct block *,
+                                                const domain_enum,
+                                                enum language,
+                                                int *,
+                                                struct symtab **);
+
+/* lookup a symbol by name (optional block, optional symtab)
+   in the current language */
 
 extern struct symbol *lookup_symbol (const char *, const struct block *,
                                     const domain_enum, int *,
@@ -1036,6 +1045,7 @@ extern struct symbol *lookup_symbol_static (const char *name,
 
 extern struct symbol *lookup_symbol_global (const char *name,
                                            const char *linkage_name,
+                                           const struct block *block,
                                            const domain_enum domain,
                                            struct symtab **symtab);
 
@@ -1087,9 +1097,6 @@ extern int find_pc_partial_function (CORE_ADDR, char **, CORE_ADDR *,
 
 extern void clear_pc_function_cache (void);
 
-extern int find_pc_sect_partial_function (CORE_ADDR, asection *,
-                                         char **, CORE_ADDR *, CORE_ADDR *);
-
 /* from symtab.c: */
 
 /* lookup partial symbol table by filename */
@@ -1127,6 +1134,7 @@ extern int find_pc_line_pc_range (CORE_ADDR, CORE_ADDR *, CORE_ADDR *);
 extern void reread_symbols (void);
 
 extern struct type *lookup_transparent_type (const char *);
+extern struct type *basic_lookup_transparent_type (const char *);
 
 
 /* Macro for name of symbol to indicate a file compiled with gcc. */
@@ -1164,7 +1172,6 @@ extern struct minimal_symbol *lookup_minimal_symbol (const char *,
                                                     struct objfile *);
 
 extern struct minimal_symbol *lookup_minimal_symbol_text (const char *,
-                                                         const char *,
                                                          struct objfile *);
 
 struct minimal_symbol *lookup_minimal_symbol_solib_trampoline (const char *,
@@ -1180,7 +1187,7 @@ extern struct minimal_symbol *lookup_minimal_symbol_by_pc_section (CORE_ADDR,
 extern struct minimal_symbol
   *lookup_solib_trampoline_symbol_by_pc (CORE_ADDR);
 
-extern CORE_ADDR find_solib_trampoline_target (CORE_ADDR);
+extern CORE_ADDR find_solib_trampoline_target (struct frame_info *, CORE_ADDR);
 
 extern void init_minimal_symbol_collection (void);
 
@@ -1203,6 +1210,8 @@ struct symtab_and_line
 
   CORE_ADDR pc;
   CORE_ADDR end;
+  int explicit_pc;
+  int explicit_line;
 };
 
 extern void init_sal (struct symtab_and_line *sal);
@@ -1313,6 +1322,7 @@ extern void forget_cached_source_info (void);
 
 extern void select_source_symtab (struct symtab *);
 
+extern char **default_make_symbol_completion_list (char *, char *);
 extern char **make_symbol_completion_list (char *, char *);
 
 extern char **make_file_symbol_completion_list (char *, char *, char *);
@@ -1321,6 +1331,8 @@ extern char **make_source_files_completion_list (char *, char *);
 
 /* symtab.c */
 
+int matching_bfd_sections (asection *, asection *);
+
 extern struct partial_symtab *find_main_psymtab (void);
 
 extern struct symtab *find_line_symtab (struct symtab *, int, int *, int *);
@@ -1338,6 +1350,8 @@ extern enum language deduce_language_from_filename (char *);
 
 extern int in_prologue (CORE_ADDR pc, CORE_ADDR func_start);
 
+extern CORE_ADDR skip_prologue_using_sal (CORE_ADDR func_addr);
+
 extern struct symbol *fixup_symbol_section (struct symbol *,
                                            struct objfile *);
 
@@ -1383,4 +1397,14 @@ extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search
 extern void set_main_name (const char *name);
 extern /*const */ char *main_name (void);
 
+/* Check global symbols in objfile.  */
+struct symbol *lookup_global_symbol_from_objfile (const struct objfile *objfile,
+                                                 const char *name,
+                                                 const char *linkage_name,
+                                                 const domain_enum domain,
+                                                 struct symtab **symtab);
+
+extern struct symtabs_and_lines
+expand_line_sal (struct symtab_and_line sal);
+
 #endif /* !defined(SYMTAB_H) */
This page took 0.031262 seconds and 4 git commands to generate.