diff options
| author | Oleksiy Vyalov <ovyalov@google.com> | 2015-03-10 01:15:28 +0000 |
|---|---|---|
| committer | Oleksiy Vyalov <ovyalov@google.com> | 2015-03-10 01:15:28 +0000 |
| commit | 63acdfdeb26616dfa1d9657fa666afc9b9440a2a (patch) | |
| tree | e16c9b93f68e2a5ddd835845a4801ec1dead78c5 /lldb/source/Host/common/HostInfoBase.cpp | |
| parent | 8fb05ac9987bb2fe210e3d0d02ef762793524c45 (diff) | |
| download | bcm5719-llvm-63acdfdeb26616dfa1d9657fa666afc9b9440a2a.tar.gz bcm5719-llvm-63acdfdeb26616dfa1d9657fa666afc9b9440a2a.zip | |
Add Utility/ModuleCache class and integrate it with PlatformGDBRemoteServer - in order to allow modules caching from remote targets.
http://reviews.llvm.org/D8037
llvm-svn: 231734
Diffstat (limited to 'lldb/source/Host/common/HostInfoBase.cpp')
| -rw-r--r-- | lldb/source/Host/common/HostInfoBase.cpp | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp index c322b5b4012..08945118d3c 100644 --- a/lldb/source/Host/common/HostInfoBase.cpp +++ b/lldb/source/Host/common/HostInfoBase.cpp @@ -68,7 +68,8 @@ namespace FileSpec m_lldb_clang_resource_dir; FileSpec m_lldb_system_plugin_dir; FileSpec m_lldb_user_plugin_dir; - FileSpec m_lldb_tmp_dir; + FileSpec m_lldb_process_tmp_dir; + FileSpec m_lldb_global_tmp_dir; }; HostInfoBaseFields *g_fields = nullptr; @@ -263,13 +264,27 @@ HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) static std::once_flag g_once_flag; static bool success = false; std::call_once(g_once_flag, []() { - success = HostInfo::ComputeTempFileDirectory (g_fields->m_lldb_tmp_dir); + 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_tmp_dir.GetPath().c_str()); + log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBTempSystemDir) => '%s'", g_fields->m_lldb_process_tmp_dir.GetPath().c_str()); }); if (success) - result = &g_fields->m_lldb_tmp_dir; + result = &g_fields->m_lldb_process_tmp_dir; + } + break; + case lldb::ePathTypeGlobalLLDBTempSystemDir: + { + static std::once_flag g_once_flag; + static bool success = false; + std::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; } @@ -305,8 +320,32 @@ HostInfoBase::ComputeSupportExeDirectory(FileSpec &file_spec) } bool -HostInfoBase::ComputeTempFileDirectory(FileSpec &file_spec) +HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec) { + FileSpec temp_file_spec; + if (!ComputeGlobalTempFileDirectory(temp_file_spec)) + return false; + + std::string pid_str; + llvm::raw_string_ostream pid_stream(pid_str); + pid_stream << Host::GetCurrentProcessID(); + temp_file_spec.AppendPathComponent(pid_stream.str().c_str()); + std::string final_path = temp_file_spec.GetPath(); + if (!FileSystem::MakeDirectory(final_path.c_str(), eFilePermissionsDirectoryDefault).Success()) + return false; + + // Make an atexit handler to clean up the process specify LLDB temp dir + // and all of its contents. + ::atexit(CleanupProcessSpecificLLDBTempDir); + file_spec.GetDirectory().SetCStringWithLength(final_path.c_str(), final_path.size()); + return true; +} + +bool +HostInfoBase::ComputeGlobalTempFileDirectory(FileSpec &file_spec) +{ + file_spec.Clear(); + const char *tmpdir_cstr = getenv("TMPDIR"); if (tmpdir_cstr == NULL) { @@ -322,18 +361,7 @@ HostInfoBase::ComputeTempFileDirectory(FileSpec &file_spec) if (!FileSystem::MakeDirectory(temp_file_spec.GetPath().c_str(), eFilePermissionsDirectoryDefault).Success()) return false; - std::string pid_str; - llvm::raw_string_ostream pid_stream(pid_str); - pid_stream << Host::GetCurrentProcessID(); - temp_file_spec.AppendPathComponent(pid_stream.str().c_str()); - std::string final_path = temp_file_spec.GetPath(); - if (!FileSystem::MakeDirectory(final_path.c_str(), eFilePermissionsDirectoryDefault).Success()) - return false; - - // Make an atexit handler to clean up the process specify LLDB temp dir - // and all of its contents. - ::atexit(CleanupProcessSpecificLLDBTempDir); - file_spec.GetDirectory().SetCStringWithLength(final_path.c_str(), final_path.size()); + file_spec = temp_file_spec; return true; } |

