1 //===-- ModuleCache.h -------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef utility_ModuleCache_h_
11 #define utility_ModuleCache_h_
13 #include "lldb/lldb-types.h"
14 #include "lldb/lldb-forward.h"
16 #include "lldb/Core/Error.h"
17 #include "lldb/Host/File.h"
18 #include "lldb/Host/FileSpec.h"
22 #include <unordered_map>
24 namespace lldb_private {
29 //----------------------------------------------------------------------
30 /// @class ModuleCache ModuleCache.h "Utility/ModuleCache.h"
31 /// @brief A module cache class.
33 /// Caches locally modules that are downloaded from remote targets.
34 /// Each cached module maintains 2 views:
35 /// - UUID view: /${CACHE_ROOT}/${PLATFORM_NAME}/.cache/${UUID}/${MODULE_FILENAME}
36 /// - Sysroot view: /${CACHE_ROOT}/${PLATFORM_NAME}/${HOSTNAME}/${MODULE_FULL_FILEPATH}
38 /// UUID views stores a real module file, whereas Sysroot view holds a symbolic
39 /// link to UUID-view file.
42 /// UUID view : /tmp/lldb/remote-linux/.cache/30C94DC6-6A1F-E951-80C3-D68D2B89E576-D5AE213C/libc.so.6
43 /// Sysroot view: /tmp/lldb/remote-linux/ubuntu/lib/x86_64-linux-gnu/libc.so.6
44 //----------------------------------------------------------------------
49 using Downloader = std::function<Error (const ModuleSpec&, const FileSpec&)>;
52 GetAndPut(const FileSpec &root_dir_spec,
54 const ModuleSpec &module_spec,
55 const Downloader &downloader,
56 lldb::ModuleSP &cached_module_sp,
57 bool *did_create_ptr);
61 Put (const FileSpec &root_dir_spec,
63 const ModuleSpec &module_spec,
64 const FileSpec &tmp_file);
67 Get (const FileSpec &root_dir_spec,
69 const ModuleSpec &module_spec,
70 lldb::ModuleSP &cached_module_sp,
71 bool *did_create_ptr);
73 std::unordered_map<std::string, lldb::ModuleWP> m_loaded_modules;
76 } // namespace lldb_private
78 #endif // utility_ModuleCache_h_