From patchwork Mon Jan 19 17:22:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 4733 Received: (qmail 25377 invoked by alias); 19 Jan 2015 17:22:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 25356 invoked by uid 89); 19 Jan 2015 17:22:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 19 Jan 2015 17:22:28 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7518D116328; Mon, 19 Jan 2015 12:22:26 -0500 (EST) 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 NezVui3K9TMT; Mon, 19 Jan 2015 12:22:26 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 492E9116303; Mon, 19 Jan 2015 12:22:26 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 31C2248E89; Mon, 19 Jan 2015 18:22:25 +0100 (CET) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Doug Evans Subject: [PATCH] [Ada] Do not re-cache symbol-lookup result found from cache lookup. Date: Mon, 19 Jan 2015 18:22:18 +0100 Message-Id: <1421688138-29406-1-git-send-email-brobecker@adacore.com> In-Reply-To: References: When ada-lang.c:ada_lookup_symbol_list_worker finds a match in the symbol cache, it caches the result again, which is unecessary. This patch fixes the code to avoid that. gdb/ChangeLog: PR 17856: * ada-lang.c (ada_lookup_symbol_list_worker): Do not re-cache results found in the cache. Tested on x86_64-linux, no regression. I'll push in a couple of days if no objection. --- gdb/ada-lang.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index ccad0a0..c081c13 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5612,14 +5612,12 @@ ada_lookup_symbol_list_worker (const char *name0, const struct block *block0, const struct block *block; const char *name; const int wild_match_p = should_use_wild_match (name0); - int cacheIfUnique; + int syms_from_global_search = 0; int ndefns; obstack_free (&symbol_list_obstack, NULL); obstack_init (&symbol_list_obstack); - cacheIfUnique = 0; - /* Search specified block and its superiors. */ name = name0; block = block0; @@ -5662,7 +5660,6 @@ ada_lookup_symbol_list_worker (const char *name0, const struct block *block0, already performed this search before. If we have, then return the same result. */ - cacheIfUnique = 1; if (lookup_cached_symbol (name0, namespace, &sym, &block)) { if (sym != NULL) @@ -5670,6 +5667,8 @@ ada_lookup_symbol_list_worker (const char *name0, const struct block *block0, goto done; } + syms_from_global_search = 1; + /* Search symbols from all global blocks. */ add_nonlocal_symbols (&symbol_list_obstack, name, namespace, 1, @@ -5688,10 +5687,10 @@ done: ndefns = remove_extra_symbols (*results, ndefns); - if (ndefns == 0 && full_search) + if (ndefns == 0 && full_search && syms_from_global_search) cache_symbol (name0, namespace, NULL, NULL); - if (ndefns == 1 && full_search && cacheIfUnique) + if (ndefns == 1 && full_search && syms_from_global_search) cache_symbol (name0, namespace, (*results)[0].sym, (*results)[0].block); ndefns = remove_irrelevant_renamings (*results, ndefns, block0);