aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Target/Platform.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lldb/Target/Platform.h')
-rw-r--r--include/lldb/Target/Platform.h111
1 files changed, 54 insertions, 57 deletions
diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h
index 53c17a6a66cf..6fdd92db5680 100644
--- a/include/lldb/Target/Platform.h
+++ b/include/lldb/Target/Platform.h
@@ -15,6 +15,7 @@
#include <functional>
#include <map>
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
@@ -28,7 +29,6 @@
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/Mutex.h"
// TODO pull NativeDelegate class out of NativeProcessProtocol so we
// can just forward ref the NativeDelegate rather than include it here.
@@ -427,7 +427,7 @@ class ModuleCache;
virtual size_t
GetSoftwareBreakpointTrapOpcode (Target &target,
- BreakpointSite *bp_site) = 0;
+ BreakpointSite *bp_site);
//------------------------------------------------------------------
/// Launch a new process on a platform, not necessarily for
@@ -1079,7 +1079,8 @@ class ModuleCache;
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_mutex; // Mutex for modifying Platform data structures that should only be used for non-reentrant code
+ // Mutex for modifying Platform data structures that should only be used for non-reentrant code
+ std::mutex m_mutex;
IDToNameMap m_uid_map;
IDToNameMap m_gid_map;
size_t m_max_uid_name_len;
@@ -1112,9 +1113,9 @@ class ModuleCache;
CalculateTrapHandlerSymbolNames () = 0;
const char *
- GetCachedUserName (uint32_t uid)
+ GetCachedUserName(uint32_t uid)
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::mutex> guard(m_mutex);
// return the empty string if our string is NULL
// so we can tell when things were in the negative
// cached (didn't find a valid user name, don't keep
@@ -1124,35 +1125,35 @@ class ModuleCache;
}
const char *
- SetCachedUserName (uint32_t uid, const char *name, size_t name_len)
+ SetCachedUserName(uint32_t uid, const char *name, size_t name_len)
{
- Mutex::Locker locker (m_mutex);
- ConstString const_name (name);
+ std::lock_guard<std::mutex> guard(m_mutex);
+ ConstString const_name(name);
m_uid_map[uid] = const_name;
if (m_max_uid_name_len < name_len)
m_max_uid_name_len = name_len;
// Const strings lives forever in our const string pool, so we can return the const char *
- return const_name.GetCString();
+ return const_name.GetCString();
}
void
- SetUserNameNotFound (uint32_t uid)
+ SetUserNameNotFound(uint32_t uid)
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::mutex> guard(m_mutex);
m_uid_map[uid] = ConstString();
}
void
- ClearCachedUserNames ()
+ ClearCachedUserNames()
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::mutex> guard(m_mutex);
m_uid_map.clear();
}
-
+
const char *
- GetCachedGroupName (uint32_t gid)
+ GetCachedGroupName(uint32_t gid)
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::mutex> guard(m_mutex);
// return the empty string if our string is NULL
// so we can tell when things were in the negative
// cached (didn't find a valid group name, don't keep
@@ -1162,28 +1163,28 @@ class ModuleCache;
}
const char *
- SetCachedGroupName (uint32_t gid, const char *name, size_t name_len)
+ SetCachedGroupName(uint32_t gid, const char *name, size_t name_len)
{
- Mutex::Locker locker (m_mutex);
- ConstString const_name (name);
+ std::lock_guard<std::mutex> guard(m_mutex);
+ ConstString const_name(name);
m_gid_map[gid] = const_name;
if (m_max_gid_name_len < name_len)
m_max_gid_name_len = name_len;
// Const strings lives forever in our const string pool, so we can return the const char *
- return const_name.GetCString();
+ return const_name.GetCString();
}
void
- SetGroupNameNotFound (uint32_t gid)
+ SetGroupNameNotFound(uint32_t gid)
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::mutex> guard(m_mutex);
m_gid_map[gid] = ConstString();
}
void
- ClearCachedGroupNames ()
+ ClearCachedGroupNames()
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::mutex> guard(m_mutex);
m_gid_map.clear();
}
@@ -1236,20 +1237,15 @@ class ModuleCache;
class PlatformList
{
public:
- PlatformList() :
- m_mutex (Mutex::eMutexTypeRecursive),
- m_platforms (),
- m_selected_platform_sp()
- {
- }
+ PlatformList() : m_mutex(), m_platforms(), m_selected_platform_sp() {}
~PlatformList() = default;
void
- Append (const lldb::PlatformSP &platform_sp, bool set_selected)
+ Append(const lldb::PlatformSP &platform_sp, bool set_selected)
{
- Mutex::Locker locker (m_mutex);
- m_platforms.push_back (platform_sp);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_platforms.push_back(platform_sp);
if (set_selected)
m_selected_platform_sp = m_platforms.back();
}
@@ -1257,16 +1253,16 @@ class ModuleCache;
size_t
GetSize()
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_platforms.size();
}
lldb::PlatformSP
- GetAtIndex (uint32_t idx)
+ GetAtIndex(uint32_t idx)
{
lldb::PlatformSP platform_sp;
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (idx < m_platforms.size())
platform_sp = m_platforms[idx];
}
@@ -1283,23 +1279,23 @@ class ModuleCache;
/// processes.
//------------------------------------------------------------------
lldb::PlatformSP
- GetSelectedPlatform ()
+ GetSelectedPlatform()
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_selected_platform_sp && !m_platforms.empty())
m_selected_platform_sp = m_platforms.front();
-
+
return m_selected_platform_sp;
}
void
- SetSelectedPlatform (const lldb::PlatformSP &platform_sp)
+ SetSelectedPlatform(const lldb::PlatformSP &platform_sp)
{
if (platform_sp)
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
const size_t num_platforms = m_platforms.size();
- for (size_t idx=0; idx<num_platforms; ++idx)
+ for (size_t idx = 0; idx < num_platforms; ++idx)
{
if (m_platforms[idx].get() == platform_sp.get())
{
@@ -1307,28 +1303,28 @@ class ModuleCache;
return;
}
}
- m_platforms.push_back (platform_sp);
+ m_platforms.push_back(platform_sp);
m_selected_platform_sp = m_platforms.back();
}
}
protected:
typedef std::vector<lldb::PlatformSP> collection;
- mutable Mutex m_mutex;
+ mutable std::recursive_mutex m_mutex;
collection m_platforms;
lldb::PlatformSP m_selected_platform_sp;
private:
DISALLOW_COPY_AND_ASSIGN (PlatformList);
};
-
+
class OptionGroupPlatformRSync : public lldb_private::OptionGroup
{
public:
- OptionGroupPlatformRSync ();
-
- ~OptionGroupPlatformRSync() override;
-
+ OptionGroupPlatformRSync() = default;
+
+ ~OptionGroupPlatformRSync() override = default;
+
lldb_private::Error
SetOptionValue(CommandInterpreter &interpreter,
uint32_t option_idx,
@@ -1353,6 +1349,7 @@ class ModuleCache;
std::string m_rsync_opts;
std::string m_rsync_prefix;
bool m_ignores_remote_hostname;
+
private:
DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformRSync);
};
@@ -1360,10 +1357,10 @@ class ModuleCache;
class OptionGroupPlatformSSH : public lldb_private::OptionGroup
{
public:
- OptionGroupPlatformSSH ();
-
- ~OptionGroupPlatformSSH() override;
-
+ OptionGroupPlatformSSH() = default;
+
+ ~OptionGroupPlatformSSH() override = default;
+
lldb_private::Error
SetOptionValue(CommandInterpreter &interpreter,
uint32_t option_idx,
@@ -1394,10 +1391,10 @@ class ModuleCache;
class OptionGroupPlatformCaching : public lldb_private::OptionGroup
{
public:
- OptionGroupPlatformCaching ();
-
- ~OptionGroupPlatformCaching() override;
-
+ OptionGroupPlatformCaching() = default;
+
+ ~OptionGroupPlatformCaching() override = default;
+
lldb_private::Error
SetOptionValue(CommandInterpreter &interpreter,
uint32_t option_idx,