X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;ds=inline;f=gdb%2Fsymtab.h;h=42beb0d56bd8ff13a449aee9337276d029e71223;hb=f70224b53d8d0a8ff7305fbfb8dd6860ae53df69;hp=f8be03b75ab2dfd6ba88b3eeff830cbbf714a32e;hpb=e06963ffef465de9702443d1f3e04b7d34fa5616;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/symtab.h b/gdb/symtab.h index f8be03b75a..42beb0d56b 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1,7 +1,7 @@ /* 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 + 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GDB. @@ -35,32 +35,63 @@ 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 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. */ + +/* 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 { /* 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; @@ -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 @@ -227,6 +258,51 @@ 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 + 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. @@ -249,12 +325,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 @@ -263,42 +340,20 @@ struct minimal_symbol char *info; + /* 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; + #ifdef SOFUN_ADDRESS_MAYBE_MISSING /* Which source file is this symbol in? Only relevant for mst_file_*. */ 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. */ @@ -312,6 +367,7 @@ struct minimal_symbol }; #define MSYMBOL_INFO(msymbol) (msymbol)->info +#define MSYMBOL_SIZE(msymbol) (msymbol)->size #define MSYMBOL_TYPE(msymbol) (msymbol)->type @@ -321,7 +377,7 @@ struct minimal_symbol /* 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_DOMAIN is used when a domain has not been discovered or none of the following apply. This usually indicates an error either @@ -394,8 +450,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. @@ -439,9 +496,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, @@ -481,14 +538,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. */ @@ -512,21 +561,12 @@ enum address_class 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 @@ -556,21 +596,7 @@ 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 { @@ -585,11 +611,17 @@ struct symbol /* Domain code. */ - domain_enum domain BYTE_BITFIELD; + 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 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 @@ -597,46 +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; - - /* 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 - 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; }; @@ -647,10 +666,8 @@ struct symbol #define SYMBOL_LINE(symbol) (symbol)->line #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 /* A partial_symbol records the name, domain, and address class of symbols whose types we have not parsed yet. For functions, it also @@ -659,6 +676,8 @@ struct symbol 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 { @@ -668,11 +687,11 @@ struct partial_symbol /* Name space code. */ - domain_enum domain 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; }; @@ -735,7 +754,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. */ @@ -743,9 +762,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. */ @@ -804,10 +820,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. */ @@ -857,7 +873,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 @@ -875,6 +891,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; @@ -988,6 +1008,52 @@ extern struct symbol *lookup_symbol (const char *, const struct block *, 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 *, @@ -1019,9 +1085,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 */ @@ -1059,6 +1122,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. */ @@ -1096,11 +1160,9 @@ 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 *, - const char *, struct objfile *); @@ -1250,8 +1312,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 */ @@ -1273,6 +1333,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 *); @@ -1318,4 +1380,9 @@ 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); +/* Global to indicate presence of HP-compiled objects, + in particular, SOM executable file with SOM debug info + Defined in symtab.c, used in hppa-tdep.c. */ +extern int deprecated_hp_som_som_object_present; + #endif /* !defined(SYMTAB_H) */