* sparc64-tdep.h (sparc64_regnum): Fix comment.
[deliverable/binutils-gdb.git] / gdb / symtab.h
index 4330b96225750380371c61863e55e27722a00a80..da301254749e54bd328fca28edca88bd0b7b06fb 100644 (file)
@@ -35,24 +35,55 @@ struct blockvector;
 struct axs_value;
 struct agent_expr;
 
-/* Don't do this; it means that if some .o's are compiled with GNU C
-   and some are not (easy to do accidentally the way we configure
-   things; also it is a pain to have to "make clean" every time you
-   want to switch compilers), then GDB dies a horrible death.  */
-/* GNU C supports enums that are bitfields.  Some compilers don't. */
-#if 0 && defined(__GNUC__) && !defined(BYTE_BITFIELD)
-#define        BYTE_BITFIELD   :8;
-#else
-#define        BYTE_BITFIELD           /*nothing */
-#endif
+/* Some of the structures in this file are space critical.
+   The space-critical structures are:
+
+     struct general_symbol_info
+     struct symbol
+     struct partial_symbol
+
+   These structures are layed 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. */
+
+/* Rearranged: used ENUM_BITFIELD and rearranged field order in
+   all the space critical structures (plus struct minimal_symbol).
+   Memory usage dropped from 99360768 bytes to 90001408 bytes.
+   I measured this with before-and-after tests of
+   "HEAD-old-gdb -readnow HEAD-old-gdb" and
+   "HEAD-new-gdb -readnow HEAD-old-gdb" on native i686-pc-linux-gnu,
+   red hat linux 8, with LD_LIBRARY_PATH=/usr/lib/debug,
+   typing "maint space 1" at the first command prompt.
+
+   Here is another measurement (from andrew c):
+     # no /usr/lib/debug, just plain glibc, like a normal user
+     gdb HEAD-old-gdb
+     (gdb) break internal_error
+     (gdb) run
+     (gdb) maint internal-error
+     (gdb) backtrace
+     (gdb) maint space 1
+
+   gdb gdb_6_0_branch  2003-08-19  space used: 8896512
+   gdb HEAD            2003-08-19  space used: 8904704
+   gdb HEAD            2003-08-21  space used: 8396800 (+symtab.h)
+   gdb HEAD            2003-08-21  space used: 8265728 (+gdbtypes.h)
+
+   The third line shows the savings from the optimizations in symtab.h.
+   The fourth line shows the savings from the optimizations in
+   gdbtypes.h.  Both optimizations are in gdb HEAD now.
+
+   --chastain 2003-08-21  */
+
+
 
 /* Define a structure for the information that is common to all symbol types,
    including minimal symbols, partial symbols, and full symbols.  In a
    multilanguage environment, some language specific information may need to
-   be recorded along with each symbol.
+   be recorded along with each symbol. */
 
-   These fields are ordered to encourage good packing, since we frequently
-   have tens or hundreds of thousands of these.  */
+/* This structure is space critical.  See space comments at the top. */
 
 struct general_symbol_info
 {
@@ -107,7 +138,7 @@ struct general_symbol_info
      This is used to select one of the fields from the language specific
      union above. */
 
-  enum language language BYTE_BITFIELD;
+  ENUM_BITFIELD(language) language : 8;
 
   /* Which section is this symbol in?  This is an index into
      section_offsets for this objfile.  Negative means that the symbol
@@ -219,16 +250,6 @@ extern char *symbol_demangled_name (struct general_symbol_info *symbol);
    "foo :: bar (int, long)".
    Evaluates to zero if the match fails, or nonzero if it succeeds. */
 
-/* FIXME: carlton/2003-02-27: This is an unholy mixture of linkage
-   names and natural names.  If you want to test the linkage names
-   with strcmp, do that.  If you want to test the natural names with
-   strcmp_iw, use SYMBOL_MATCHES_NATURAL_NAME.  */
-
-#define DEPRECATED_SYMBOL_MATCHES_NAME(symbol, name)                   \
-  (STREQ (DEPRECATED_SYMBOL_NAME (symbol), (name))                     \
-   || (SYMBOL_DEMANGLED_NAME (symbol) != NULL                          \
-       && strcmp_iw (SYMBOL_DEMANGLED_NAME (symbol), (name)) == 0))
-
 /* Macro that tests a symbol for a match against a specified name
    string.  It tests against SYMBOL_NATURAL_NAME, and it ignores
    whitespace and trailing parentheses.  (See strcmp_iw for details
@@ -237,6 +258,37 @@ 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)
 
+/* 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
+   guess when it can't figure out which is a better match between two
+   types (mst_data versus mst_bss) for example.  Since the minimal
+   symbol info is sometimes derived from the BFD library's view of a
+   file, we need to live with what information bfd supplies. */
+
+enum minimal_symbol_type
+{
+  mst_unknown = 0,             /* Unknown type, the default */
+  mst_text,                    /* Generally executable instructions */
+  mst_data,                    /* Generally initialized data */
+  mst_bss,                     /* Generally uninitialized data */
+  mst_abs,                     /* Generally absolute (nonrelocatable) */
+  /* GDB uses mst_solib_trampoline for the start address of a shared
+     library trampoline entry.  Breakpoints for shared library functions
+     are put there if the shared library is not yet loaded.
+     After the shared library is loaded, lookup_minimal_symbol will
+     prefer the minimal symbol from the shared library (usually
+     a mst_text symbol) over the mst_solib_trampoline symbol, and the
+     breakpoints will be moved to their true address in the shared
+     library via breakpoint_re_set.  */
+  mst_solib_trampoline,                /* Shared library trampoline code */
+  /* For the mst_file* types, the names are only guaranteed to be unique
+     within a given .o file.  */
+  mst_file_text,               /* Static version of mst_text */
+  mst_file_data,               /* Static version of mst_data */
+  mst_file_bss                 /* Static version of mst_bss */
+};
+
 /* Define a simple structure used to hold some very basic information about
    all defined global symbols (text, data, bss, abs, etc).  The only required
    information is the general_symbol_info.
@@ -278,37 +330,9 @@ struct minimal_symbol
   char *filename;
 #endif
 
-  /* Classification types for this 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 guess when it can't figure out
-     which is a better match between two types (mst_data versus mst_bss) for
-     example.  Since the minimal symbol info is sometimes derived from the
-     BFD library's view of a file, we need to live with what information bfd
-     supplies. */
+  /* Classification type for this minimal symbol.  */
 
-  enum minimal_symbol_type
-  {
-    mst_unknown = 0,           /* Unknown type, the default */
-    mst_text,                  /* Generally executable instructions */
-    mst_data,                  /* Generally initialized data */
-    mst_bss,                   /* Generally uninitialized data */
-    mst_abs,                   /* Generally absolute (nonrelocatable) */
-    /* GDB uses mst_solib_trampoline for the start address of a shared
-       library trampoline entry.  Breakpoints for shared library functions
-       are put there if the shared library is not yet loaded.
-       After the shared library is loaded, lookup_minimal_symbol will
-       prefer the minimal symbol from the shared library (usually
-       a mst_text symbol) over the mst_solib_trampoline symbol, and the
-       breakpoints will be moved to their true address in the shared
-       library via breakpoint_re_set.  */
-    mst_solib_trampoline,      /* Shared library trampoline code */
-    /* For the mst_file* types, the names are only guaranteed to be unique
-       within a given .o file.  */
-    mst_file_text,             /* Static version of mst_text */
-    mst_file_data,             /* Static version of mst_data */
-    mst_file_bss               /* Static version of mst_bss */
-  }
-  type BYTE_BITFIELD;
+  ENUM_BITFIELD(minimal_symbol_type) type : 8;
 
   /* Minimal symbols with the same hash key are kept on a linked
      list.  This is the link.  */
@@ -328,50 +352,50 @@ struct minimal_symbol
 
 /* Represent one symbol name; a variable, constant, function or typedef.  */
 
-/* Different name spaces for symbols.  Looking up a symbol specifies a
-   namespace and ignores symbol definitions in other name spaces. */
+/* Different name domains for symbols.  Looking up a symbol specifies a
+   domain and ignores symbol definitions in other name domains. */
 
-typedef enum
+typedef enum domain_enum_tag
 {
-  /* UNDEF_NAMESPACE is used when a namespace has not been discovered or
+  /* UNDEF_DOMAIN is used when a domain has not been discovered or
      none of the following apply.  This usually indicates an error either
      in the symbol information or in gdb's handling of symbols. */
 
-  UNDEF_NAMESPACE,
+  UNDEF_DOMAIN,
 
-  /* VAR_NAMESPACE is the usual namespace.  In C, this contains variables,
+  /* VAR_DOMAIN is the usual domain.  In C, this contains variables,
      function names, typedef names and enum type values. */
 
-  VAR_NAMESPACE,
+  VAR_DOMAIN,
 
-  /* STRUCT_NAMESPACE is used in C to hold struct, union and enum type names.
+  /* STRUCT_DOMAIN is used in C to hold struct, union and enum type names.
      Thus, if `struct foo' is used in a C program, it produces a symbol named
-     `foo' in the STRUCT_NAMESPACE. */
+     `foo' in the STRUCT_DOMAIN. */
 
-  STRUCT_NAMESPACE,
+  STRUCT_DOMAIN,
 
-  /* LABEL_NAMESPACE may be used for names of labels (for gotos);
+  /* LABEL_DOMAIN may be used for names of labels (for gotos);
      currently it is not used and labels are not recorded at all.  */
 
-  LABEL_NAMESPACE,
+  LABEL_DOMAIN,
 
-  /* Searching namespaces. These overlap with VAR_NAMESPACE, providing
+  /* Searching domains. These overlap with VAR_DOMAIN, providing
      some granularity with the search_symbols function. */
 
-  /* Everything in VAR_NAMESPACE minus FUNCTIONS_-, TYPES_-, and
-     METHODS_NAMESPACE */
-  VARIABLES_NAMESPACE,
+  /* Everything in VAR_DOMAIN minus FUNCTIONS_-, TYPES_-, and
+     METHODS_DOMAIN */
+  VARIABLES_DOMAIN,
 
   /* All functions -- for some reason not methods, though. */
-  FUNCTIONS_NAMESPACE,
+  FUNCTIONS_DOMAIN,
 
   /* All defined types */
-  TYPES_NAMESPACE,
+  TYPES_DOMAIN,
 
   /* All class methods -- why is this separated out? */
-  METHODS_NAMESPACE
+  METHODS_DOMAIN
 }
-namespace_enum;
+domain_enum;
 
 /* An address-class says where to find the value of a symbol.  */
 
@@ -404,8 +428,9 @@ enum address_class
   /* Value is in register number SYMBOL_VALUE.  Just like LOC_REGISTER
      except this is an argument.  Probably the cleaner way to handle
      this would be to separate address_class (which would include
-     separate ARG and LOCAL to deal with FRAME_ARGS_ADDRESS versus
-     FRAME_LOCALS_ADDRESS), and an is_argument flag.
+     separate ARG and LOCAL to deal with the frame's arguments
+     (get_frame_args_address) versus the frame's locals
+     (get_frame_locals_address), and an is_argument flag.
 
      For some symbol formats (stabs, for some compilers at least),
      the compiler generates two symbols, an argument and a register.
@@ -427,8 +452,8 @@ enum address_class
 
   LOC_LOCAL,
 
-  /* Value not used; definition in SYMBOL_TYPE.  Symbols in the namespace
-     STRUCT_NAMESPACE all have this class.  */
+  /* Value not used; definition in SYMBOL_TYPE.  Symbols in the domain
+     STRUCT_DOMAIN all have this class.  */
 
   LOC_TYPEDEF,
 
@@ -449,9 +474,9 @@ enum address_class
 
   /* Value is arg at SYMBOL_VALUE offset in stack frame. Differs from
      LOC_LOCAL in that symbol is an argument; differs from LOC_ARG in
-     that we find it in the frame (FRAME_LOCALS_ADDRESS), not in the
-     arglist (FRAME_ARGS_ADDRESS).  Added for i960, which passes args
-     in regs then copies to frame.  */
+     that we find it in the frame (get_frame_locals_address), not in
+     the arglist (get_frame_args_address).  Added for i960, which
+     passes args in regs then copies to frame.  */
 
   LOC_LOCAL_ARG,
 
@@ -491,14 +516,6 @@ enum address_class
 
   LOC_HP_THREAD_LOCAL_STATIC,
 
-  /* Value is at a thread-specific location calculated by a
-     target-specific method.  SYMBOL_OBJFILE gives the object file
-     in which the symbol is defined; the symbol's value is the
-     offset into that objfile's thread-local storage for the current
-     thread.  */
-      
-  LOC_THREAD_LOCAL_STATIC,
-
   /* The variable does not actually exist in the program.
      The value is ignored.  */
 
@@ -582,6 +599,8 @@ struct alias_list
   struct alias_list *next;
 };
 
+/* This structure is space critical.  See space comments at the top. */
+
 struct symbol
 {
 
@@ -593,18 +612,13 @@ struct symbol
 
   struct type *type;
 
-  /* Name space code.  */
+  /* Domain code.  */
 
-#ifdef __MFC4__
-  /* FIXME: don't conflict with C++'s namespace */
-  /* would be safer to do a global change for all namespace identifiers. */
-#define namespace _namespace
-#endif
-  namespace_enum namespace BYTE_BITFIELD;
+  ENUM_BITFIELD(domain_enum_tag) domain : 6;
 
   /* Address class */
 
-  enum address_class aclass BYTE_BITFIELD;
+  ENUM_BITFIELD(address_class) aclass : 6;
 
   /* Line number of definition.  FIXME:  Should we really make the assumption
      that nobody will try to debug files longer than 64K lines?  What about
@@ -620,12 +634,6 @@ struct symbol
     /* Used by LOC_BASEREG and LOC_BASEREG_ARG.  */
     short basereg;
 
-    /* Used by LOC_THREAD_LOCAL_STATIC.  The objfile in which this
-       symbol is defined.  To find a thread-local variable (e.g., a
-       variable declared with the `__thread' storage class), we may
-       need to know which object file it's in.  */
-    struct objfile *objfile;
-
     /* 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
@@ -656,7 +664,7 @@ struct symbol
 };
 
 
-#define SYMBOL_NAMESPACE(symbol)       (symbol)->namespace
+#define SYMBOL_DOMAIN(symbol)  (symbol)->domain
 #define SYMBOL_CLASS(symbol)           (symbol)->aclass
 #define SYMBOL_TYPE(symbol)            (symbol)->type
 #define SYMBOL_LINE(symbol)            (symbol)->line
@@ -667,13 +675,15 @@ struct symbol
 #define SYMBOL_LOCATION_BATON(symbol)   (symbol)->aux_value.loc.baton
 #define SYMBOL_LOCATION_FUNCS(symbol)   (symbol)->aux_value.loc.funcs
 \f
-/* A partial_symbol records the name, namespace, and address class of
+/* A partial_symbol records the name, domain, and address class of
    symbols whose types we have not parsed yet.  For functions, it also
    contains their memory address, so we can find them from a PC value.
    Each partial_symbol sits in a partial_symtab, all of which are chained
    on a  partial symtab list and which points to the corresponding 
    normal symtab once the partial_symtab has been referenced.  */
 
+/* This structure is space critical.  See space comments at the top. */
+
 struct partial_symbol
 {
 
@@ -683,15 +693,15 @@ struct partial_symbol
 
   /* Name space code.  */
 
-  namespace_enum namespace BYTE_BITFIELD;
+  ENUM_BITFIELD(domain_enum_tag) domain : 6;
 
   /* Address class (for info_symbols) */
 
-  enum address_class aclass BYTE_BITFIELD;
+  ENUM_BITFIELD(address_class) aclass : 6;
 
 };
 
-#define PSYMBOL_NAMESPACE(psymbol)     (psymbol)->namespace
+#define PSYMBOL_DOMAIN(psymbol)        (psymbol)->domain
 #define PSYMBOL_CLASS(psymbol)         (psymbol)->aclass
 \f
 
@@ -758,9 +768,6 @@ struct section_offsets
   (sizeof (struct section_offsets) \
    + sizeof (((struct section_offsets *) 0)->offsets) * ((n)-1))
 
-/* The maximum possible size of a section_offsets table.  */
-#define SIZEOF_SECTION_OFFSETS (SIZEOF_N_SECTION_OFFSETS (SECT_OFF_MAX))
-
 /* Each source file or header is represented by a struct symtab. 
    These objects are chained through the `next' field.  */
 
@@ -819,10 +826,10 @@ struct symtab
   }
   free_code;
 
-  /* Pointer to one block of storage to be freed, if nonzero.  */
-  /* This is IN ADDITION to the action indicated by free_code.  */
+  /* A function to call to free space, if necessary.  This is IN
+     ADDITION to the action indicated by free_code.  */
 
-  char *free_ptr;
+  void (*free_func)(struct symtab *symtab);
 
   /* Total number of lines found in source file.  */
 
@@ -1000,14 +1007,60 @@ extern struct symtab *lookup_symtab (const char *);
 /* lookup a symbol by name (optional block, optional symtab) */
 
 extern struct symbol *lookup_symbol (const char *, const struct block *,
-                                    const namespace_enum, int *,
+                                    const domain_enum, int *,
                                     struct symtab **);
 
+/* A default version of lookup_symbol_nonlocal for use by languages
+   that can't think of anything better to do.  */
+
+extern struct symbol *basic_lookup_symbol_nonlocal (const char *,
+                                                   const char *,
+                                                   const struct block *,
+                                                   const domain_enum,
+                                                   struct symtab **);
+
+/* Some helper functions for languages that need to write their own
+   lookup_symbol_nonlocal functions.  */
+
+/* Lookup a symbol in the static block associated to BLOCK, if there
+   is one; do nothing if BLOCK is NULL or a global block.  */
+
+extern struct symbol *lookup_symbol_static (const char *name,
+                                           const char *linkage_name,
+                                           const struct block *block,
+                                           const domain_enum domain,
+                                           struct symtab **symtab);
+
+/* Lookup a symbol in all files' global blocks (searching psymtabs if
+   necessary).  */
+
+extern struct symbol *lookup_symbol_global (const char *name,
+                                           const char *linkage_name,
+                                           const domain_enum domain,
+                                           struct symtab **symtab);
+
+/* Lookup a symbol within the block BLOCK.  This, unlike
+   lookup_symbol_block, will set SYMTAB and BLOCK_FOUND correctly, and
+   will fix up the symbol if necessary.  */
+
+extern struct symbol *lookup_symbol_aux_block (const char *name,
+                                              const char *linkage_name,
+                                              const struct block *block,
+                                              const domain_enum domain,
+                                              struct symtab **symtab);
+
+/* Lookup a partial symbol.  */
+
+extern struct partial_symbol *lookup_partial_symbol (struct partial_symtab *,
+                                                    const char *,
+                                                    const char *, int,
+                                                    domain_enum);
+
 /* lookup a symbol by name, within a specified block */
 
 extern struct symbol *lookup_block_symbol (const struct block *, const char *,
                                           const char *,
-                                          const namespace_enum);
+                                          const domain_enum);
 
 /* lookup a [struct, union, enum] by name, within a specified block */
 
@@ -1265,8 +1318,6 @@ extern char **make_symbol_completion_list (char *, char *);
 
 extern char **make_file_symbol_completion_list (char *, char *, char *);
 
-extern struct symbol **make_symbol_overload_list (struct symbol *);
-
 extern char **make_source_files_completion_list (char *, char *);
 
 /* symtab.c */
@@ -1320,7 +1371,7 @@ struct symbol_search
   struct symbol_search *next;
 };
 
-extern void search_symbols (char *, namespace_enum, int, char **,
+extern void search_symbols (char *, domain_enum, int, char **,
                            struct symbol_search **);
 extern void free_search_symbols (struct symbol_search *);
 extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search
This page took 0.040538 seconds and 4 git commands to generate.