public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Hannes Domani <ssbssa@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb/origin/users/ssbssa/pdb-reader-preview] PDB: cache types
Date: Mon, 11 Apr 2022 17:40:03 +0000 (GMT)	[thread overview]
Message-ID: <20220411174003.C91ED385B202@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e4405d097d465efe60f42992bcd2067ca530eb45

commit e4405d097d465efe60f42992bcd2067ca530eb45
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Mon Apr 11 17:27:46 2022 +0200

    PDB: cache types

Diff:
---
 gdb/windows-nat.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 59fbae765cd..e7930e931ef 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -3297,6 +3297,7 @@ struct pdb_line_info
   SymGetTypeInfo_ftype *fSymGetTypeInfo;
   DWORD64 addr;
   DWORD64 max_addr;
+  std::vector<type *> cache;
 };
 
 
@@ -3315,7 +3316,9 @@ static const char *wchar_to_objfile (pdb_line_info *pli, WCHAR *nameW)
   return pli->objfile->intern (name.get ());
 }
 
-static type *get_pdb_type (pdb_line_info *pli, DWORD type_index)
+static type *get_pdb_type (pdb_line_info *pli, DWORD type_index);
+
+static type *get_pdb_type_cached (pdb_line_info *pli, DWORD type_index)
 {
   const struct objfile_type *ot = objfile_type (pli->objfile);
 
@@ -3451,6 +3454,8 @@ static type *get_pdb_type (pdb_line_info *pli, DWORD type_index)
 	      type *t = alloc_type (pli->objfile);
 	      INIT_CPLUS_SPECIFIC (t);
 
+	      pli->cache[type_index] = t;
+
 	      t->set_name (wchar_to_objfile (pli, nameW));
 
 	      if (udtkind == UdtUnion)
@@ -3517,6 +3522,19 @@ static type *get_pdb_type (pdb_line_info *pli, DWORD type_index)
   return ot->builtin_void;
 }
 
+static type *get_pdb_type (pdb_line_info *pli, DWORD type_index)
+{
+  if (type_index >= pli->cache.size ())
+    pli->cache.resize (type_index + 1, nullptr);
+  else if (pli->cache[type_index] != nullptr)
+    return pli->cache[type_index];
+
+  type *t = get_pdb_type_cached (pli, type_index);
+  pli->cache[type_index] = t;
+
+  return t;
+}
+
 static BOOL CALLBACK symbol_callback(PSYMBOL_INFO si,
     ULONG /*SymbolSize*/, PVOID UserContext)
 {


                 reply	other threads:[~2022-04-11 17:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220411174003.C91ED385B202@sourceware.org \
    --to=ssbssa@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /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).