[Lldb-commits] [lldb] r211241 - Add a lock in the UnwindTable class so two Targets won't try
Jason Molenda
jmolenda at apple.com
Wed Jun 18 16:32:53 PDT 2014
Author: jmolenda
Date: Wed Jun 18 18:32:53 2014
New Revision: 211241
URL: http://llvm.org/viewvc/llvm-project?rev=211241&view=rev
Log:
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>
Modified:
lldb/trunk/include/lldb/Symbol/UnwindTable.h
lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp
lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp
lldb/trunk/source/Symbol/UnwindTable.cpp
Modified: lldb/trunk/include/lldb/Symbol/UnwindTable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/UnwindTable.h?rev=211241&r1=211240&r2=211241&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/UnwindTable.h (original)
+++ lldb/trunk/include/lldb/Symbol/UnwindTable.h Wed Jun 18 18:32:53 2014
@@ -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;
Modified: lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp?rev=211241&r1=211240&r2=211241&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp Wed Jun 18 18:32:53 2014
@@ -78,7 +78,7 @@ HistoryThread::CreateRegisterContextForF
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));
Modified: lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp?rev=211241&r1=211240&r2=211241&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp Wed Jun 18 18:32:53 2014
@@ -66,7 +66,7 @@ HistoryUnwind::DoCreateRegisterContextFo
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;
Modified: lldb/trunk/source/Symbol/UnwindTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindTable.cpp?rev=211241&r1=211240&r2=211241&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/UnwindTable.cpp (original)
+++ lldb/trunk/source/Symbol/UnwindTable.cpp Wed Jun 18 18:32:53 2014
@@ -29,6 +29,7 @@ UnwindTable::UnwindTable (ObjectFile& ob
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::GetFuncUnwindersContainingA
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::GetUncachedFuncUnwindersCon
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();
More information about the lldb-commits
mailing list