summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common/HostInfoBase.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2015-10-15 14:44:29 +0000
committerPavel Labath <labath@google.com>2015-10-15 14:44:29 +0000
commit33ef8acbbd2cc1788cb92e31c38a977c0a5328bd (patch)
treebf4ad53956cf407629a8b36c49132b9412fbe504 /lldb/source/Host/common/HostInfoBase.cpp
parent90428328eee7c20bfef5cdb67895130f057c328e (diff)
downloadbcm5719-llvm-33ef8acbbd2cc1788cb92e31c38a977c0a5328bd.tar.gz
bcm5719-llvm-33ef8acbbd2cc1788cb92e31c38a977c0a5328bd.zip
Fix temporary directory computation on linux (pr25147)
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. llvm-svn: 250409
Diffstat (limited to 'lldb/source/Host/common/HostInfoBase.cpp')
-rw-r--r--lldb/source/Host/common/HostInfoBase.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp
index 3cb00a875e2..0f4324f83dd 100644
--- a/lldb/source/Host/common/HostInfoBase.cpp
+++ b/lldb/source/Host/common/HostInfoBase.cpp
@@ -20,6 +20,7 @@
#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>
@@ -344,19 +345,9 @@ HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec)
bool
HostInfoBase::ComputeTempFileBaseDirectory(FileSpec &file_spec)
{
- 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);
+ llvm::SmallVector<char, 16> tmpdir;
+ llvm::sys::path::system_temp_directory(/*ErasedOnReboot*/ true, tmpdir);
+ file_spec = FileSpec(std::string(tmpdir.data(), tmpdir.size()), true);
return true;
}
OpenPOWER on IntegriCloud