Add a lock ivar to the Platform so that multiple Targets

trying to populate the list of trap handler names at
the same time don't conflict with one another.
<rdar://problem/17011969> 

llvm-svn: 209563
This commit is contained in:
Jason Molenda 2014-05-23 23:11:27 +00:00
parent 771bb72aa7
commit 4da8706e5d
2 changed files with 9 additions and 3 deletions

View File

@ -892,6 +892,7 @@ namespace lldb_private {
std::string m_local_cache_directory; std::string m_local_cache_directory;
std::vector<ConstString> m_trap_handlers; std::vector<ConstString> m_trap_handlers;
bool m_calculated_trap_handlers; bool m_calculated_trap_handlers;
Mutex m_trap_handler_mutex;
//------------------------------------------------------------------ //------------------------------------------------------------------
/// Ask the Platform subclass to fill in the list of trap handler names /// Ask the Platform subclass to fill in the list of trap handler names

View File

@ -257,7 +257,8 @@ Platform::Platform (bool is_host) :
m_ssh_opts (), m_ssh_opts (),
m_ignores_remote_hostname (false), m_ignores_remote_hostname (false),
m_trap_handlers(), m_trap_handlers(),
m_calculated_trap_handlers (false) m_calculated_trap_handlers (false),
m_trap_handler_mutex()
{ {
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
if (log) if (log)
@ -1396,11 +1397,15 @@ Platform::GetEnvironment (StringList &environment)
const std::vector<ConstString> & const std::vector<ConstString> &
Platform::GetTrapHandlerSymbolNames () Platform::GetTrapHandlerSymbolNames ()
{ {
if (!m_calculated_trap_handlers)
{
Mutex::Locker locker (m_trap_handler_mutex);
if (!m_calculated_trap_handlers) if (!m_calculated_trap_handlers)
{ {
CalculateTrapHandlerSymbolNames(); CalculateTrapHandlerSymbolNames();
m_calculated_trap_handlers = true; m_calculated_trap_handlers = true;
} }
}
return m_trap_handlers; return m_trap_handlers;
} }