]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PDB: cache types
authorHannes Domani <ssbssa@yahoo.de>
Mon, 11 Apr 2022 15:27:46 +0000 (17:27 +0200)
committerHannes Domani <ssbssa@yahoo.de>
Mon, 11 Apr 2022 17:37:59 +0000 (19:37 +0200)
gdb/windows-nat.c

index 59fbae765cdd93efec155d45d8a9bf699100444d..e7930e931ef18079cedc6a458073501168b4a7b3 100644 (file)
@@ -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)
 {