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 ModuleDownloader = std::function<Error (const ModuleSpec&, const FileSpec&)>;
50 using SymfileDownloader = std::function<Error (const lldb::ModuleSP&, const FileSpec&)>;
53 GetAndPut(const FileSpec &root_dir_spec,
55 const ModuleSpec &module_spec,
56 const ModuleDownloader &module_downloader,
57 const SymfileDownloader &symfile_downloader,
58 lldb::ModuleSP &cached_module_sp,
59 bool *did_create_ptr);
63 Put (const FileSpec &root_dir_spec,
65 const ModuleSpec &module_spec,
66 const FileSpec &tmp_file,
67 const FileSpec &target_file);
70 Get (const FileSpec &root_dir_spec,
72 const ModuleSpec &module_spec,
73 lldb::ModuleSP &cached_module_sp,
74 bool *did_create_ptr);
76 std::unordered_map<std::string, lldb::ModuleWP> m_loaded_modules;
79 } // namespace lldb_private
81 #endif // utility_ModuleCache_h_