Document that index-cache requires build ID

Message ID txh3hkxmhe2wnpsgwr4a5mjyjcvojc2djy3w2hxmgabkr7bqrc@oi622hwd2lhn
State New
Headers
Series Document that index-cache requires build ID |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed

Commit Message

Lluís Batlle i Rossell April 6, 2025, 11:15 a.m. UTC
  Attached
From 4dfcd1888e3fc3c5707e3f697268d820679a1c7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= <viric@viric.name>
Date: Sun, 6 Apr 2025 13:11:06 +0200
Subject: [PATCH] Document that index-cache requires build ID

---
 gdb/doc/gdb.texinfo | 2 ++
 gdb/dwarf2/read.c   | 4 ++++
 2 files changed, 6 insertions(+)
  

Patch

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index e034ac53295..37b65ab72ac 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -22934,6 +22934,8 @@  Indices only work when using DWARF debugging information, not stabs.
 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 71fd352343a..f6a221a57de 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -2237,7 +2237,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)
+  {
+    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);