[Lldb-commits] [lldb] r236843 - Use /data/local/tmp as temp directory on android

Tamas Berghammer tberghammer at google.com
Fri May 8 05:46:26 PDT 2015


Author: tberghammer
Date: Fri May  8 07:46:26 2015
New Revision: 236843

URL: http://llvm.org/viewvc/llvm-project?rev=236843&view=rev
Log:
Use /data/local/tmp as temp directory on android

If no temp directory specified by the user on android then fall back
to /data/local/tmp what is always present on the device. It removes
the dependency of specifying TMPDIR for executing platform commands
on android.

Differential revision: http://reviews.llvm.org/D9569

Modified:
    lldb/trunk/include/lldb/Host/HostInfoBase.h
    lldb/trunk/include/lldb/Host/android/HostInfoAndroid.h
    lldb/trunk/source/Host/android/HostInfoAndroid.cpp
    lldb/trunk/source/Host/common/HostInfoBase.cpp

Modified: lldb/trunk/include/lldb/Host/HostInfoBase.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/HostInfoBase.h?rev=236843&r1=236842&r2=236843&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/HostInfoBase.h (original)
+++ lldb/trunk/include/lldb/Host/HostInfoBase.h Fri May  8 07:46:26 2015
@@ -117,6 +117,7 @@ class HostInfoBase
     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);

Modified: lldb/trunk/include/lldb/Host/android/HostInfoAndroid.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/android/HostInfoAndroid.h?rev=236843&r1=236842&r2=236843&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/android/HostInfoAndroid.h (original)
+++ lldb/trunk/include/lldb/Host/android/HostInfoAndroid.h Fri May  8 07:46:26 2015
@@ -25,6 +25,7 @@ class HostInfoAndroid : public HostInfoL
 
   protected:
     static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64);
+    static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
 };
 
 } // end of namespace lldb_private

Modified: lldb/trunk/source/Host/android/HostInfoAndroid.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/android/HostInfoAndroid.cpp?rev=236843&r1=236842&r2=236843&view=diff
==============================================================================
--- lldb/trunk/source/Host/android/HostInfoAndroid.cpp (original)
+++ lldb/trunk/source/Host/android/HostInfoAndroid.cpp Fri May  8 07:46:26 2015
@@ -87,3 +87,15 @@ HostInfoAndroid::ResolveLibraryPath(cons
 
     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;
+}

Modified: lldb/trunk/source/Host/common/HostInfoBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/HostInfoBase.cpp?rev=236843&r1=236842&r2=236843&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/HostInfoBase.cpp (original)
+++ lldb/trunk/source/Host/common/HostInfoBase.cpp Fri May  8 07:46:26 2015
@@ -323,7 +323,7 @@ bool
 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 @@ HostInfoBase::ComputeProcessTempFileDire
 }
 
 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;





More information about the lldb-commits mailing list