From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2111) id C91ED385B202; Mon, 11 Apr 2022 17:40:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C91ED385B202 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Hannes Domani To: gdb-cvs@sourceware.org Subject: [binutils-gdb/origin/users/ssbssa/pdb-reader-preview] PDB: cache types X-Act-Checkin: binutils-gdb X-Git-Author: Hannes Domani X-Git-Refname: refs/heads/origin/users/ssbssa/pdb-reader-preview X-Git-Oldrev: bf22f1d7101dbbdbc14e9a58cb733ae2da4567f2 X-Git-Newrev: e4405d097d465efe60f42992bcd2067ca530eb45 Message-Id: <20220411174003.C91ED385B202@sourceware.org> Date: Mon, 11 Apr 2022 17:40:03 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2022 17:40:03 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3De4405d097d46= 5efe60f42992bcd2067ca530eb45 commit e4405d097d465efe60f42992bcd2067ca530eb45 Author: Hannes Domani 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 cache; }; =20 =20 @@ -3315,7 +3316,9 @@ static const char *wchar_to_objfile (pdb_line_info *p= li, WCHAR *nameW) return pli->objfile->intern (name.get ()); } =20 -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 =3D objfile_type (pli->objfile); =20 @@ -3451,6 +3454,8 @@ static type *get_pdb_type (pdb_line_info *pli, DWORD = type_index) type *t =3D alloc_type (pli->objfile); INIT_CPLUS_SPECIFIC (t); =20 + pli->cache[type_index] =3D t; + t->set_name (wchar_to_objfile (pli, nameW)); =20 if (udtkind =3D=3D UdtUnion) @@ -3517,6 +3522,19 @@ static type *get_pdb_type (pdb_line_info *pli, DWORD= type_index) return ot->builtin_void; } =20 +static type *get_pdb_type (pdb_line_info *pli, DWORD type_index) +{ + if (type_index >=3D pli->cache.size ()) + pli->cache.resize (type_index + 1, nullptr); + else if (pli->cache[type_index] !=3D nullptr) + return pli->cache[type_index]; + + type *t =3D get_pdb_type_cached (pli, type_index); + pli->cache[type_index] =3D t; + + return t; +} + static BOOL CALLBACK symbol_callback(PSYMBOL_INFO si, ULONG /*SymbolSize*/, PVOID UserContext) {