diff options
Diffstat (limited to 'source/Host/common/HostInfoBase.cpp')
| -rw-r--r-- | source/Host/common/HostInfoBase.cpp | 92 |
1 files changed, 29 insertions, 63 deletions
diff --git a/source/Host/common/HostInfoBase.cpp b/source/Host/common/HostInfoBase.cpp index 01ac87047c5d..a6c9e91a98e8 100644 --- a/source/Host/common/HostInfoBase.cpp +++ b/source/Host/common/HostInfoBase.cpp @@ -10,21 +10,22 @@ #include "lldb/Host/Config.h" #include "lldb/Core/ArchSpec.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/StreamString.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/HostInfoBase.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/StreamString.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Triple.h" #include "llvm/Support/Host.h" #include "llvm/Support/Path.h" #include "llvm/Support/ScopedPrinter.h" +#include "llvm/Support/Threading.h" #include "llvm/Support/raw_ostream.h" -#include <mutex> // std::once +#include <mutex> #include <thread> using namespace lldb; @@ -45,13 +46,10 @@ struct HostInfoBaseFields { // Remove the LLDB temporary directory if we have one. Set "recurse" to // true to all files that were created for the LLDB process can be cleaned // up. - FileSystem::DeleteDirectory(m_lldb_process_tmp_dir, true); + llvm::sys::fs::remove_directories(m_lldb_process_tmp_dir.GetPath()); } } - uint32_t m_number_cpus; - std::string m_vendor_string; - std::string m_os_string; std::string m_host_triple; ArchSpec m_host_arch_32; @@ -78,37 +76,9 @@ void HostInfoBase::Terminate() { g_fields = nullptr; } -uint32_t HostInfoBase::GetNumberCPUS() { - static std::once_flag g_once_flag; - std::call_once(g_once_flag, []() { - g_fields->m_number_cpus = std::thread::hardware_concurrency(); - }); - return g_fields->m_number_cpus; -} - -uint32_t HostInfoBase::GetMaxThreadNameLength() { return 0; } - -llvm::StringRef HostInfoBase::GetVendorString() { - static std::once_flag g_once_flag; - std::call_once(g_once_flag, []() { - g_fields->m_vendor_string = - HostInfo::GetArchitecture().GetTriple().getVendorName().str(); - }); - return g_fields->m_vendor_string; -} - -llvm::StringRef HostInfoBase::GetOSString() { - static std::once_flag g_once_flag; - std::call_once(g_once_flag, []() { - g_fields->m_os_string = - std::move(HostInfo::GetArchitecture().GetTriple().getOSName()); - }); - return g_fields->m_os_string; -} - llvm::StringRef HostInfoBase::GetTargetTriple() { - static std::once_flag g_once_flag; - std::call_once(g_once_flag, []() { + static llvm::once_flag g_once_flag; + llvm::call_once(g_once_flag, []() { g_fields->m_host_triple = HostInfo::GetArchitecture().GetTriple().getTriple(); }); @@ -116,8 +86,8 @@ llvm::StringRef HostInfoBase::GetTargetTriple() { } const ArchSpec &HostInfoBase::GetArchitecture(ArchitectureKind arch_kind) { - static std::once_flag g_once_flag; - std::call_once(g_once_flag, []() { + static llvm::once_flag g_once_flag; + llvm::call_once(g_once_flag, []() { HostInfo::ComputeHostArchitectureSupport(g_fields->m_host_arch_32, g_fields->m_host_arch_64); }); @@ -144,9 +114,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) { FileSpec *result = nullptr; switch (type) { case lldb::ePathTypeLLDBShlibDir: { - static std::once_flag g_once_flag; + static llvm::once_flag g_once_flag; static bool success = false; - std::call_once(g_once_flag, []() { + llvm::call_once(g_once_flag, []() { success = HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); @@ -158,9 +128,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) { result = &g_fields->m_lldb_so_dir; } break; case lldb::ePathTypeSupportExecutableDir: { - static std::once_flag g_once_flag; + static llvm::once_flag g_once_flag; static bool success = false; - std::call_once(g_once_flag, []() { + llvm::call_once(g_once_flag, []() { success = HostInfo::ComputeSupportExeDirectory( g_fields->m_lldb_support_exe_dir); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); @@ -173,9 +143,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) { result = &g_fields->m_lldb_support_exe_dir; } break; case lldb::ePathTypeHeaderDir: { - static std::once_flag g_once_flag; + static llvm::once_flag g_once_flag; static bool success = false; - std::call_once(g_once_flag, []() { + llvm::call_once(g_once_flag, []() { success = HostInfo::ComputeHeaderDirectory(g_fields->m_lldb_headers_dir); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (log) @@ -186,9 +156,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) { result = &g_fields->m_lldb_headers_dir; } break; case lldb::ePathTypePythonDir: { - static std::once_flag g_once_flag; + static llvm::once_flag g_once_flag; static bool success = false; - std::call_once(g_once_flag, []() { + llvm::call_once(g_once_flag, []() { success = HostInfo::ComputePythonDirectory(g_fields->m_lldb_python_dir); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (log) @@ -199,9 +169,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) { result = &g_fields->m_lldb_python_dir; } break; case lldb::ePathTypeClangDir: { - static std::once_flag g_once_flag; + static llvm::once_flag g_once_flag; static bool success = false; - std::call_once(g_once_flag, []() { + llvm::call_once(g_once_flag, []() { success = HostInfo::ComputeClangDirectory(g_fields->m_lldb_clang_resource_dir); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); @@ -214,9 +184,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) { result = &g_fields->m_lldb_clang_resource_dir; } break; case lldb::ePathTypeLLDBSystemPlugins: { - static std::once_flag g_once_flag; + static llvm::once_flag g_once_flag; static bool success = false; - std::call_once(g_once_flag, []() { + llvm::call_once(g_once_flag, []() { success = HostInfo::ComputeSystemPluginsDirectory( g_fields->m_lldb_system_plugin_dir); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); @@ -229,9 +199,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) { result = &g_fields->m_lldb_system_plugin_dir; } break; case lldb::ePathTypeLLDBUserPlugins: { - static std::once_flag g_once_flag; + static llvm::once_flag g_once_flag; static bool success = false; - std::call_once(g_once_flag, []() { + llvm::call_once(g_once_flag, []() { success = HostInfo::ComputeUserPluginsDirectory( g_fields->m_lldb_user_plugin_dir); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); @@ -244,9 +214,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) { result = &g_fields->m_lldb_user_plugin_dir; } break; case lldb::ePathTypeLLDBTempSystemDir: { - static std::once_flag g_once_flag; + static llvm::once_flag g_once_flag; static bool success = false; - std::call_once(g_once_flag, []() { + llvm::call_once(g_once_flag, []() { success = HostInfo::ComputeProcessTempFileDirectory( g_fields->m_lldb_process_tmp_dir); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); @@ -259,9 +229,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) { result = &g_fields->m_lldb_process_tmp_dir; } break; case lldb::ePathTypeGlobalLLDBTempSystemDir: { - static std::once_flag g_once_flag; + static llvm::once_flag g_once_flag; static bool success = false; - std::call_once(g_once_flag, []() { + llvm::call_once(g_once_flag, []() { success = HostInfo::ComputeGlobalTempFileDirectory( g_fields->m_lldb_global_tmp_dir); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); @@ -313,9 +283,7 @@ bool HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec) { std::string pid_str{llvm::to_string(Host::GetCurrentProcessID())}; temp_file_spec.AppendPathComponent(pid_str); - if (!FileSystem::MakeDirectory(temp_file_spec, - eFilePermissionsDirectoryDefault) - .Success()) + if (llvm::sys::fs::create_directory(temp_file_spec.GetPath())) return false; file_spec.GetDirectory().SetCString(temp_file_spec.GetCString()); @@ -337,9 +305,7 @@ bool HostInfoBase::ComputeGlobalTempFileDirectory(FileSpec &file_spec) { return false; temp_file_spec.AppendPathComponent("lldb"); - if (!FileSystem::MakeDirectory(temp_file_spec, - eFilePermissionsDirectoryDefault) - .Success()) + if (llvm::sys::fs::create_directory(temp_file_spec.GetPath())) return false; file_spec.GetDirectory().SetCString(temp_file_spec.GetCString()); |
