diff options
author | Pavel Labath <labath@google.com> | 2015-10-16 09:32:05 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2015-10-16 09:32:05 +0000 |
commit | 33183147227215a1c91b8bc2d0f18d8dec342417 (patch) | |
tree | dfea831d77565318b260fb8d2c1baf2da3c8529b /lldb/source/Host/android/HostInfoAndroid.cpp | |
parent | 7187e4bba90943c86e3569519b997c1d6f40c72f (diff) | |
download | bcm5719-llvm-33183147227215a1c91b8bc2d0f18d8dec342417.tar.gz bcm5719-llvm-33183147227215a1c91b8bc2d0f18d8dec342417.zip |
Fix temporary directory computation on linux (pr25147)
Summary:
On linux, the environment variables for temp directories that lldb checks for are generally not
defined, and the temp directory computation failed. This caused expression evaluation to fall
back to creating "/tmp/lldb-*.expr" debugging files instead of the usual
"$TMP/lldb/pid/lldb-*.expr". Crucially, these files were not cleaned up on lldb exit, which
caused clutter in the /tmp folder, especially on long-running machines (e.g. builtbots). This
commit fixes lldb to use llvm::sys::path::system_temp_directory, which does the same environment
variable dance, but (!) also falls back to the P_tmpdir macro, which is how the temp directory is
defined on linux.
Since the linux temp path computation now succeeds, I needed to also modify Android path
computation to check for actual directory existence, rather then checking whether the operation
failed.
Reviewers: clayborg, tberghammer
Subscribers: tberghammer, lldb-commits, danalbert, srhines, emaste
Differential Revision: http://reviews.llvm.org/D13772
llvm-svn: 250502
Diffstat (limited to 'lldb/source/Host/android/HostInfoAndroid.cpp')
-rw-r--r-- | lldb/source/Host/android/HostInfoAndroid.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lldb/source/Host/android/HostInfoAndroid.cpp b/lldb/source/Host/android/HostInfoAndroid.cpp index a5695f686a3..3fa50ec8ddf 100644 --- a/lldb/source/Host/android/HostInfoAndroid.cpp +++ b/lldb/source/Host/android/HostInfoAndroid.cpp @@ -91,11 +91,14 @@ HostInfoAndroid::ResolveLibraryPath(const std::string& module_path, const ArchSp bool HostInfoAndroid::ComputeTempFileBaseDirectory(FileSpec &file_spec) { - if (HostInfoLinux::ComputeTempFileBaseDirectory(file_spec)) - return true; + bool success = HostInfoLinux::ComputeTempFileBaseDirectory(file_spec); - // 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; + // 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(); } |