Daniel Jacobowitz wrote: > > Maybe there's some way we can avoid needing psymbols for types at all. > But I think we need to have a real design and some documentation for > it instead of just accidentally omitting them. > Here is a revised patch I am suggesting. It does not completely eliminate the need for psymbols for types, but does significantly reduce number of global type symbols. I tried to explain in detail why is it possible and safe. Here is the explanation: First the facts about the partial symbols: 1. add_partial_symbol This function gets called during reading the partial symbol information to add a partial_symbol to either global_list or static_list declared in struct objfile. The following table lists partial symbol types and scope. DW_TAG_ Lang Scope (DOMAIN,LOC) subprogram Ada global (VAR,BLOCK) All other global if ext or static (VAR,BLOCK) variable All global if ext or static (VAR,STATIC) typedef base_type subrange_type All static (VAR,TYPEDEF) namespace All global (VAR,TYPEDEF) class_type interface_type union_type enumeration_type cplus,java global (STRUCT,TYPEDEF) cplus,java,ada again to global (VAR,TYPEDEF) enumerator cplus,java global (VAR,CONST) All other static (VAR,CONST) Note that psymbol types namespace, class_type, interface_type, union_type, enumeration_type and enumerator, for c++ and java, always go to global list and will always have address 0 (anything else wouldn't make sense). 2. add_psymbol_to_list This function adds partial symbol first to bcache (objfile->psymbol_cache) and then to objfile->global_psymbols or objfile->static_psymbols list, depending on which one was passed in. It gets called by add_partial_symbol function. In this function we will add partial symbol to one of the lists; the partial symbols will always have exactly the same order in which they were added. This fact will be used when building partial symbol table which will use this list and with offset and number of symbols determine which partial symbols "belong" to it. The reason why partial symbol table needs to know about a symbol is to be able to eventually load full symbols. 3. lookup_partial_symbol Function looks up global or static list of objfile, but only subset of it determined by partial symtab's offset and number of symbols. Returns partial symbol found. This function is always called from a loop through all partial symtabs (this fact is important). When is a partial symbol really matched: Now let's look at the partial symbols which are added only to global partial symbol list: namespace, class_type, interface_type, union_type, enumeration_type, enumerator. The partial symbol will contain names and no address (it will be 0). Therefore, lookup_partial_symbol will always return the first partial symbol table where the psymbol was found. Once the psymbol was found, most probably full symbols will be loaded; once full symbols are loaded, all subsequent lookups for a symbol will first find it in full symtab and will never look for it in the partial symtab again. As a result, all but the first addition of such partial symbol will never be found and are therefore redundant and only take up time to qsort partial symbols within a partial symbol table. The patch: This revised patch adds global symbols only once to first partial symbol table where the symbol was encountered, but only for namespace, class_type, interface_type, union_type, enumeration_type and enumerator partial symbol types (for the last two, only for java and cplus). 2008-02-12 Aleksandar Ristovski * bcache.c (bcache_data): Call bcache_added function. (bcache_added): New function name. Body of function bcache_data is used here with the addition of 'added' argument. The argument is optional and if specified, bcache_added returns 1 if the data was added and 0 if it was found in the hash. * bcache.h (bcache_added): New function. * dwarf2read.c (add_partial_symbol): Make call to new function add_psymbol_to_global_list for namespace, class_type, interface_type, union_type, enumeration_type and enumerator partial symbol types. * symfile.c (add_psymbol_to_bcache): New helper function, takes part of work from add_psymbol_to_list - initialises partial symbol and stashes it in objfile's cache. (append_psymbol_to_list): New helper function, takes other part of work from add_psymbol_to_list - adds partial symbol to the given list. (add_psymbol_to_list): Call helper functions instead of doing work here. Functionally, the function hasn't changed. (add_psymbol_to_global_list): New function, adds partial symbol to global list and does it only once per objfile. * symfile.h (add_psymbol_to_global_list): New function.