From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11135 invoked by alias); 31 May 2012 20:37:20 -0000 Received: (qmail 10929 invoked by uid 22791); 31 May 2012 20:37:18 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,KHOP_THREADED,RCVD_IN_HOSTKARMA_NO,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 31 May 2012 20:37:04 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 04D821C6C52; Thu, 31 May 2012 16:37:04 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id hWXz-Ebxf6IE; Thu, 31 May 2012 16:37:03 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id A39631C6A5B; Thu, 31 May 2012 16:37:03 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 0CE1F145616; Thu, 31 May 2012 13:36:54 -0700 (PDT) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [RFA/commit 1/3] Revert "Search global symbols from the expression's block objfile first." Date: Thu, 31 May 2012 20:37:00 -0000 Message-Id: <1338496603-5423-2-git-send-email-brobecker@adacore.com> In-Reply-To: <1338496603-5423-1-git-send-email-brobecker@adacore.com> References: <1338496603-5423-1-git-send-email-brobecker@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-05/txt/msg01105.txt.bz2 The search order used in this patch breaks global symbol lookups for certain symbols when copy-relocation is used. A slightly different search order will be implemented later. gdb/ChangeLog: Revert the following patch: * findvar.c (default_read_var_value): For LOC_UNRESOLVED symbols, try locating the symbol in the symbol's own objfile first, before extending the search to all objfiles. * symtab.c (lookup_symbol_aux_objfile): New function, extracted out of lookup_symbol_aux_symtabs. (lookup_symbol_aux_symtabs): Add new parameter "exclude_objfile". Replace extracted-out code by call to lookup_symbol_aux_objfile. Do not search EXCLUDE_OBJFILE. (lookup_static_symbol_aux): Update call to lookup_symbol_aux_symtabs. (lookup_symbol_global): Search for matches in the block's objfile first, before searching all other objfiles. Will commit if patches #2 & #3 are OK. --- gdb/findvar.c | 10 +----- gdb/symtab.c | 108 +++++++++++++++++---------------------------------------- 2 files changed, 33 insertions(+), 85 deletions(-) diff --git a/gdb/findvar.c b/gdb/findvar.c index ed7903c..9009e6f 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -562,15 +562,7 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) struct minimal_symbol *msym; struct obj_section *obj_section; - /* First, try locating the associated minimal symbol within - the same objfile. This prevents us from selecting another - symbol with the same name but located in a different objfile. */ - msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, - SYMBOL_SYMTAB (var)->objfile); - /* If the lookup failed, try expanding the search to all - objfiles. */ - if (msym == NULL) - msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL); + msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL); if (msym == NULL) error (_("No global symbol \"%s\"."), SYMBOL_LINKAGE_NAME (var)); if (overlay_debugging) diff --git a/gdb/symtab.c b/gdb/symtab.c index 85ddd1d..39d8c6f 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -95,8 +95,7 @@ struct symbol *lookup_symbol_aux_local (const char *name, static struct symbol *lookup_symbol_aux_symtabs (int block_index, const char *name, - const domain_enum domain, - struct objfile *exclude_objfile); + const domain_enum domain); static struct symbol *lookup_symbol_aux_quick (struct objfile *objfile, @@ -1360,7 +1359,7 @@ lookup_static_symbol_aux (const char *name, const domain_enum domain) struct objfile *objfile; struct symbol *sym; - sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain, NULL); + sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain); if (sym != NULL) return sym; @@ -1499,61 +1498,40 @@ lookup_global_symbol_from_objfile (const struct objfile *main_objfile, return NULL; } -/* Check to see if the symbol is defined in one of the OBJFILE's - symtabs. BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK, +/* Check to see if the symbol is defined in one of the symtabs. + BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK, depending on whether or not we want to search global symbols or static symbols. */ static struct symbol * -lookup_symbol_aux_objfile (struct objfile *objfile, int block_index, - const char *name, const domain_enum domain) -{ - struct symbol *sym = NULL; - struct blockvector *bv; - const struct block *block; - struct symtab *s; - - if (objfile->sf) - objfile->sf->qf->pre_expand_symtabs_matching (objfile, block_index, - name, domain); - - ALL_OBJFILE_SYMTABS (objfile, s) - if (s->primary) - { - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, block_index); - sym = lookup_block_symbol (block, name, domain); - if (sym) - { - block_found = block; - return fixup_symbol_section (sym, objfile); - } - } - - return NULL; -} - -/* Same as lookup_symbol_aux_objfile, except that it searches all - objfiles except for EXCLUDE_OBJFILE. Return the first match found. - - If EXCLUDE_OBJFILE is NULL, then all objfiles are searched. */ - -static struct symbol * lookup_symbol_aux_symtabs (int block_index, const char *name, - const domain_enum domain, - struct objfile *exclude_objfile) + const domain_enum domain) { struct symbol *sym; struct objfile *objfile; + struct blockvector *bv; + const struct block *block; + struct symtab *s; ALL_OBJFILES (objfile) { - if (objfile != exclude_objfile) - { - sym = lookup_symbol_aux_objfile (objfile, block_index, name, domain); - if (sym) - return sym; - } + if (objfile->sf) + objfile->sf->qf->pre_expand_symtabs_matching (objfile, + block_index, + name, domain); + + ALL_OBJFILE_SYMTABS (objfile, s) + if (s->primary) + { + bv = BLOCKVECTOR (s); + block = BLOCKVECTOR_BLOCK (bv, block_index); + sym = lookup_block_symbol (block, name, domain); + if (sym) + { + block_found = block; + return fixup_symbol_section (sym, objfile); + } + } } return NULL; @@ -1679,46 +1657,24 @@ lookup_symbol_global (const char *name, const domain_enum domain) { struct symbol *sym = NULL; - struct objfile *block_objfile = NULL; struct objfile *objfile = NULL; /* Call library-specific lookup procedure. */ - block_objfile = lookup_objfile_from_block (block); - if (block_objfile != NULL) - sym = solib_global_lookup (block_objfile, name, domain); + objfile = lookup_objfile_from_block (block); + if (objfile != NULL) + sym = solib_global_lookup (objfile, name, domain); if (sym != NULL) return sym; - /* If BLOCK_OBJFILE is not NULL, then search this objfile first. - In case the global symbol is defined in multiple objfiles, - we have a better chance of finding the most relevant symbol. */ - - if (block_objfile != NULL) - { - sym = lookup_symbol_aux_objfile (block_objfile, GLOBAL_BLOCK, - name, domain); - if (sym == NULL) - sym = lookup_symbol_aux_quick (block_objfile, GLOBAL_BLOCK, - name, domain); - if (sym != NULL) - return sym; - } - - /* Symbol not found in the BLOCK_OBJFILE, so try all the other - objfiles, starting with symtabs first, and then partial symtabs. */ - - sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, domain, block_objfile); + sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, domain); if (sym != NULL) return sym; ALL_OBJFILES (objfile) { - if (objfile != block_objfile) - { - sym = lookup_symbol_aux_quick (objfile, GLOBAL_BLOCK, name, domain); - if (sym) - return sym; - } + sym = lookup_symbol_aux_quick (objfile, GLOBAL_BLOCK, name, domain); + if (sym) + return sym; } return NULL; -- 1.7.1