mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-26 19:36:28 +00:00
Add a lock in the UnwindTable class so two Targets won't try
to modify the same UnwindTable object simultaneously. Fix HistoryThread and HistoryUnwind's mutex lock acqusition to retain the lock for the duration of the operation instead of releasing the temporary immediately. <rdar://problem/17055023> llvm-svn: 211241
This commit is contained in:
parent
5b63fa02b2
commit
5cba569c4b
@ -14,6 +14,7 @@
|
||||
#include <map>
|
||||
|
||||
#include "lldb/lldb-private.h"
|
||||
#include "lldb/Host/Mutex.h"
|
||||
|
||||
namespace lldb_private {
|
||||
|
||||
@ -59,6 +60,7 @@ private:
|
||||
collection m_unwinds;
|
||||
|
||||
bool m_initialized; // delay some initialization until ObjectFile is set up
|
||||
Mutex m_mutex;
|
||||
|
||||
DWARFCallFrameInfo* m_eh_frame;
|
||||
|
||||
|
@ -78,7 +78,7 @@ HistoryThread::CreateRegisterContextForFrame (StackFrame *frame)
|
||||
lldb::StackFrameListSP
|
||||
HistoryThread::GetStackFrameList ()
|
||||
{
|
||||
Mutex::Locker (m_framelist_mutex);
|
||||
Mutex::Locker locker(m_framelist_mutex);
|
||||
if (m_framelist.get() == NULL)
|
||||
{
|
||||
m_framelist.reset (new StackFrameList (*this, StackFrameListSP(), true));
|
||||
|
@ -66,7 +66,7 @@ HistoryUnwind::DoCreateRegisterContextForFrame (StackFrame *frame)
|
||||
bool
|
||||
HistoryUnwind::DoGetFrameInfoAtIndex (uint32_t frame_idx, lldb::addr_t& cfa, lldb::addr_t& pc)
|
||||
{
|
||||
Mutex::Locker (m_unwind_mutex);
|
||||
Mutex::Locker locker(m_unwind_mutex);
|
||||
if (frame_idx < m_pcs.size())
|
||||
{
|
||||
cfa = frame_idx;
|
||||
|
@ -29,6 +29,7 @@ UnwindTable::UnwindTable (ObjectFile& objfile) :
|
||||
m_object_file (objfile),
|
||||
m_unwinds (),
|
||||
m_initialized (false),
|
||||
m_mutex (),
|
||||
m_eh_frame (nullptr)
|
||||
{
|
||||
}
|
||||
@ -42,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)
|
||||
{
|
||||
@ -68,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 ();
|
||||
@ -128,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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user