diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-01-29 20:36:38 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-01-29 20:36:38 +0000 |
commit | ba22da9479aea2956c743caf394ddd0fba4002be (patch) | |
tree | f82bfbdd3fcb92a3ad3dc79e56cd6f0bfe4a29c7 /source/Initialization/SystemInitializerCommon.cpp | |
parent | 0e6825fcf0685740e367b4816e63238af4e70148 (diff) |
[Reproducers] Add file provider
This patch adds the file provider which is responsible for capturing
files used by LLDB.
When capturing a reproducer, we use a file collector that is very
similar to the one used in clang. For every file that we touch, we add
an entry with a mapping from its virtual to its real path. When we
decide to generate a reproducer we copy over the files and their
permission into to reproducer folder.
When replaying a reproducer, we load the VFS mapping and instantiate a
RedirectingFileSystem. The latter will transparently use the files
available in the reproducer.
I've tested this on two macOS machines with an artificial example.
Still, it is very likely that I missed some places where we (still) use
native file system calls. I'm hoping to flesh those out while testing
with more advanced examples. However, I will fix those things in
separate patches.
Differential revision: https://reviews.llvm.org/D54617
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@352538 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'source/Initialization/SystemInitializerCommon.cpp')
-rw-r--r-- | source/Initialization/SystemInitializerCommon.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/source/Initialization/SystemInitializerCommon.cpp b/source/Initialization/SystemInitializerCommon.cpp index 2cc3aa8c6..173d48308 100644 --- a/source/Initialization/SystemInitializerCommon.cpp +++ b/source/Initialization/SystemInitializerCommon.cpp @@ -65,6 +65,7 @@ SystemInitializerCommon::Initialize(const InitializerOptions &options) { } #endif + // Initialize the reproducer. ReproducerMode mode = ReproducerMode::Off; if (options.reproducer_capture) mode = ReproducerMode::Capture; @@ -74,7 +75,23 @@ SystemInitializerCommon::Initialize(const InitializerOptions &options) { if (auto e = Reproducer::Initialize(mode, FileSpec(options.reproducer_path))) return e; - FileSystem::Initialize(); + // Initialize the file system. + auto &r = repro::Reproducer::Instance(); + if (repro::Loader *loader = r.GetLoader()) { + FileSpec vfs_mapping = loader->GetFile<FileInfo>(); + if (vfs_mapping) { + if (llvm::Error e = FileSystem::Initialize(vfs_mapping)) + return e; + } else { + FileSystem::Initialize(); + } + } else if (repro::Generator *g = r.GetGenerator()) { + repro::FileProvider &fp = g->GetOrCreate<repro::FileProvider>(); + FileSystem::Initialize(fp.GetFileCollector()); + } else { + FileSystem::Initialize(); + } + Log::Initialize(); HostInfo::Initialize(); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); |