[Lldb-commits] [PATCH] D13323: Use %HOME%/.lldb/module_cache as a default module cache directory

Oleksiy Vyalov via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 30 20:03:23 PDT 2015


ovyalov created this revision.
ovyalov added reviewers: clayborg, tberghammer.
ovyalov added a subscriber: lldb-commits.

Use %HOME%/.lldb/module_cache as a default module cache directory.

http://reviews.llvm.org/D13323

Files:
  source/Target/Platform.cpp

Index: source/Target/Platform.cpp
===================================================================
--- source/Target/Platform.cpp
+++ source/Target/Platform.cpp
@@ -39,9 +39,11 @@
 #include "lldb/Target/UnixSignals.h"
 #include "lldb/Utility/Utils.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 #include "Utility/ModuleCache.h"
 
+
 // Define these constants from POSIX mman.h rather than include the file
 // so that they will be correct even when compiled on Linux.
 #define MAP_PRIVATE 2
@@ -99,13 +101,17 @@
     m_collection_sp->Initialize (g_properties);
 
     auto module_cache_dir = GetModuleCacheDirectory ();
-    if (!module_cache_dir)
-    {
-        if (!HostInfo::GetLLDBPath (ePathTypeGlobalLLDBTempSystemDir, module_cache_dir))
-            module_cache_dir = FileSpec ("/tmp/lldb", false);
-        module_cache_dir.AppendPathComponent ("module_cache");
-        SetModuleCacheDirectory (module_cache_dir);
-    }
+    if (module_cache_dir)
+        return;
+
+    llvm::SmallString<64> user_home_dir;
+    if (!llvm::sys::path::home_directory (user_home_dir))
+        return;
+
+    module_cache_dir = FileSpec (user_home_dir.c_str(), false);
+    module_cache_dir.AppendPathComponent (".lldb");
+    module_cache_dir.AppendPathComponent ("module_cache");
+    SetModuleCacheDirectory (module_cache_dir);
 }
 
 bool
@@ -1847,7 +1853,8 @@
                                  bool *did_create_ptr)
 {
     if (IsHost() ||
-        !GetGlobalPlatformProperties ()->GetUseModuleCache ())
+        !GetGlobalPlatformProperties ()->GetUseModuleCache () ||
+        !GetGlobalPlatformProperties ()->GetModuleCacheDirectory ())
         return false;
 
     Log *log = GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PLATFORM);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13323.36177.patch
Type: text/x-patch
Size: 1760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151001/fd1911c1/attachment.bin>


More information about the lldb-commits mailing list