aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Utility/Reproducer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Utility/Reproducer.cpp')
-rw-r--r--lldb/source/Utility/Reproducer.cpp147
1 files changed, 0 insertions, 147 deletions
diff --git a/lldb/source/Utility/Reproducer.cpp b/lldb/source/Utility/Reproducer.cpp
index 1e71dba472ed..3641c933c38a 100644
--- a/lldb/source/Utility/Reproducer.cpp
+++ b/lldb/source/Utility/Reproducer.cpp
@@ -136,7 +136,6 @@ Generator::~Generator() {
if (!m_done) {
if (m_auto_generate) {
Keep();
- llvm::cantFail(Finalize(GetRoot()));
} else {
Discard();
}
@@ -229,149 +228,3 @@ bool Loader::HasFile(StringRef file) {
auto it = std::lower_bound(m_files.begin(), m_files.end(), file.str());
return (it != m_files.end()) && (*it == file);
}
-
-void Verifier::Verify(
- llvm::function_ref<void(llvm::StringRef)> error_callback,
- llvm::function_ref<void(llvm::StringRef)> warning_callback,
- llvm::function_ref<void(llvm::StringRef)> note_callack) const {
- if (!m_loader) {
- error_callback("invalid loader");
- return;
- }
-
- FileSpec vfs_mapping = m_loader->GetFile<FileProvider::Info>();
- ErrorOr<std::unique_ptr<MemoryBuffer>> buffer =
- vfs::getRealFileSystem()->getBufferForFile(vfs_mapping.GetPath());
- if (!buffer) {
- error_callback("unable to read files: " + buffer.getError().message());
- return;
- }
-
- IntrusiveRefCntPtr<vfs::FileSystem> vfs = vfs::getVFSFromYAML(
- std::move(buffer.get()), nullptr, vfs_mapping.GetPath());
- if (!vfs) {
- error_callback("unable to initialize the virtual file system");
- return;
- }
-
- auto &redirecting_vfs = static_cast<vfs::RedirectingFileSystem &>(*vfs);
- redirecting_vfs.setFallthrough(false);
-
- {
- llvm::Expected<std::string> working_dir =
- GetDirectoryFrom<WorkingDirectoryProvider>(m_loader);
- if (working_dir) {
- if (!vfs->exists(*working_dir))
- warning_callback("working directory '" + *working_dir + "' not in VFS");
- vfs->setCurrentWorkingDirectory(*working_dir);
- } else {
- warning_callback("no working directory in reproducer: " +
- toString(working_dir.takeError()));
- }
- }
-
- {
- llvm::Expected<std::string> home_dir =
- GetDirectoryFrom<HomeDirectoryProvider>(m_loader);
- if (home_dir) {
- if (!vfs->exists(*home_dir))
- warning_callback("home directory '" + *home_dir + "' not in VFS");
- } else {
- warning_callback("no home directory in reproducer: " +
- toString(home_dir.takeError()));
- }
- }
-
- {
- Expected<std::string> symbol_files =
- m_loader->LoadBuffer<SymbolFileProvider>();
- if (symbol_files) {
- std::vector<SymbolFileProvider::Entry> entries;
- llvm::yaml::Input yin(*symbol_files);
- yin >> entries;
- for (const auto &entry : entries) {
- if (!entry.module_path.empty() && !vfs->exists(entry.module_path)) {
- warning_callback("'" + entry.module_path + "': module path for " +
- entry.uuid + " not in VFS");
- }
- if (!entry.symbol_path.empty() && !vfs->exists(entry.symbol_path)) {
- warning_callback("'" + entry.symbol_path + "': symbol path for " +
- entry.uuid + " not in VFS");
- }
- }
- } else {
- llvm::consumeError(symbol_files.takeError());
- }
- }
-
- // Missing files in the VFS are notes rather than warnings. Because the VFS
- // is a snapshot, temporary files could have been removed between when they
- // were recorded and when the reproducer was generated.
- std::vector<llvm::StringRef> roots = redirecting_vfs.getRoots();
- for (llvm::StringRef root : roots) {
- std::error_code ec;
- vfs::recursive_directory_iterator iter(*vfs, root, ec);
- vfs::recursive_directory_iterator end;
- for (; iter != end && !ec; iter.increment(ec)) {
- ErrorOr<vfs::Status> status = vfs->status(iter->path());
- if (!status)
- note_callack("'" + iter->path().str() +
- "': " + status.getError().message());
- }
- }
-}
-
-static llvm::Error addPaths(StringRef path,
- function_ref<void(StringRef)> callback) {
- auto buffer = llvm::MemoryBuffer::getFile(path);
- if (!buffer)
- return errorCodeToError(buffer.getError());
-
- SmallVector<StringRef, 0> paths;
- (*buffer)->getBuffer().split(paths, '\0');
- for (StringRef p : paths) {
- if (!p.empty() && llvm::sys::fs::exists(p))
- callback(p);
- }
-
- return errorCodeToError(llvm::sys::fs::remove(path));
-}
-
-llvm::Error repro::Finalize(Loader *loader) {
- if (!loader)
- return make_error<StringError>("invalid loader",
- llvm::inconvertibleErrorCode());
-
- FileSpec reproducer_root = loader->GetRoot();
- std::string files_path =
- reproducer_root.CopyByAppendingPathComponent("files.txt").GetPath();
- std::string dirs_path =
- reproducer_root.CopyByAppendingPathComponent("dirs.txt").GetPath();
-
- FileCollector collector(
- reproducer_root.CopyByAppendingPathComponent("root").GetPath(),
- reproducer_root.GetPath());
-
- if (Error e =
- addPaths(files_path, [&](StringRef p) { collector.addFile(p); }))
- return e;
-
- if (Error e =
- addPaths(dirs_path, [&](StringRef p) { collector.addDirectory(p); }))
- return e;
-
- FileSpec mapping =
- reproducer_root.CopyByAppendingPathComponent(FileProvider::Info::file);
- if (auto ec = collector.copyFiles(/*StopOnError=*/false))
- return errorCodeToError(ec);
- collector.writeMapping(mapping.GetPath());
-
- return llvm::Error::success();
-}
-
-llvm::Error repro::Finalize(const FileSpec &root) {
- Loader loader(root);
- if (Error e = loader.LoadIndex())
- return e;
- return Finalize(&loader);
-}