[PATCH v3 1/8] Don't call add_dependence from index_imported_unit

Tom Tromey
2026-02-20T20:43:33Z

cooked_indexer::index_imported_unit calls add_dependence. However,
this field is only needed during full symbol reading. Remove this
call.
---
gdb/dwarf2/cooked-indexer.c | 6 +-----
gdb/dwarf2/cu.h | 6 +++---
2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/gdb/dwarf2/cooked-indexer.c b/gdb/dwarf2/cooked-indexer.c
index 40f62de80eb..3221ccd34f8 100644
--- a/gdb/dwarf2/cooked-indexer.c
+++ b/gdb/dwarf2/cooked-indexer.c
@@ -430,11 +430,7 @@ cooked_indexer::index_imported_unit (cutu_reader *reader,
cutu_reader *new_reader
= ensure_cu_exists (reader, *target, true);
if (new_reader != nullptr)
- {
- index_dies (new_reader, new_reader->info_ptr (), nullptr, false);
-
- reader->cu ()->add_dependence (new_reader->cu ()->per_cu);
- }
+ index_dies (new_reader, new_reader->info_ptr (), nullptr, false);

return info_ptr;
}
diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h
index 1361898accc..8ece6ddc010 100644
--- a/gdb/dwarf2/cu.h
+++ b/gdb/dwarf2/cu.h
@@ -300,9 +300,9 @@ struct dwarf2_cu
symbols are being read. */
buildsym_compunit_up m_builder;

- /* A set of pointers to dwarf2_per_cu objects for compilation units referenced
- by this one. Only used during full symbol processing; partial symbol
- tables do not have dependencies. */
+ /* A set of pointers to dwarf2_per_cu objects for compilation units
+ referenced by this one. Only used during full symbol
+ processing. */
gdb::unordered_set<dwarf2_per_cu *> m_dependencies;

public:

--
2.49.0