Index: lldb/trunk/include/lldb/Host/HostInfoBase.h =================================================================== --- lldb/trunk/include/lldb/Host/HostInfoBase.h +++ lldb/trunk/include/lldb/Host/HostInfoBase.h @@ -63,25 +63,39 @@ static llvm::Optional 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 Index: lldb/trunk/source/API/SBHostOS.cpp =================================================================== --- lldb/trunk/source/API/SBHostOS.cpp +++ lldb/trunk/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; } Index: lldb/trunk/source/Core/Debugger.cpp =================================================================== --- lldb/trunk/source/Core/Debugger.cpp +++ lldb/trunk/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); Index: lldb/trunk/source/Core/PluginManager.cpp =================================================================== --- lldb/trunk/source/Core/PluginManager.cpp +++ lldb/trunk/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); Index: lldb/trunk/source/Expression/REPL.cpp =================================================================== --- lldb/trunk/source/Expression/REPL.cpp +++ lldb/trunk/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 { Index: lldb/trunk/source/Host/common/Host.cpp =================================================================== --- lldb/trunk/source/Host/common/Host.cpp +++ lldb/trunk/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); Index: lldb/trunk/source/Host/common/HostInfoBase.cpp =================================================================== --- lldb/trunk/source/Host/common/HostInfoBase.cpp +++ lldb/trunk/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( - reinterpret_cast(HostInfoBase::GetLLDBPath)))); + FileSpec lldb_file_spec(Host::GetModuleFileSpecForHostAddress( + reinterpret_cast(reinterpret_cast( + 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) { Index: lldb/trunk/source/Host/macosx/objcxx/Host.mm =================================================================== --- lldb/trunk/source/Host/macosx/objcxx/Host.mm +++ lldb/trunk/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; Index: lldb/trunk/source/Host/macosx/objcxx/HostInfoMacOSX.mm =================================================================== --- lldb/trunk/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ lldb/trunk/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(); Index: lldb/trunk/source/Host/posix/HostInfoPosix.cpp =================================================================== --- lldb/trunk/source/Host/posix/HostInfoPosix.cpp +++ lldb/trunk/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]; Index: lldb/trunk/source/Host/posix/PipePosix.cpp =================================================================== --- lldb/trunk/source/Host/posix/PipePosix.cpp +++ lldb/trunk/source/Host/posix/PipePosix.cpp @@ -127,14 +127,10 @@ llvm::SmallVectorImpl &name) { llvm::SmallString named_pipe_path; llvm::SmallString 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 Index: lldb/trunk/source/Host/windows/Host.cpp =================================================================== --- lldb/trunk/source/Host/windows/Host.cpp +++ lldb/trunk/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; Index: lldb/trunk/source/Host/windows/HostInfoWindows.cpp =================================================================== --- lldb/trunk/source/Host/windows/HostInfoWindows.cpp +++ lldb/trunk/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); Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp =================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -561,9 +561,7 @@ codegenoptions::FullDebugInfo) { int temp_fd = -1; llvm::SmallString 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); Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp =================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp +++ lldb/trunk/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__ Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp =================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ lldb/trunk/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. Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp =================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ lldb/trunk/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/"); Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ lldb/trunk/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) { Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ lldb/trunk/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; Index: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp =================================================================== --- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ lldb/trunk/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 " Index: lldb/trunk/unittests/Target/ModuleCacheTest.cpp =================================================================== --- lldb/trunk/unittests/Target/ModuleCacheTest.cpp +++ lldb/trunk/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); }