Skip to content

Commit c5867f1

Browse files
committed
[LLDB] Support importing modules from llvmcas:// URLs
This patch creates a wrapper LLDB Swft module loader that owns both an ESML (explicit Swift module loader) and a CAS explicit module loader, dispatches module discovery calls to both, and tries to find each module in the CAS first, before trying the ESML. rdar://166576110
1 parent 69757c8 commit c5867f1

File tree

14 files changed

+540
-155
lines changed

14 files changed

+540
-155
lines changed

lldb/include/lldb/Core/ModuleList.h

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "lldb/lldb-types.h"
2323

2424
#include "llvm/ADT/DenseSet.h"
25-
#include "llvm/CAS/CASConfiguration.h"
2625
#include "llvm/Support/RWMutex.h"
2726

2827
#include <functional>
@@ -33,6 +32,14 @@
3332
#include <cstddef>
3433
#include <cstdint>
3534

35+
namespace llvm {
36+
namespace cas {
37+
class CASConfiguration;
38+
class ObjectStore;
39+
class ActionCache;
40+
} // namespace cas
41+
} // namespace llvm
42+
3643
namespace lldb_private {
3744
class ConstString;
3845
class FileSpecList;
@@ -106,6 +113,7 @@ class ModuleListProperties : public Properties {
106113
// START CAS
107114
/// Get CASPath set via properties.
108115
FileSpec GetCASOnDiskPath() const;
116+
bool SetCASOnDiskPath(const FileSpec &);
109117

110118
/// Get CASPluginPath set via properties.
111119
FileSpec GetCASPluginPath() const;
@@ -538,10 +546,14 @@ class ModuleList {
538546

539547
// START CAS
540548

541-
/// Get CAS configuration using global module properties or from candidate
542-
/// search path.
543-
static std::optional<llvm::cas::CASConfiguration>
544-
GetCASConfiguration(FileSpec CandidateConfigSearchPath);
549+
struct CAS {
550+
std::shared_ptr<llvm::cas::CASConfiguration> configuration;
551+
std::shared_ptr<llvm::cas::ObjectStore> object_store;
552+
std::shared_ptr<llvm::cas::ActionCache> action_cache;
553+
};
554+
/// Search for a CAS configuration file near this module. This
555+
/// operation does a lot of file system stat calls.
556+
static llvm::Expected<CAS> GetOrCreateCAS(const lldb::ModuleSP &module_sp);
545557

546558
/// Gets the shared module from CAS. It works the same as `GetSharedModule`
547559
/// but the lookup is done inside the CAS.
@@ -550,11 +562,9 @@ class ModuleList {
550562
/// true if module is successfully loaded, false if module is not found
551563
/// in the CAS, error if there are any errors happened during the loading
552564
/// process.
553-
static llvm::Expected<bool> GetSharedModuleFromCAS(ConstString module_name,
554-
llvm::StringRef cas_id,
555-
FileSpec cu_path,
556-
ModuleSpec &module_spec,
557-
lldb::ModuleSP &module_sp);
565+
static llvm::Expected<bool>
566+
GetSharedModuleFromCAS(llvm::StringRef cas_id, const lldb::ModuleSP &nearby,
567+
ModuleSpec &module_spec, lldb::ModuleSP &module_sp);
558568
// END CAS
559569

560570
static bool RemoveSharedModule(lldb::ModuleSP &module_sp);

0 commit comments

Comments
 (0)