From e4405d097d465efe60f42992bcd2067ca530eb45 Mon Sep 17 00:00:00 2001 From: Hannes Domani Date: Mon, 11 Apr 2022 17:27:46 +0200 Subject: [PATCH] PDB: cache types --- 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 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) { -- 2.47.2