Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/Timer.h"
#include "lldb/lldb-private-enumerations.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/ThreadPool.h"
#include <atomic>
#include <optional>
Expand All @@ -33,10 +32,10 @@ using namespace lldb_private::plugin::dwarf;
using namespace llvm::dwarf;

void ManualDWARFIndex::Index() {
if (m_indexed)
return;
m_indexed = true;
std::call_once(m_indexed_flag, [this]() { IndexImpl(); });
}

void ManualDWARFIndex::IndexImpl() {
ElapsedTime elapsed(m_index_time);
LLDB_SCOPED_TIMERF("%p", static_cast<void *>(m_dwarf));
if (LoadFromCache()) {
Expand Down Expand Up @@ -78,8 +77,8 @@ void ManualDWARFIndex::Index() {
lldb::eDescriptionLevelBrief);

// Include 2 passes per unit to index for extracting DIEs from the unit and
// indexing the unit, and then extra entries for finalizing each index in the
// set.
// indexing the unit, and then extra entries for finalizing each index in
// the set.
const auto indices = IndexSet<NameToDIE>::Indices();
const uint64_t total_progress = units_to_index.size() * 2 + indices.size();
Progress progress("Manually indexing DWARF", module_desc.GetData(),
Expand Down Expand Up @@ -114,10 +113,10 @@ void ManualDWARFIndex::Index() {

// Extract dies for all DWARFs unit in parallel. Figure out which units
// didn't have their DIEs already parsed and remember this. If no DIEs were
// parsed prior to this index function call, we are going to want to clear the
// CU dies after we are done indexing to make sure we don't pull in all DWARF
// dies, but we need to wait until all units have been indexed in case a DIE
// in one unit refers to another and the indexes accesses those DIEs.
// parsed prior to this index function call, we are going to want to clear
// the CU dies after we are done indexing to make sure we don't pull in all
// DWARF dies, but we need to wait until all units have been indexed in case
// a DIE in one unit refers to another and the indexes accesses those DIEs.
std::vector<std::optional<DWARFUnit::ScopedExtractDIEs>> clear_cu_dies(
units_to_index.size());
for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
Expand Down
8 changes: 7 additions & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,14 @@ class ManualDWARFIndex : public DWARFIndex {
void Dump(Stream &s) override;

private:
/// Reads the DWARF debug info to build the index once.
///
/// Should be called before attempting to retrieve symbols.
void Index();

/// Call `ManualDWARFIndex::Index()` instead.
void IndexImpl();

/// Decode a serialized version of this object from data.
///
/// \param data
Expand Down Expand Up @@ -170,7 +176,7 @@ class ManualDWARFIndex : public DWARFIndex {
llvm::DenseSet<uint64_t> m_type_sigs_to_avoid;

IndexSet<NameToDIE> m_set;
bool m_indexed = false;
std::once_flag m_indexed_flag;
};
} // namespace dwarf
} // namespace lldb_private::plugin
Expand Down
Loading