Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
12 changes: 9 additions & 3 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,23 @@ DWARFUnit::ScopedExtractDIEs DWARFUnit::ExtractDIEsScoped() {
}

DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(DWARFUnit &cu) : m_cu(&cu) {
m_cu->m_die_array_scoped_mutex.lock_shared();
llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
++m_cu->m_die_array_scoped_count;
}

DWARFUnit::ScopedExtractDIEs::~ScopedExtractDIEs() {
if (!m_cu)
return;
m_cu->m_die_array_scoped_mutex.unlock_shared();
{
llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
--m_cu->m_die_array_scoped_count;
if (m_cu->m_die_array_scoped_count == 0)
return;
}
if (!m_clear_dies || m_cu->m_cancel_scopes)
return;
// Be sure no other ScopedExtractDIEs is running anymore.
llvm::sys::ScopedWriter lock_scoped(m_cu->m_die_array_scoped_mutex);
llvm::sys::ScopedLock lock_scoped(m_cu->m_die_array_scoped_mutex);
llvm::sys::ScopedWriter lock(m_cu->m_die_array_mutex);
if (m_cu->m_cancel_scopes)
return;
Expand Down
4 changes: 3 additions & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/RWMutex.h"
#include <atomic>
#include <optional>
Expand Down Expand Up @@ -328,7 +329,8 @@ class DWARFUnit : public DWARFExpression::Delegate, public UserID {
DWARFDebugInfoEntry::collection m_die_array;
mutable llvm::sys::RWMutex m_die_array_mutex;
// It is used for tracking of ScopedExtractDIEs instances.
mutable llvm::sys::RWMutex m_die_array_scoped_mutex;
mutable llvm::sys::Mutex m_die_array_scoped_mutex;
mutable int m_die_array_scoped_count = 0;
// ScopedExtractDIEs instances should not call ClearDIEsRWLocked()
// as someone called ExtractDIEsIfNeeded().
std::atomic<bool> m_cancel_scopes;
Expand Down
Loading