Replace HostInfo::GetLLDBPath with specific functions
Summary:
Instead of a function taking an enum value determining which path to
return, we now have a suite of functions, each returning a single path
kind. This makes it easy to move the python-path function into a
specific plugin in a follow-up commit.
All the users of GetLLDBPath were converted to call specific functions
instead. Most of them were hard-coding the enum value anyway, so this
conversion was simple. The only exception was SBHostOS, which I've
changed to use a switch on the incoming enum value.
Reviewers: clayborg, zturner
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D48272
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@335052 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/lldb/Host/HostInfoBase.h b/include/lldb/Host/HostInfoBase.h
index f7003c9..b2567b2 100644
--- a/include/lldb/Host/HostInfoBase.h
+++ b/include/lldb/Host/HostInfoBase.h
@@ -63,25 +63,39 @@
static llvm::Optional<ArchitectureKind> ParseArchitectureKind(llvm::StringRef kind);
- //------------------------------------------------------------------
- /// Find a resource files that are related to LLDB.
- ///
- /// Operating systems have different ways of storing shared
- /// libraries and related resources. This function abstracts the
- /// access to these paths.
- ///
- /// @param[in] path_type
- /// The type of LLDB resource path you are looking for. If the
- /// enumeration ends with "Dir", then only the \a file_spec's
- /// directory member gets filled in.
- ///
- /// @param[in] file_spec
- /// A file spec that gets filled in with the appropriate path.
- ///
- /// @return
- /// \b true if \a resource_path was resolved, \a false otherwise.
- //------------------------------------------------------------------
- static bool GetLLDBPath(lldb::PathType type, FileSpec &file_spec);
+ /// Returns the directory containing the lldb shared library. Only the
+ /// directory member of the FileSpec is filled in.
+ static FileSpec GetShlibDir();
+
+ /// Returns the directory containing the support executables (debugserver,
+ /// ...). Only the directory member of the FileSpec is filled in.
+ static FileSpec GetSupportExeDir();
+
+ /// Returns the directory containing the lldb headers. Only the directory
+ /// member of the FileSpec is filled in.
+ static FileSpec GetHeaderDir();
+
+ /// Returns the directory containing the python modules. Only the directory
+ /// member of the FileSpec is filled in.
+ static FileSpec GetPythonDir();
+
+ /// Returns the directory containing the system plugins. Only the directory
+ /// member of the FileSpec is filled in.
+ static FileSpec GetSystemPluginDir();
+
+ /// Returns the directory containing the user plugins. Only the directory
+ /// member of the FileSpec is filled in.
+ static FileSpec GetUserPluginDir();
+
+ /// Returns the proces temporary directory. This directory will be cleaned up
+ /// when this process exits. Only the directory member of the FileSpec is
+ /// filled in.
+ static FileSpec GetProcessTempDir();
+
+ /// Returns the global temporary directory. This directory will **not** be
+ /// cleaned up when this process exits. Only the directory member of the
+ /// FileSpec is filled in.
+ static FileSpec GetGlobalTempDir();
//---------------------------------------------------------------------------
/// If the triple does not specify the vendor, os, and environment parts, we
diff --git a/source/API/SBHostOS.cpp b/source/API/SBHostOS.cpp
index 8f47eab..f74c63c 100644
--- a/source/API/SBHostOS.cpp
+++ b/source/API/SBHostOS.cpp
@@ -32,24 +32,43 @@
}
SBFileSpec SBHostOS::GetLLDBPythonPath() {
- SBFileSpec sb_lldb_python_filespec;
- FileSpec lldb_python_spec;
- if (HostInfo::GetLLDBPath(ePathTypePythonDir, lldb_python_spec)) {
- sb_lldb_python_filespec.SetFileSpec(lldb_python_spec);
- }
- return sb_lldb_python_filespec;
+ return GetLLDBPath(ePathTypePythonDir);
}
SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) {
- SBFileSpec sb_fspec;
FileSpec fspec;
- bool Success = true;
- if (path_type == ePathTypeClangDir)
+ switch (path_type) {
+ case ePathTypeLLDBShlibDir:
+ fspec = HostInfo::GetShlibDir();
+ break;
+ case ePathTypeSupportExecutableDir:
+ fspec = HostInfo::GetSupportExeDir();
+ break;
+ case ePathTypeHeaderDir:
+ fspec = HostInfo::GetHeaderDir();
+ break;
+ case ePathTypePythonDir:
+ fspec = HostInfo::GetPythonDir();
+ break;
+ case ePathTypeLLDBSystemPlugins:
+ fspec = HostInfo::GetSystemPluginDir();
+ break;
+ case ePathTypeLLDBUserPlugins:
+ fspec = HostInfo::GetUserPluginDir();
+ break;
+ case ePathTypeLLDBTempSystemDir:
+ fspec = HostInfo::GetProcessTempDir();
+ break;
+ case ePathTypeGlobalLLDBTempSystemDir:
+ fspec = HostInfo::GetGlobalTempDir();
+ break;
+ case ePathTypeClangDir:
fspec = GetClangResourceDir();
- else
- Success = HostInfo::GetLLDBPath(path_type, fspec);
- if (Success)
- sb_fspec.SetFileSpec(fspec);
+ break;
+ }
+
+ SBFileSpec sb_fspec;
+ sb_fspec.SetFileSpec(fspec);
return sb_fspec;
}
diff --git a/source/Core/Debugger.cpp b/source/Core/Debugger.cpp
index 9d68d84..6cb8526 100644
--- a/source/Core/Debugger.cpp
+++ b/source/Core/Debugger.cpp
@@ -646,19 +646,18 @@
}
void Debugger::InstanceInitialize() {
- FileSpec dir_spec;
const bool find_directories = true;
const bool find_files = true;
const bool find_other = true;
char dir_path[PATH_MAX];
- if (HostInfo::GetLLDBPath(ePathTypeLLDBSystemPlugins, dir_spec)) {
+ if (FileSpec dir_spec = HostInfo::GetSystemPluginDir()) {
if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) {
FileSpec::EnumerateDirectory(dir_path, find_directories, find_files,
find_other, LoadPluginCallback, this);
}
}
- if (HostInfo::GetLLDBPath(ePathTypeLLDBUserPlugins, dir_spec)) {
+ if (FileSpec dir_spec = HostInfo::GetUserPluginDir()) {
if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) {
FileSpec::EnumerateDirectory(dir_path, find_directories, find_files,
find_other, LoadPluginCallback, this);
diff --git a/source/Core/PluginManager.cpp b/source/Core/PluginManager.cpp
index 44a37a0..55affb6 100644
--- a/source/Core/PluginManager.cpp
+++ b/source/Core/PluginManager.cpp
@@ -157,19 +157,18 @@
void PluginManager::Initialize() {
#if 1
- FileSpec dir_spec;
const bool find_directories = true;
const bool find_files = true;
const bool find_other = true;
char dir_path[PATH_MAX];
- if (HostInfo::GetLLDBPath(ePathTypeLLDBSystemPlugins, dir_spec)) {
+ if (FileSpec dir_spec = HostInfo::GetSystemPluginDir()) {
if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) {
FileSpec::EnumerateDirectory(dir_path, find_directories, find_files,
find_other, LoadPluginCallback, nullptr);
}
}
- if (HostInfo::GetLLDBPath(ePathTypeLLDBUserPlugins, dir_spec)) {
+ if (FileSpec dir_spec = HostInfo::GetUserPluginDir()) {
if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) {
FileSpec::EnumerateDirectory(dir_path, find_directories, find_files,
find_other, LoadPluginCallback, nullptr);
diff --git a/source/Expression/REPL.cpp b/source/Expression/REPL.cpp
index da9dc08..a441e38 100644
--- a/source/Expression/REPL.cpp
+++ b/source/Expression/REPL.cpp
@@ -61,10 +61,8 @@
std::string REPL::GetSourcePath() {
ConstString file_basename = GetSourceFileBasename();
-
- FileSpec tmpdir_file_spec;
- if (HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir,
- tmpdir_file_spec)) {
+ FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir();
+ if (tmpdir_file_spec) {
tmpdir_file_spec.GetFilename().SetCString(file_basename.AsCString());
m_repl_source_path = tmpdir_file_spec.GetPath();
} else {
diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp
index 5325225..d284825 100644
--- a/source/Host/common/Host.cpp
+++ b/source/Host/common/Host.cpp
@@ -500,8 +500,7 @@
// Create a temporary file to get the stdout/stderr and redirect the output
// of the command into this file. We will later read this file if all goes
// well and fill the data into "command_output_ptr"
- FileSpec tmpdir_file_spec;
- if (HostInfo::GetLLDBPath(ePathTypeLLDBTempSystemDir, tmpdir_file_spec)) {
+ if (FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir()) {
tmpdir_file_spec.AppendPathComponent("lldb-shell-output.%%%%%%");
llvm::sys::fs::createUniqueFile(tmpdir_file_spec.GetPath(),
output_file_path);
diff --git a/source/Host/common/HostInfoBase.cpp b/source/Host/common/HostInfoBase.cpp
index 51eba38..b023338 100644
--- a/source/Host/common/HostInfoBase.cpp
+++ b/source/Host/common/HostInfoBase.cpp
@@ -111,141 +111,99 @@
.Default(llvm::None);
}
-bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) {
- file_spec.Clear();
+FileSpec HostInfoBase::GetShlibDir() {
+ static llvm::once_flag g_once_flag;
+ static bool success = false;
+ llvm::call_once(g_once_flag, []() {
+ success = HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ LLDB_LOG(log, "shlib dir -> `{0}`", g_fields->m_lldb_so_dir);
+ });
+ return success ? g_fields->m_lldb_so_dir : FileSpec();
+}
- assert(type != lldb::ePathTypeClangDir);
+FileSpec HostInfoBase::GetSupportExeDir() {
+ static llvm::once_flag g_once_flag;
+ static bool success = false;
+ llvm::call_once(g_once_flag, []() {
+ success =
+ HostInfo::ComputeSupportExeDirectory(g_fields->m_lldb_support_exe_dir);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ LLDB_LOG(log, "support exe dir -> `{0}`", g_fields->m_lldb_support_exe_dir);
+ });
+ return success ? g_fields->m_lldb_support_exe_dir : FileSpec();
+}
-#if defined(LLDB_DISABLE_PYTHON)
- if (type == lldb::ePathTypePythonDir)
- return false;
-#endif
+FileSpec HostInfoBase::GetHeaderDir() {
+ static llvm::once_flag g_once_flag;
+ static bool success = false;
+ llvm::call_once(g_once_flag, []() {
+ success = HostInfo::ComputeHeaderDirectory(g_fields->m_lldb_headers_dir);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ LLDB_LOG(log, "header dir -> `{0}`", g_fields->m_lldb_headers_dir);
+ });
+ return success ? g_fields->m_lldb_headers_dir : FileSpec();
+}
- FileSpec *result = nullptr;
- switch (type) {
- case lldb::ePathTypeLLDBShlibDir: {
- static llvm::once_flag g_once_flag;
- static bool success = false;
- llvm::call_once(g_once_flag, []() {
- success =
- HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir);
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- if (log)
- log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBShlibDir) => '%s'",
- g_fields->m_lldb_so_dir.GetPath().c_str());
- });
- if (success)
- result = &g_fields->m_lldb_so_dir;
- } break;
- case lldb::ePathTypeSupportExecutableDir: {
- static llvm::once_flag g_once_flag;
- static bool success = false;
- llvm::call_once(g_once_flag, []() {
- success = HostInfo::ComputeSupportExeDirectory(
- g_fields->m_lldb_support_exe_dir);
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- if (log)
- log->Printf(
- "HostInfoBase::GetLLDBPath(ePathTypeSupportExecutableDir) => '%s'",
- g_fields->m_lldb_support_exe_dir.GetPath().c_str());
- });
- if (success)
- result = &g_fields->m_lldb_support_exe_dir;
- } break;
- case lldb::ePathTypeHeaderDir: {
- static llvm::once_flag g_once_flag;
- static bool success = false;
- 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)
- log->Printf("HostInfoBase::GetLLDBPath(ePathTypeHeaderDir) => '%s'",
- g_fields->m_lldb_headers_dir.GetPath().c_str());
- });
- if (success)
- result = &g_fields->m_lldb_headers_dir;
- } break;
- case lldb::ePathTypePythonDir: {
- static llvm::once_flag g_once_flag;
- static bool success = false;
- 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)
- log->Printf("HostInfoBase::GetLLDBPath(ePathTypePythonDir) => '%s'",
- g_fields->m_lldb_python_dir.GetPath().c_str());
- });
- if (success)
- result = &g_fields->m_lldb_python_dir;
- } break;
- case lldb::ePathTypeLLDBSystemPlugins: {
- static llvm::once_flag g_once_flag;
- static bool success = false;
- llvm::call_once(g_once_flag, []() {
- success = HostInfo::ComputeSystemPluginsDirectory(
- g_fields->m_lldb_system_plugin_dir);
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- if (log)
- log->Printf(
- "HostInfoBase::GetLLDBPath(ePathTypeLLDBSystemPlugins) => '%s'",
- g_fields->m_lldb_system_plugin_dir.GetPath().c_str());
- });
- if (success)
- result = &g_fields->m_lldb_system_plugin_dir;
- } break;
- case lldb::ePathTypeLLDBUserPlugins: {
- static llvm::once_flag g_once_flag;
- static bool success = false;
- llvm::call_once(g_once_flag, []() {
- success = HostInfo::ComputeUserPluginsDirectory(
- g_fields->m_lldb_user_plugin_dir);
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- if (log)
- log->Printf(
- "HostInfoBase::GetLLDBPath(ePathTypeLLDBUserPlugins) => '%s'",
- g_fields->m_lldb_user_plugin_dir.GetPath().c_str());
- });
- if (success)
- result = &g_fields->m_lldb_user_plugin_dir;
- } break;
- case lldb::ePathTypeLLDBTempSystemDir: {
- static llvm::once_flag g_once_flag;
- static bool success = false;
- llvm::call_once(g_once_flag, []() {
- success = HostInfo::ComputeProcessTempFileDirectory(
- g_fields->m_lldb_process_tmp_dir);
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- if (log)
- log->Printf(
- "HostInfoBase::GetLLDBPath(ePathTypeLLDBTempSystemDir) => '%s'",
- g_fields->m_lldb_process_tmp_dir.GetPath().c_str());
- });
- if (success)
- result = &g_fields->m_lldb_process_tmp_dir;
- } break;
- case lldb::ePathTypeGlobalLLDBTempSystemDir: {
- static llvm::once_flag g_once_flag;
- static bool success = false;
- llvm::call_once(g_once_flag, []() {
- success = HostInfo::ComputeGlobalTempFileDirectory(
- g_fields->m_lldb_global_tmp_dir);
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- if (log)
- log->Printf("HostInfoBase::GetLLDBPath("
- "ePathTypeGlobalLLDBTempSystemDir) => '%s'",
- g_fields->m_lldb_global_tmp_dir.GetPath().c_str());
- });
- if (success)
- result = &g_fields->m_lldb_global_tmp_dir;
- } break;
- default:
- llvm_unreachable("Unreachable!");
- }
+FileSpec HostInfoBase::GetPythonDir() {
+ static llvm::once_flag g_once_flag;
+ static bool success = false;
+ llvm::call_once(g_once_flag, []() {
+ success = HostInfo::ComputePythonDirectory(g_fields->m_lldb_python_dir);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ LLDB_LOG(log, "python dir -> `{0}`", g_fields->m_lldb_python_dir);
+ });
+ return success ? g_fields->m_lldb_python_dir : FileSpec();
+}
- if (!result)
- return false;
- file_spec = *result;
- return true;
+FileSpec HostInfoBase::GetSystemPluginDir() {
+ static llvm::once_flag g_once_flag;
+ static bool success = false;
+ llvm::call_once(g_once_flag, []() {
+ success = HostInfo::ComputeSystemPluginsDirectory(
+ g_fields->m_lldb_system_plugin_dir);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ LLDB_LOG(log, "system plugin dir -> `{0}`",
+ g_fields->m_lldb_system_plugin_dir);
+ });
+ return success ? g_fields->m_lldb_system_plugin_dir : FileSpec();
+}
+
+FileSpec HostInfoBase::GetUserPluginDir() {
+ static llvm::once_flag g_once_flag;
+ static bool success = false;
+ llvm::call_once(g_once_flag, []() {
+ success =
+ HostInfo::ComputeUserPluginsDirectory(g_fields->m_lldb_user_plugin_dir);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ LLDB_LOG(log, "user plugin dir -> `{0}`", g_fields->m_lldb_user_plugin_dir);
+ });
+ return success ? g_fields->m_lldb_user_plugin_dir : FileSpec();
+}
+
+FileSpec HostInfoBase::GetProcessTempDir() {
+ static llvm::once_flag g_once_flag;
+ static bool success = false;
+ llvm::call_once(g_once_flag, []() {
+ success = HostInfo::ComputeProcessTempFileDirectory(
+ g_fields->m_lldb_process_tmp_dir);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ LLDB_LOG(log, "process temp dir -> `{0}`",
+ g_fields->m_lldb_process_tmp_dir);
+ });
+ return success ? g_fields->m_lldb_process_tmp_dir : FileSpec();
+}
+
+FileSpec HostInfoBase::GetGlobalTempDir() {
+ static llvm::once_flag g_once_flag;
+ static bool success = false;
+ llvm::call_once(g_once_flag, []() {
+ success = HostInfo::ComputeGlobalTempFileDirectory(
+ g_fields->m_lldb_global_tmp_dir);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ LLDB_LOG(log, "global temp dir -> `{0}`", g_fields->m_lldb_global_tmp_dir);
+ });
+ return success ? g_fields->m_lldb_global_tmp_dir : FileSpec();
}
ArchSpec HostInfoBase::GetAugmentedArchSpec(llvm::StringRef triple) {
@@ -274,9 +232,9 @@
// contains this function. On MacOSX this will be "LLDB.framework/.../LLDB".
// On other posix systems, we will get .../lib(64|32)?/liblldb.so.
- FileSpec lldb_file_spec(
- Host::GetModuleFileSpecForHostAddress(reinterpret_cast<void *>(
- reinterpret_cast<intptr_t>(HostInfoBase::GetLLDBPath))));
+ FileSpec lldb_file_spec(Host::GetModuleFileSpecForHostAddress(
+ reinterpret_cast<void *>(reinterpret_cast<intptr_t>(
+ HostInfoBase::ComputeSharedLibraryDirectory))));
// This is necessary because when running the testsuite the shlib might be a
// symbolic link inside the Python resource dir.
@@ -289,7 +247,8 @@
}
bool HostInfoBase::ComputeSupportExeDirectory(FileSpec &file_spec) {
- return GetLLDBPath(lldb::ePathTypeLLDBShlibDir, file_spec);
+ file_spec = GetShlibDir();
+ return bool(file_spec);
}
bool HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec) {
diff --git a/source/Host/macosx/objcxx/Host.mm b/source/Host/macosx/objcxx/Host.mm
index 504ed10..a70bf04 100644
--- a/source/Host/macosx/objcxx/Host.mm
+++ b/source/Host/macosx/objcxx/Host.mm
@@ -217,9 +217,8 @@
}
StreamString command;
- FileSpec darwin_debug_file_spec;
- if (!HostInfo::GetLLDBPath(ePathTypeSupportExecutableDir,
- darwin_debug_file_spec)) {
+ FileSpec darwin_debug_file_spec = HostInfo::GetSupportExeDir();
+ if (!darwin_debug_file_spec) {
error.SetErrorString("can't locate the 'darwin-debug' executable");
return error;
}
@@ -1331,9 +1330,8 @@
Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
Status error;
if (launch_info.GetFlags().Test(eLaunchFlagShellExpandArguments)) {
- FileSpec expand_tool_spec;
- if (!HostInfo::GetLLDBPath(lldb::ePathTypeSupportExecutableDir,
- expand_tool_spec)) {
+ FileSpec expand_tool_spec = HostInfo::GetSupportExeDir();
+ if (!expand_tool_spec) {
error.SetErrorString(
"could not get support executable directory for lldb-argdumper tool");
return error;
diff --git a/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 5ec57c9..085f553 100644
--- a/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -118,8 +118,8 @@
}
bool HostInfoMacOSX::ComputeSupportExeDirectory(FileSpec &file_spec) {
- FileSpec lldb_file_spec;
- if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
+ FileSpec lldb_file_spec = GetShlibDir();
+ if (!lldb_file_spec)
return false;
std::string raw_path = lldb_file_spec.GetPath();
@@ -171,8 +171,8 @@
}
bool HostInfoMacOSX::ComputeHeaderDirectory(FileSpec &file_spec) {
- FileSpec lldb_file_spec;
- if (!HostInfo::GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
+ FileSpec lldb_file_spec = GetShlibDir();
+ if (!lldb_file_spec)
return false;
std::string raw_path = lldb_file_spec.GetPath();
@@ -190,8 +190,8 @@
bool HostInfoMacOSX::ComputePythonDirectory(FileSpec &file_spec) {
#ifndef LLDB_DISABLE_PYTHON
- FileSpec lldb_file_spec;
- if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
+ FileSpec lldb_file_spec = GetShlibDir();
+ if (!lldb_file_spec)
return false;
std::string raw_path = lldb_file_spec.GetPath();
@@ -219,8 +219,8 @@
}
bool HostInfoMacOSX::ComputeSystemPluginsDirectory(FileSpec &file_spec) {
- FileSpec lldb_file_spec;
- if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
+ FileSpec lldb_file_spec = GetShlibDir();
+ if (!lldb_file_spec)
return false;
std::string raw_path = lldb_file_spec.GetPath();
diff --git a/source/Host/posix/HostInfoPosix.cpp b/source/Host/posix/HostInfoPosix.cpp
index e0f3a55..3f82a12 100644
--- a/source/Host/posix/HostInfoPosix.cpp
+++ b/source/Host/posix/HostInfoPosix.cpp
@@ -129,8 +129,8 @@
llvm::StringRef dir) {
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- FileSpec lldb_file_spec;
- if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
+ FileSpec lldb_file_spec = GetShlibDir();
+ if (!lldb_file_spec)
return false;
std::string raw_path = lldb_file_spec.GetPath();
@@ -174,8 +174,8 @@
bool HostInfoPosix::ComputePythonDirectory(FileSpec &file_spec) {
#ifndef LLDB_DISABLE_PYTHON
- FileSpec lldb_file_spec;
- if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
+ FileSpec lldb_file_spec = GetShlibDir();
+ if (!lldb_file_spec)
return false;
char raw_path[PATH_MAX];
diff --git a/source/Host/posix/PipePosix.cpp b/source/Host/posix/PipePosix.cpp
index 5ff5467..b321cad 100644
--- a/source/Host/posix/PipePosix.cpp
+++ b/source/Host/posix/PipePosix.cpp
@@ -127,14 +127,10 @@
llvm::SmallVectorImpl<char> &name) {
llvm::SmallString<PATH_MAX> named_pipe_path;
llvm::SmallString<PATH_MAX> pipe_spec((prefix + ".%%%%%%").str());
- FileSpec tmpdir_file_spec;
- tmpdir_file_spec.Clear();
- if (HostInfo::GetLLDBPath(ePathTypeLLDBTempSystemDir, tmpdir_file_spec)) {
- tmpdir_file_spec.AppendPathComponent(pipe_spec.c_str());
- } else {
+ FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir();
+ if (!tmpdir_file_spec)
tmpdir_file_spec.AppendPathComponent("/tmp");
- tmpdir_file_spec.AppendPathComponent(pipe_spec.c_str());
- }
+ tmpdir_file_spec.AppendPathComponent(pipe_spec);
// It's possible that another process creates the target path after we've
// verified it's available but before we create it, in which case we should
diff --git a/source/Host/windows/Host.cpp b/source/Host/windows/Host.cpp
index 049c31b..cc6c454 100644
--- a/source/Host/windows/Host.cpp
+++ b/source/Host/windows/Host.cpp
@@ -182,9 +182,8 @@
Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
Status error;
if (launch_info.GetFlags().Test(eLaunchFlagShellExpandArguments)) {
- FileSpec expand_tool_spec;
- if (!HostInfo::GetLLDBPath(lldb::ePathTypeSupportExecutableDir,
- expand_tool_spec)) {
+ FileSpec expand_tool_spec = HostInfo::GetSupportExeDir();
+ if (!expand_tool_spec) {
error.SetErrorString("could not find support executable directory for "
"the lldb-argdumper tool");
return error;
diff --git a/source/Host/windows/HostInfoWindows.cpp b/source/Host/windows/HostInfoWindows.cpp
index 5c0c293..25df5a4 100644
--- a/source/Host/windows/HostInfoWindows.cpp
+++ b/source/Host/windows/HostInfoWindows.cpp
@@ -104,8 +104,8 @@
}
bool HostInfoWindows::ComputePythonDirectory(FileSpec &file_spec) {
- FileSpec lldb_file_spec;
- if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
+ FileSpec lldb_file_spec = GetShlibDir();
+ if (!lldb_file_spec)
return false;
llvm::SmallString<64> path(lldb_file_spec.GetDirectory().AsCString());
llvm::sys::path::remove_filename(path);
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 0b0681a..c5406fc 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -561,9 +561,7 @@
codegenoptions::FullDebugInfo) {
int temp_fd = -1;
llvm::SmallString<PATH_MAX> result_path;
- FileSpec tmpdir_file_spec;
- if (HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir,
- tmpdir_file_spec)) {
+ if (FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir()) {
tmpdir_file_spec.AppendPathComponent("lldb-%%%%%%.expr");
std::string temp_source_path = tmpdir_file_spec.GetPath();
llvm::sys::fs::createUniqueFile(temp_source_path, temp_fd, result_path);
diff --git a/source/Plugins/ExpressionParser/Clang/ClangHost.cpp b/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
index c359985..4251d2e 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -115,10 +115,9 @@
}
static bool ComputeClangDirectory(FileSpec &file_spec) {
- FileSpec lldb_file_spec;
- if (!HostInfo::GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
- return false;
- return ComputeClangDirectory(lldb_file_spec, file_spec, true);
+ if (FileSpec lldb_file_spec = HostInfo::GetShlibDir())
+ return ComputeClangDirectory(lldb_file_spec, file_spec, true);
+ return false;
}
#else // __APPLE__
diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 10da80f..b581d03 100644
--- a/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1132,11 +1132,11 @@
if (m_developer_directory.empty()) {
bool developer_dir_path_valid = false;
char developer_dir_path[PATH_MAX];
- FileSpec temp_file_spec;
// Get the lldb framework's file path, and if it exists, truncate some
// components to only the developer directory path.
- if (HostInfo::GetLLDBPath(ePathTypeLLDBShlibDir, temp_file_spec)) {
+ FileSpec temp_file_spec = HostInfo::GetShlibDir();
+ if (temp_file_spec) {
if (temp_file_spec.GetPath(developer_dir_path,
sizeof(developer_dir_path))) {
// e.g.
diff --git a/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
index c24a0ee..99f603b 100644
--- a/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -173,7 +173,8 @@
FileSpec fspec;
uint32_t versions[2];
if (objfile->GetSDKVersion(versions, sizeof(versions))) {
- if (HostInfo::GetLLDBPath(ePathTypeLLDBShlibDir, fspec)) {
+ fspec = HostInfo::GetShlibDir();
+ if (fspec) {
std::string path;
xcode_contents_path = fspec.GetPath();
size_t pos = xcode_contents_path.find("/Xcode.app/Contents/");
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 14f0553..c335b60 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1008,8 +1008,8 @@
bool debugserver_exists = debugserver_file_spec.Exists();
if (!debugserver_exists) {
// The debugserver binary is in the LLDB.framework/Resources directory.
- if (HostInfo::GetLLDBPath(ePathTypeSupportExecutableDir,
- debugserver_file_spec)) {
+ debugserver_file_spec = HostInfo::GetSupportExeDir();
+ if (debugserver_file_spec) {
debugserver_file_spec.AppendPathComponent(DEBUGSERVER_BASENAME);
debugserver_exists = debugserver_file_spec.Exists();
if (debugserver_exists) {
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
index 3e5cc56..26e28a9 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -534,7 +534,7 @@
if (domainsocket_dir_env != nullptr)
g_domainsocket_dir = FileSpec(domainsocket_dir_env, false);
else
- HostInfo::GetLLDBPath(ePathTypeLLDBTempSystemDir, g_domainsocket_dir);
+ g_domainsocket_dir = HostInfo::GetProcessTempDir();
});
return g_domainsocket_dir;
diff --git a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 8c7517f..101e07b 100644
--- a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -3094,14 +3094,13 @@
PyRun_SimpleString("import sys");
AddToSysPath(AddLocation::End, ".");
- FileSpec file_spec;
// Don't denormalize paths when calling file_spec.GetPath(). On platforms
// that use a backslash as the path separator, this will result in executing
// python code containing paths with unescaped backslashes. But Python also
// accepts forward slashes, so to make life easier we just use that.
- if (HostInfo::GetLLDBPath(ePathTypePythonDir, file_spec))
+ if (FileSpec file_spec = HostInfo::GetPythonDir())
AddToSysPath(AddLocation::Beginning, file_spec.GetPath(false));
- if (HostInfo::GetLLDBPath(ePathTypeLLDBShlibDir, file_spec))
+ if (FileSpec file_spec = HostInfo::GetShlibDir())
AddToSysPath(AddLocation::Beginning, file_spec.GetPath(false));
PyRun_SimpleString("sys.dont_write_bytecode = 1; import "
diff --git a/unittests/Target/ModuleCacheTest.cpp b/unittests/Target/ModuleCacheTest.cpp
index f7d8a8d..1219a1d 100644
--- a/unittests/Target/ModuleCacheTest.cpp
+++ b/unittests/Target/ModuleCacheTest.cpp
@@ -68,8 +68,7 @@
HostInfo::Initialize();
ObjectFileELF::Initialize();
- FileSpec tmpdir_spec;
- HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir, s_cache_dir);
+ s_cache_dir = HostInfo::GetProcessTempDir();
s_test_executable = GetInputFilePath(module_name);
}