Index: lldb/trunk/include/lldb/Host/HostInfoBase.h =================================================================== --- lldb/trunk/include/lldb/Host/HostInfoBase.h +++ lldb/trunk/include/lldb/Host/HostInfoBase.h @@ -117,6 +117,7 @@ static bool ComputeSupportExeDirectory(FileSpec &file_spec); static bool ComputeProcessTempFileDirectory(FileSpec &file_spec); static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec); + static bool ComputeTempFileBaseDirectory(FileSpec &file_spec); static bool ComputeHeaderDirectory(FileSpec &file_spec); static bool ComputeSystemPluginsDirectory(FileSpec &file_spec); static bool ComputeClangDirectory(FileSpec &file_spec); Index: lldb/trunk/include/lldb/Host/android/HostInfoAndroid.h =================================================================== --- lldb/trunk/include/lldb/Host/android/HostInfoAndroid.h +++ lldb/trunk/include/lldb/Host/android/HostInfoAndroid.h @@ -25,6 +25,7 @@ protected: static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64); + static bool ComputeTempFileBaseDirectory(FileSpec &file_spec); }; } // end of namespace lldb_private Index: lldb/trunk/source/Host/android/HostInfoAndroid.cpp =================================================================== --- lldb/trunk/source/Host/android/HostInfoAndroid.cpp +++ lldb/trunk/source/Host/android/HostInfoAndroid.cpp @@ -87,3 +87,15 @@ return FileSpec(); } + +bool +HostInfoAndroid::ComputeTempFileBaseDirectory(FileSpec &file_spec) +{ + if (HostInfoLinux::ComputeTempFileBaseDirectory(file_spec)) + return true; + + // If the default mechanism for computing the temp directory failed then + // fall back to /data/local/tmp + file_spec = FileSpec("/data/local/tmp", false); + return true; +} Index: lldb/trunk/source/Host/common/HostInfoBase.cpp =================================================================== --- lldb/trunk/source/Host/common/HostInfoBase.cpp +++ lldb/trunk/source/Host/common/HostInfoBase.cpp @@ -323,7 +323,7 @@ HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec) { FileSpec temp_file_spec; - if (!ComputeGlobalTempFileDirectory(temp_file_spec)) + if (!HostInfo::ComputeGlobalTempFileDirectory(temp_file_spec)) return false; std::string pid_str; @@ -342,21 +342,33 @@ } bool -HostInfoBase::ComputeGlobalTempFileDirectory(FileSpec &file_spec) +HostInfoBase::ComputeTempFileBaseDirectory(FileSpec &file_spec) { file_spec.Clear(); const char *tmpdir_cstr = getenv("TMPDIR"); - if (tmpdir_cstr == NULL) + if (tmpdir_cstr == nullptr) { tmpdir_cstr = getenv("TMP"); - if (tmpdir_cstr == NULL) + if (tmpdir_cstr == nullptr) tmpdir_cstr = getenv("TEMP"); } if (!tmpdir_cstr) return false; - FileSpec temp_file_spec(tmpdir_cstr, false); + file_spec = FileSpec(tmpdir_cstr, false); + return true; +} + +bool +HostInfoBase::ComputeGlobalTempFileDirectory(FileSpec &file_spec) +{ + file_spec.Clear(); + + FileSpec temp_file_spec; + if (!HostInfo::ComputeTempFileBaseDirectory(temp_file_spec)) + return false; + temp_file_spec.AppendPathComponent("lldb"); if (!FileSystem::MakeDirectory(temp_file_spec.GetPath().c_str(), eFilePermissionsDirectoryDefault).Success()) return false;