The two readers currently using cooked_index_worker shared some code.
This patch factors this out into a new "done_reading" method.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
m_cache_store.store ();
}
}
+
+/* See cooked-index-worker.h. */
+
+void
+cooked_index_worker::done_reading ()
+{
+ /* Only handle the scanning results here. Complaints and exceptions
+ can only be dealt with on the main thread. */
+ std::vector<cooked_index_shard_up> shards;
+
+ for (auto &one_result : m_results)
+ {
+ shards.push_back (one_result.release_shard ());
+ m_all_parents_map.add_map (*one_result.get_parent_map ());
+ }
+
+ shards.shrink_to_fit ();
+
+ dwarf2_per_bfd *per_bfd = m_per_objfile->per_bfd;
+ cooked_index *table
+ = (gdb::checked_static_cast<cooked_index *>
+ (per_bfd->index_table.get ()));
+ table->set_contents (std::move (shards), &m_warnings, &m_all_parents_map);
+}
to be run in a worker thread without problems. */
virtual void do_reading () = 0;
+ /* Helper function that should be called when done reading. This
+ assumes that m_results is filled in, and will initialize
+ m_all_parents_map and end by calling
+ cooked_index::set_contents. */
+ virtual void done_reading ();
+
/* A callback that can print stats, if needed. This is called when
transitioning to the 'MAIN_AVAILABLE' state. */
virtual void print_stats ()
m_map.indices[0].note_error (std::move (exc));
}
- std::vector<cooked_index_shard_up> shards;
bool first = true;
for (auto &iter : m_map.indices)
{
}
else
iter.done_reading ({});
- shards.push_back (iter.release_shard ());
- m_all_parents_map.add_map (*iter.get_parent_map ());
}
m_results = std::move (m_map.indices);
-
- dwarf2_per_bfd *per_bfd = m_per_objfile->per_bfd;
- cooked_index *table
- = (gdb::checked_static_cast<cooked_index *>
- (per_bfd->index_table.get ()));
-
- /* Note that this code never uses IS_PARENT_DEFERRED, so it is safe
- to pass nullptr here. */
- table->set_contents (std::move (shards), &m_warnings, nullptr);
+ done_reading ();
bfd_thread_cleanup ();
}
/* After the last DWARF-reading task has finished, this function
does the remaining work to finish the scan. */
- void done_reading ();
+ void done_reading () override;
/* An iterator for the comp units. */
using unit_iterator = std::vector<dwarf2_per_cu_up>::iterator;
void
cooked_index_worker_debug_info::done_reading ()
{
- /* Only handle the scanning results here. Complaints and exceptions
- can only be dealt with on the main thread. */
- std::vector<cooked_index_shard_up> shards;
-
- for (auto &one_result : m_results)
- {
- shards.push_back (one_result.release_shard ());
- m_all_parents_map.add_map (*one_result.get_parent_map ());
- }
-
/* This has to wait until we read the CUs, we need the list of DWOs. */
process_skeletonless_type_units (m_per_objfile, &m_index_storage);
- shards.push_back (m_index_storage.release_shard ());
- shards.shrink_to_fit ();
-
- m_all_parents_map.add_map (*m_index_storage.get_parent_map ());
+ m_results.push_back (std::move (m_index_storage));
- dwarf2_per_bfd *per_bfd = m_per_objfile->per_bfd;
- cooked_index *table
- = (gdb::checked_static_cast<cooked_index *>
- (per_bfd->index_table.get ()));
- table->set_contents (std::move (shards), &m_warnings,
- &m_all_parents_map);
+ /* Call into the base class. */
+ cooked_index_worker::done_reading ();
}
void