From 7d69f12e75cf1816964f6e51d7d7400c99d0be99 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Thu, 12 Jul 2012 01:11:40 +0000 Subject: [PATCH] Added a mutex to the call frame info to guard generation of the FDE index. llvm-svn: 160099 --- lldb/include/lldb/Symbol/DWARFCallFrameInfo.h | 2 ++ lldb/source/Symbol/DWARFCallFrameInfo.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h index 75a9f19f62c8..c878ea91245a 100644 --- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -18,6 +18,7 @@ #include "lldb/Core/AddressRange.h" #include "lldb/Core/VMRange.h" #include "lldb/Core/dwarf.h" +#include "lldb/Host/Mutex.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Symbol/ObjectFile.h" @@ -128,6 +129,7 @@ private: std::vector m_fde_index; bool m_fde_index_initialized; // only scan the section for FDEs once + Mutex m_fde_index_mutex; // and isolate the thread that does it bool m_is_eh_frame; diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp b/lldb/source/Symbol/DWARFCallFrameInfo.cpp index b8e8cde7151a..edc6d151f049 100644 --- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp +++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp @@ -293,9 +293,14 @@ DWARFCallFrameInfo::GetFDEIndex () { if (m_section_sp.get() == NULL || m_section_sp->IsEncrypted()) return; + if (m_fde_index_initialized) return; - + + Mutex::Locker locker(m_fde_index_mutex); + + if (m_fde_index_initialized) // if two threads hit the locker + return; dw_offset_t offset = 0; if (m_cfi_data_initialized == false)