aboutsummaryrefslogtreecommitdiff
path: root/source/Symbol/UnwindTable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Symbol/UnwindTable.cpp')
-rw-r--r--source/Symbol/UnwindTable.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/source/Symbol/UnwindTable.cpp b/source/Symbol/UnwindTable.cpp
index 33eb4d6c092b..df9f5b932565 100644
--- a/source/Symbol/UnwindTable.cpp
+++ b/source/Symbol/UnwindTable.cpp
@@ -17,7 +17,6 @@
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
-#include "lldb/Target/UnwindAssembly.h"
// There is one UnwindTable object per ObjectFile.
// It contains a list of Unwind objects -- one per function, populated lazily -- for the ObjectFile.
@@ -30,8 +29,8 @@ UnwindTable::UnwindTable (ObjectFile& objfile) :
m_object_file (objfile),
m_unwinds (),
m_initialized (false),
- m_assembly_profiler (NULL),
- m_eh_frame (NULL)
+ m_mutex (),
+ m_eh_frame (nullptr)
{
}
@@ -44,6 +43,11 @@ UnwindTable::Initialize ()
if (m_initialized)
return;
+ Mutex::Locker locker(m_mutex);
+
+ if (m_initialized) // check again once we've acquired the lock
+ return;
+
SectionList* sl = m_object_file.GetSectionList ();
if (sl)
{
@@ -54,12 +58,7 @@ UnwindTable::Initialize ()
}
}
- ArchSpec arch;
- if (m_object_file.GetArchitecture (arch))
- {
- m_assembly_profiler = UnwindAssembly::FindPlugin (arch);
- m_initialized = true;
- }
+ m_initialized = true;
}
UnwindTable::~UnwindTable ()
@@ -75,6 +74,8 @@ UnwindTable::GetFuncUnwindersContainingAddress (const Address& addr, SymbolConte
Initialize();
+ Mutex::Locker locker(m_mutex);
+
// There is an UnwindTable per object file, so we can safely use file handles
addr_t file_addr = addr.GetFileAddress();
iterator end = m_unwinds.end ();
@@ -94,13 +95,13 @@ UnwindTable::GetFuncUnwindersContainingAddress (const Address& addr, SymbolConte
if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, false, range) || !range.GetBaseAddress().IsValid())
{
// Does the eh_frame unwind info has a function bounds for this addr?
- if (m_eh_frame == NULL || !m_eh_frame->GetAddressRange (addr, range))
+ if (m_eh_frame == nullptr || !m_eh_frame->GetAddressRange (addr, range))
{
return no_unwind_found;
}
}
- FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, m_assembly_profiler, range));
+ FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, range));
m_unwinds.insert (insert_pos, std::make_pair(range.GetBaseAddress().GetFileAddress(), func_unwinder_sp));
// StreamFile s(stdout, false);
// Dump (s);
@@ -121,13 +122,13 @@ UnwindTable::GetUncachedFuncUnwindersContainingAddress (const Address& addr, Sym
if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, false, range) || !range.GetBaseAddress().IsValid())
{
// Does the eh_frame unwind info has a function bounds for this addr?
- if (m_eh_frame == NULL || !m_eh_frame->GetAddressRange (addr, range))
+ if (m_eh_frame == nullptr || !m_eh_frame->GetAddressRange (addr, range))
{
return no_unwind_found;
}
}
- FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, m_assembly_profiler, range));
+ FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, range));
return func_unwinder_sp;
}
@@ -135,6 +136,7 @@ UnwindTable::GetUncachedFuncUnwindersContainingAddress (const Address& addr, Sym
void
UnwindTable::Dump (Stream &s)
{
+ Mutex::Locker locker(m_mutex);
s.Printf("UnwindTable for '%s':\n", m_object_file.GetFileSpec().GetPath().c_str());
const_iterator begin = m_unwinds.begin();
const_iterator end = m_unwinds.end();
@@ -151,3 +153,9 @@ UnwindTable::GetEHFrameInfo ()
Initialize();
return m_eh_frame;
}
+
+bool
+UnwindTable::GetArchitecture (lldb_private::ArchSpec &arch)
+{
+ return m_object_file.GetArchitecture (arch);
+}