[Lldb-commits] [lldb] r250412 - Revert "Fix temporary directory computation on linux (pr25147)"
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 15 07:46:46 PDT 2015
Author: labath
Date: Thu Oct 15 09:46:46 2015
New Revision: 250412
URL: http://llvm.org/viewvc/llvm-project?rev=250412&view=rev
Log:
Revert "Fix temporary directory computation on linux (pr25147)"
I actually did not want to commit this without review, but I mistyped. :/
Modified:
lldb/trunk/source/Host/android/HostInfoAndroid.cpp
lldb/trunk/source/Host/common/HostInfoBase.cpp
Modified: lldb/trunk/source/Host/android/HostInfoAndroid.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/android/HostInfoAndroid.cpp?rev=250412&r1=250411&r2=250412&view=diff
==============================================================================
--- lldb/trunk/source/Host/android/HostInfoAndroid.cpp (original)
+++ lldb/trunk/source/Host/android/HostInfoAndroid.cpp Thu Oct 15 09:46:46 2015
@@ -91,14 +91,11 @@ HostInfoAndroid::ResolveLibraryPath(cons
bool
HostInfoAndroid::ComputeTempFileBaseDirectory(FileSpec &file_spec)
{
- bool success = HostInfoLinux::ComputeTempFileBaseDirectory(file_spec);
+ if (HostInfoLinux::ComputeTempFileBaseDirectory(file_spec))
+ return true;
- // On Android, there is no path which is guaranteed to be writable. If the user has not
- // provided a path via an environment variable, the generic algorithm will deduce /tmp, which
- // is plain wrong. In that case we have an invalid directory, we substitute the path with
- // /data/local/tmp, which is correct at least in some cases (i.e., when running as shell user).
- if (!success || !file_spec.Exists())
- file_spec = FileSpec("/data/local/tmp", false);
-
- return file_spec.Exists();
+ // 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=250412&r1=250411&r2=250412&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/HostInfoBase.cpp (original)
+++ lldb/trunk/source/Host/common/HostInfoBase.cpp Thu Oct 15 09:46:46 2015
@@ -20,7 +20,6 @@
#include "llvm/ADT/Triple.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Host.h"
-#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include <thread>
@@ -345,9 +344,19 @@ HostInfoBase::ComputeProcessTempFileDire
bool
HostInfoBase::ComputeTempFileBaseDirectory(FileSpec &file_spec)
{
- llvm::SmallVector<char, 16> tmpdir;
- llvm::sys::path::system_temp_directory(/*ErasedOnReboot*/ true, tmpdir);
- file_spec = FileSpec(std::string(tmpdir.data(), tmpdir.size()), true);
+ file_spec.Clear();
+
+ const char *tmpdir_cstr = getenv("TMPDIR");
+ if (tmpdir_cstr == nullptr)
+ {
+ tmpdir_cstr = getenv("TMP");
+ if (tmpdir_cstr == nullptr)
+ tmpdir_cstr = getenv("TEMP");
+ }
+ if (!tmpdir_cstr)
+ return false;
+
+ file_spec = FileSpec(tmpdir_cstr, false);
return true;
}
More information about the lldb-commits
mailing list