Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:53

0001 //===-- ModuleCache.h -------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_TARGET_MODULECACHE_H
0010 #define LLDB_TARGET_MODULECACHE_H
0011 
0012 #include "lldb/lldb-forward.h"
0013 #include "lldb/lldb-types.h"
0014 
0015 #include "lldb/Host/File.h"
0016 #include "lldb/Utility/FileSpec.h"
0017 #include "lldb/Utility/Status.h"
0018 
0019 #include <functional>
0020 #include <string>
0021 #include <unordered_map>
0022 
0023 namespace lldb_private {
0024 
0025 class Module;
0026 class UUID;
0027 
0028 /// \class ModuleCache ModuleCache.h "lldb/Target/ModuleCache.h"
0029 /// A module cache class.
0030 ///
0031 /// Caches locally modules that are downloaded from remote targets. Each
0032 /// cached module maintains 2 views:
0033 ///  - UUID view:
0034 ///  /${CACHE_ROOT}/${PLATFORM_NAME}/.cache/${UUID}/${MODULE_FILENAME}
0035 ///  - Sysroot view:
0036 ///  /${CACHE_ROOT}/${PLATFORM_NAME}/${HOSTNAME}/${MODULE_FULL_FILEPATH}
0037 ///
0038 /// UUID views stores a real module file, whereas Sysroot view holds a symbolic
0039 /// link to UUID-view file.
0040 ///
0041 /// Example:
0042 /// UUID view   :
0043 /// /tmp/lldb/remote-
0044 /// linux/.cache/30C94DC6-6A1F-E951-80C3-D68D2B89E576-D5AE213C/libc.so.6
0045 /// Sysroot view: /tmp/lldb/remote-linux/ubuntu/lib/x86_64-linux-gnu/libc.so.6
0046 
0047 class ModuleCache {
0048 public:
0049   using ModuleDownloader =
0050       std::function<Status(const ModuleSpec &, const FileSpec &)>;
0051   using SymfileDownloader =
0052       std::function<Status(const lldb::ModuleSP &, const FileSpec &)>;
0053 
0054   Status GetAndPut(const FileSpec &root_dir_spec, const char *hostname,
0055                    const ModuleSpec &module_spec,
0056                    const ModuleDownloader &module_downloader,
0057                    const SymfileDownloader &symfile_downloader,
0058                    lldb::ModuleSP &cached_module_sp, bool *did_create_ptr);
0059 
0060 private:
0061   Status Put(const FileSpec &root_dir_spec, const char *hostname,
0062              const ModuleSpec &module_spec, const FileSpec &tmp_file,
0063              const FileSpec &target_file);
0064 
0065   Status Get(const FileSpec &root_dir_spec, const char *hostname,
0066              const ModuleSpec &module_spec, lldb::ModuleSP &cached_module_sp,
0067              bool *did_create_ptr);
0068 
0069   std::unordered_map<std::string, lldb::ModuleWP> m_loaded_modules;
0070 };
0071 
0072 } // namespace lldb_private
0073 
0074 #endif // LLDB_TARGET_MODULECACHE_H