The new .debug_names reader will work by creating a cooked index from
.debug_names. This patch updates cooked_index::maybe_write_index to
avoid writing the index in this case.
However, in order to do this in a clean way, the readers are changed
so that a nullptr result from index_for_writing means "cannot be
done", and then the error message is moved into write_dwarf_index
(where it historically lived).
cooked_index::maybe_write_index (dwarf2_per_bfd *per_bfd,
const index_cache_store_context &ctx)
{
- /* (maybe) store an index in the cache. */
- global_index_cache.store (m_per_bfd, ctx);
+ if (index_for_writing () != nullptr)
+ {
+ /* (maybe) store an index in the cache. */
+ global_index_cache.store (m_per_bfd, ctx);
+ }
m_state->set (cooked_state::CACHE_DONE);
}
if (per_bfd->index_table == nullptr)
error (_("No debugging symbols"));
cooked_index *table = per_bfd->index_table->index_for_writing ();
+ if (table == nullptr)
+ error (_("Cannot use an index to create the index"));
if (per_bfd->types.size () > 1)
error (_("Cannot make an index when the file has multiple .debug_types sections"));
dwarf2_per_objfile *per_objfile) const;
cooked_index *index_for_writing () override
- {
- error (_("Cannot use an index to create the index"));
- }
+ { return nullptr; }
};
#endif /* GDB_DWARF2_MAPPED_INDEX_H */