diff options
author | Greg Clayton <gclayton@apple.com> | 2015-02-02 20:45:17 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2015-02-02 20:45:17 +0000 |
commit | 7597b353b3cdf56af79b8abb86b5a5d1330af4e2 (patch) | |
tree | f2b11da5791fab9dac01854c5a9fdd5a92fe261c | |
parent | 49a766e46885570266a06b6bf8fbd5ee31783d8a (diff) | |
download | bcm5719-llvm-7597b353b3cdf56af79b8abb86b5a5d1330af4e2.tar.gz bcm5719-llvm-7597b353b3cdf56af79b8abb86b5a5d1330af4e2.zip |
Make one mutex for the lldb_private::Platform class that can be used to protect with modifying member variables. This mutex is designed to be used for simple modifications, so the lock should be taken, modify the member variable and released. We need to make sure this isn't used with any code that cause code to rely or reenter on another thread.
Partial fix for: <rdar://problem/19575304>
llvm-svn: 227855
-rw-r--r-- | lldb/include/lldb/Target/Platform.h | 20 | ||||
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp | 7 | ||||
-rw-r--r-- | lldb/source/Target/Platform.cpp | 10 |
3 files changed, 20 insertions, 17 deletions
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index 9a91c79feac..2f2281dee13 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -952,8 +952,7 @@ namespace lldb_private { uint32_t m_update_os_version; ArchSpec m_system_arch; // The architecture of the kernel or the remote platform typedef std::map<uint32_t, ConstString> IDToNameMap; - Mutex m_uid_map_mutex; - Mutex m_gid_map_mutex; + Mutex m_mutex; // Mutex for modifying Platform data structures that should only be used for non-reentrant code IDToNameMap m_uid_map; IDToNameMap m_gid_map; size_t m_max_uid_name_len; @@ -967,7 +966,6 @@ namespace lldb_private { std::string m_local_cache_directory; std::vector<ConstString> m_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 @@ -988,7 +986,7 @@ namespace lldb_private { const char * GetCachedUserName (uint32_t uid) { - Mutex::Locker locker (m_uid_map_mutex); + Mutex::Locker locker (m_mutex); IDToNameMap::iterator pos = m_uid_map.find (uid); if (pos != m_uid_map.end()) { @@ -1004,7 +1002,7 @@ namespace lldb_private { const char * SetCachedUserName (uint32_t uid, const char *name, size_t name_len) { - Mutex::Locker locker (m_uid_map_mutex); + Mutex::Locker locker (m_mutex); ConstString const_name (name); m_uid_map[uid] = const_name; if (m_max_uid_name_len < name_len) @@ -1016,7 +1014,7 @@ namespace lldb_private { void SetUserNameNotFound (uint32_t uid) { - Mutex::Locker locker (m_uid_map_mutex); + Mutex::Locker locker (m_mutex); m_uid_map[uid] = ConstString(); } @@ -1024,14 +1022,14 @@ namespace lldb_private { void ClearCachedUserNames () { - Mutex::Locker locker (m_uid_map_mutex); + Mutex::Locker locker (m_mutex); m_uid_map.clear(); } const char * GetCachedGroupName (uint32_t gid) { - Mutex::Locker locker (m_gid_map_mutex); + Mutex::Locker locker (m_mutex); IDToNameMap::iterator pos = m_gid_map.find (gid); if (pos != m_gid_map.end()) { @@ -1047,7 +1045,7 @@ namespace lldb_private { const char * SetCachedGroupName (uint32_t gid, const char *name, size_t name_len) { - Mutex::Locker locker (m_gid_map_mutex); + Mutex::Locker locker (m_mutex); ConstString const_name (name); m_gid_map[gid] = const_name; if (m_max_gid_name_len < name_len) @@ -1059,14 +1057,14 @@ namespace lldb_private { void SetGroupNameNotFound (uint32_t gid) { - Mutex::Locker locker (m_gid_map_mutex); + Mutex::Locker locker (m_mutex); m_gid_map[gid] = ConstString(); } void ClearCachedGroupNames () { - Mutex::Locker locker (m_gid_map_mutex); + Mutex::Locker locker (m_mutex); m_gid_map.clear(); } diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 5fb43c6d4c1..5966466fa3c 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1496,7 +1496,12 @@ PlatformDarwin::AddClangModuleCompilationOptionsForSDKType (Target *target, std: options.push_back(minimum_version_option.GetString()); } - FileSpec sysroot_spec = GetSDKDirectoryForModules(sdk_type); + FileSpec sysroot_spec; + // Scope for mutex locker below + { + Mutex::Locker locker (m_mutex); + sysroot_spec = GetSDKDirectoryForModules(sdk_type); + } if (sysroot_spec.IsDirectory()) { diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 83a8769953f..086e1a7e4a5 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -286,8 +286,7 @@ Platform::Platform (bool is_host) : m_minor_os_version (UINT32_MAX), m_update_os_version (UINT32_MAX), m_system_arch(), - m_uid_map_mutex (Mutex::eMutexTypeNormal), - m_gid_map_mutex (Mutex::eMutexTypeNormal), + m_mutex (Mutex::eMutexTypeRecursive), m_uid_map(), m_gid_map(), m_max_uid_name_len (0), @@ -299,8 +298,7 @@ Platform::Platform (bool is_host) : m_ssh_opts (), m_ignores_remote_hostname (false), m_trap_handlers(), - m_calculated_trap_handlers (false), - m_trap_handler_mutex() + m_calculated_trap_handlers (false) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) @@ -384,6 +382,8 @@ Platform::GetOSVersion (uint32_t &major, uint32_t &minor, uint32_t &update) { + Mutex::Locker locker (m_mutex); + bool success = m_major_os_version != UINT32_MAX; if (IsHost()) { @@ -1585,7 +1585,7 @@ Platform::GetTrapHandlerSymbolNames () { if (!m_calculated_trap_handlers) { - Mutex::Locker locker (m_trap_handler_mutex); + Mutex::Locker locker (m_mutex); if (!m_calculated_trap_handlers) { CalculateTrapHandlerSymbolNames(); |