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 LLDB_TARGET_MODULECACHE_H
11 #define LLDB_TARGET_MODULECACHE_H
13 #include "lldb/lldb-forward.h"
14 #include "lldb/lldb-types.h"
16 #include "lldb/Host/File.h"
17 #include "lldb/Utility/FileSpec.h"
18 #include "lldb/Utility/Status.h"
22 #include <unordered_map>
24 namespace lldb_private {
29 //----------------------------------------------------------------------
30 /// @class ModuleCache ModuleCache.h "lldb/Target/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:
36 /// /${CACHE_ROOT}/${PLATFORM_NAME}/.cache/${UUID}/${MODULE_FILENAME}
38 /// /${CACHE_ROOT}/${PLATFORM_NAME}/${HOSTNAME}/${MODULE_FULL_FILEPATH}
40 /// UUID views stores a real module file, whereas Sysroot view holds a symbolic
41 /// link to UUID-view file.
45 /// /tmp/lldb/remote-linux/.cache/30C94DC6-6A1F-E951-80C3-D68D2B89E576-D5AE213C/libc.so.6
46 /// Sysroot view: /tmp/lldb/remote-linux/ubuntu/lib/x86_64-linux-gnu/libc.so.6
47 //----------------------------------------------------------------------
51 using ModuleDownloader =
52 std::function<Status(const ModuleSpec &, const FileSpec &)>;
53 using SymfileDownloader =
54 std::function<Status(const lldb::ModuleSP &, const FileSpec &)>;
56 Status GetAndPut(const FileSpec &root_dir_spec, const char *hostname,
57 const ModuleSpec &module_spec,
58 const ModuleDownloader &module_downloader,
59 const SymfileDownloader &symfile_downloader,
60 lldb::ModuleSP &cached_module_sp, bool *did_create_ptr);
63 Status Put(const FileSpec &root_dir_spec, const char *hostname,
64 const ModuleSpec &module_spec, const FileSpec &tmp_file,
65 const FileSpec &target_file);
67 Status Get(const FileSpec &root_dir_spec, const char *hostname,
68 const ModuleSpec &module_spec, lldb::ModuleSP &cached_module_sp,
69 bool *did_create_ptr);
71 std::unordered_map<std::string, lldb::ModuleWP> m_loaded_modules;
74 } // namespace lldb_private
76 #endif // utility_ModuleCache_h_