From 10b5513e6d9a5a8d72bff272b6f254a3b68abc56 Mon Sep 17 00:00:00 2001 Message-ID: <10b5513e6d9a5a8d72bff272b6f254a3b68abc56.1771693680.git.sam@gentoo.org> From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 6 Apr 2025 13:11:06 +0200 Subject: [PATCH] Document that index-cache requires build ID Reviewed-By: Guinevere Larsen Reviewed-By: Eli Zaretskii --- gdb/doc/gdb.texinfo | 2 ++ gdb/dwarf2/read.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 5b99c2b2e23..3b2401117c7 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -23198,6 +23198,8 @@ Indices only work when using DWARF debugging information. It is possible for @value{GDBN} to automatically save a copy of this index in a cache on disk and retrieve it from there when loading the same binary in the future. This feature can be turned on with @kbd{set index-cache enabled on}. +Note that the cache will use the ELF build ID to identify the cached indices, +so files without build ID will not have their index cached. The following commands can be used to tweak the behavior of the index cache. @table @code diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 5f18d5f2e9a..302b137526f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2302,7 +2302,11 @@ get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd) { const bfd_build_id *build_id = build_id_bfd_get (obj->obfd.get ()); if (build_id == nullptr) - return {}; + { + dwarf_read_debug_printf ("Not using index-cache for %s due to missing build-id", + objfile_name (obj)); + return {}; + } return global_index_cache.lookup_gdb_index (build_id, &dwarf2_per_bfd->index_cache_res); base-commit: 646982f4295bf0a1e64867606d496c34c9a15a0c -- 2.53.0