public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Doug Evans <xdje42@gmail.com>
Subject: [PATCH] [Ada] Do not re-cache symbol-lookup result found from cache lookup.
Date: Mon, 19 Jan 2015 17:22:00 -0000	[thread overview]
Message-ID: <1421688138-29406-1-git-send-email-brobecker@adacore.com> (raw)
In-Reply-To: <CAP9bCMTo3kOehd0Mm1k26dRDJvLbfv1mTrQLhWo4cAjPxOoMoQ@mail.gmail.com>

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);
-- 
1.9.1

  parent reply	other threads:[~2015-01-19 17:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-18  5:25 ada symbol lookup cache: disable for 7.9? Doug Evans
2015-01-19 15:04 ` Joel Brobecker
2015-01-20 22:00   ` Doug Evans
2015-02-02  3:33   ` pushed: [Ada] pspace_data->sym_cache is always NULL (was: "ada symbol lookup cache: disable for 7.9?") Joel Brobecker
2015-02-02  3:41     ` pushed/7.9: " Joel Brobecker
2015-01-19 17:22 ` Joel Brobecker [this message]
2015-02-02  3:34   ` pushed: [Ada] Do not re-cache symbol-lookup result found from cache lookup Joel Brobecker
2015-02-02  3:41     ` pushed/7.9: " Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421688138-29406-1-git-send-email-brobecker@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=xdje42@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).