From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16707 invoked by alias); 22 Jan 2003 17:41:37 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 16700 invoked from network); 22 Jan 2003 17:41:36 -0000 Received: from unknown (HELO jackfruit.Stanford.EDU) (171.64.38.136) by 172.16.49.205 with SMTP; 22 Jan 2003 17:41:36 -0000 Received: (from carlton@localhost) by jackfruit.Stanford.EDU (8.11.6/8.11.6) id h0MHfSf07776; Wed, 22 Jan 2003 09:41:28 -0800 X-Authentication-Warning: jackfruit.Stanford.EDU: carlton set sender to carlton@math.stanford.edu using -f To: Elena Zannoni Cc: "Martin M. Hunt" , gdb@sources.redhat.com Subject: Re: very very slow symbol searches References: <1043236817.32119.7.camel@Dragon> <15918.45982.254578.620499@localhost.redhat.com> From: David Carlton Date: Wed, 22 Jan 2003 17:41:00 -0000 In-Reply-To: <15918.45982.254578.620499@localhost.redhat.com> Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-01/txt/msg00376.txt.bz2 On Wed, 22 Jan 2003 10:07:10 -0500, Elena Zannoni said: > Martin M. Hunt writes: >> Anyone have any idea why search_symbols in symtab.c is now a few >> thousand times slower than it used to be? At least it is on Linux >> x86. >> Insight calls search_symbols twice on startup. Sometime 2-4 weeks >> ago, (builds from CVS on sources) Insight started taking a minute >> or two to load when debugging itself. It is very fast when >> debugging small programs, but large things like insight or gdb take >> forever. At first glance the problem is that search_symbols() is >> taking 20-30 seconds to return. > there have been some changes to that function on 12-23. Could you > try backing those out? This was a change we convinced ourselves it > was ok to do, but maybe it is problematic. Yeah, I actually submitted a patch to revert the search_symbols part of my 12-23 change as part of my patch to demangle partial symbols: now that I understand lookup_symbol_aux_minimal better, I'm sure that's not the right thing to call in that situation. I'd been waiting on pushing that reversion until we'd made a final decision as to whether or not to demangle partial symbols, but probably reverting it now would be a good idea. Of course, even if the search_symbols part of that patch is reverted, it may be the case that the change to lookup_symbol_aux_minimal also causes problems. I hope not, but it's certainly not out of the question. I'm including the patch that Elena referred to after my signature: Martin, could you test if reverting just the search_symbols part helps, or if it's necessary to revert the whole thing? (Or we might be barking up the wrong tree entirely, I suppose.) David Carlton carlton@math.stanford.edu Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.82 diff -u -p -r1.82 symtab.c --- symtab.c 17 Dec 2002 18:34:06 -0000 1.82 +++ symtab.c 19 Dec 2002 23:02:35 -0000 @@ -117,8 +117,7 @@ struct symbol *lookup_symbol_aux_minsyms const char *mangled_name, const namespace_enum namespace, int *is_a_field_of_this, - struct symtab **symtab, - int *force_return); + struct symtab **symtab); static struct symbol *find_active_alias (struct symbol *sym, CORE_ADDR addr); @@ -805,14 +804,6 @@ lookup_symbol_aux (const char *name, con struct symbol *sym; const struct block *static_block; - /* FIXME: carlton/2002-11-05: This variable is here so that - lookup_symbol_aux will sometimes return NULL after receiving a - NULL return value from lookup_symbol_aux_minsyms, without - proceeding on to the partial symtab and static variable tests. I - suspect that that's a bad idea. */ - - int force_return; - /* Search specified block and its superiors. Don't search STATIC_BLOCK or GLOBAL_BLOCK. */ @@ -931,13 +922,11 @@ lookup_symbol_aux (const char *name, con a mangled variable that is stored in one of the minimal symbol tables. Eventually, all global symbols might be resolved in this way. */ - force_return = 0; - sym = lookup_symbol_aux_minsyms (name, mangled_name, namespace, is_a_field_of_this, - symtab, &force_return); + symtab); - if (sym != NULL || force_return == 1) + if (sym != NULL) return sym; #endif @@ -981,13 +970,11 @@ lookup_symbol_aux (const char *name, con */ - force_return = 0; - sym = lookup_symbol_aux_minsyms (name, mangled_name, namespace, is_a_field_of_this, - symtab, &force_return); + symtab); - if (sym != NULL || force_return == 1) + if (sym != NULL) return sym; #endif @@ -1172,13 +1159,20 @@ lookup_symbol_aux_psymtabs (int block_in tables. Eventually, all global symbols might be resolved in this way. */ +/* NOTE: carlton/2002-12-05: At one point, this function was part of + lookup_symbol_aux, and what are now 'return' statements within + lookup_symbol_aux_minsyms returned from lookup_symbol_aux, even if + sym was NULL. As far as I can tell, this was basically accidental; + it didn't happen every time that msymbol was non-NULL, but only if + some additional conditions held as well, and it caused problems + with HP-generated symbol tables. */ + static struct symbol * lookup_symbol_aux_minsyms (const char *name, const char *mangled_name, const namespace_enum namespace, int *is_a_field_of_this, - struct symtab **symtab, - int *force_return) + struct symtab **symtab) { struct symbol *sym; struct blockvector *bv; @@ -1271,7 +1265,6 @@ lookup_symbol_aux_minsyms (const char *n if (symtab != NULL && sym != NULL) *symtab = s; - *force_return = 1; return fixup_symbol_section (sym, s->objfile); } else if (MSYMBOL_TYPE (msymbol) != mst_text @@ -1280,7 +1273,6 @@ lookup_symbol_aux_minsyms (const char *n { /* This is a mangled variable, look it up by its mangled name. */ - *force_return = 1; return lookup_symbol_aux (SYMBOL_NAME (msymbol), mangled_name, NULL, namespace, is_a_field_of_this, symtab); @@ -2904,12 +2896,31 @@ search_symbols (char *regexp, namespace_ { if (0 == find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol))) { - if (kind == FUNCTIONS_NAMESPACE - || lookup_symbol (SYMBOL_NAME (msymbol), - (struct block *) NULL, - VAR_NAMESPACE, - 0, (struct symtab **) NULL) == NULL) - found_misc = 1; + if (kind == FUNCTIONS_NAMESPACE) + { + found_misc = 1; + } + else + { + struct symbol *sym; + + if (SYMBOL_DEMANGLED_NAME (msymbol) != NULL) + sym + = lookup_symbol_aux_minsyms (SYMBOL_DEMANGLED_NAME + (msymbol), + SYMBOL_NAME (msymbol), + VAR_NAMESPACE, + NULL, NULL); + else + sym + = lookup_symbol_aux_minsyms (SYMBOL_NAME (msymbol), + NULL, + VAR_NAMESPACE, + NULL, NULL); + + if (sym == NULL) + found_misc = 1; + } } } }