diff --git a/lldb/include/lldb/Host/FileSystem.h b/lldb/include/lldb/Host/FileSystem.h index 9f863e8a9d7e2..50c48648fecda 100644 --- a/lldb/include/lldb/Host/FileSystem.h +++ b/lldb/include/lldb/Host/FileSystem.h @@ -33,11 +33,10 @@ class FileSystem { FileSystem() : m_fs(llvm::vfs::getRealFileSystem()), m_collector(nullptr) {} FileSystem(std::shared_ptr collector) - : m_fs(llvm::vfs::getRealFileSystem()), m_collector(std::move(collector)), - m_mapped(false) {} - FileSystem(llvm::IntrusiveRefCntPtr fs, - bool mapped = false) - : m_fs(std::move(fs)), m_collector(nullptr), m_mapped(mapped) {} + : m_fs(llvm::vfs::getRealFileSystem()), + m_collector(std::move(collector)) {} + FileSystem(llvm::IntrusiveRefCntPtr fs) + : m_fs(std::move(fs)), m_collector(nullptr) {} FileSystem(const FileSystem &fs) = delete; FileSystem &operator=(const FileSystem &fs) = delete; @@ -46,7 +45,6 @@ class FileSystem { static void Initialize(); static void Initialize(std::shared_ptr collector); - static llvm::Error Initialize(const FileSpec &mapping); static void Initialize(llvm::IntrusiveRefCntPtr fs); static void Terminate(); @@ -189,9 +187,6 @@ class FileSystem { std::error_code GetRealPath(const llvm::Twine &path, llvm::SmallVectorImpl &output) const; - llvm::ErrorOr GetExternalPath(const llvm::Twine &path); - llvm::ErrorOr GetExternalPath(const FileSpec &file_spec); - llvm::IntrusiveRefCntPtr GetVirtualFileSystem() { return m_fs; } @@ -206,7 +201,6 @@ class FileSystem { llvm::IntrusiveRefCntPtr m_fs; std::shared_ptr m_collector; std::string m_home_directory; - bool m_mapped = false; }; } // namespace lldb_private diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp index 26a98fa0a4ec4..4a8cc3a21ea43 100644 --- a/lldb/source/Host/common/FileSystem.cpp +++ b/lldb/source/Host/common/FileSystem.cpp @@ -54,22 +54,6 @@ void FileSystem::Initialize(std::shared_ptr collector) { InstanceImpl().emplace(collector); } -llvm::Error FileSystem::Initialize(const FileSpec &mapping) { - lldbassert(!InstanceImpl() && "Already initialized."); - - llvm::ErrorOr> buffer = - llvm::vfs::getRealFileSystem()->getBufferForFile(mapping.GetPath()); - - if (!buffer) - return llvm::errorCodeToError(buffer.getError()); - - InstanceImpl().emplace(llvm::vfs::getVFSFromYAML(std::move(buffer.get()), - nullptr, mapping.GetPath()), - true); - - return llvm::Error::success(); -} - void FileSystem::Initialize(IntrusiveRefCntPtr fs) { lldbassert(!InstanceImpl() && "Already initialized."); InstanceImpl().emplace(fs); @@ -300,21 +284,16 @@ FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size, Collect(path); const bool is_volatile = !IsLocal(path); - const ErrorOr external_path = GetExternalPath(path); - - if (!external_path) - return nullptr; - std::unique_ptr buffer; if (size == 0) { auto buffer_or_error = - llvm::WritableMemoryBuffer::getFile(*external_path, is_volatile); + llvm::WritableMemoryBuffer::getFile(path, is_volatile); if (!buffer_or_error) return nullptr; buffer = std::move(*buffer_or_error); } else { auto buffer_or_error = llvm::WritableMemoryBuffer::getFileSlice( - *external_path, size, offset, is_volatile); + path, size, offset, is_volatile); if (!buffer_or_error) return nullptr; buffer = std::move(*buffer_or_error); @@ -457,12 +436,10 @@ Expected FileSystem::Open(const FileSpec &file_spec, const mode_t open_mode = (open_flags & O_CREAT) ? GetOpenMode(permissions) : 0; - auto path = GetExternalPath(file_spec); - if (!path) - return errorCodeToError(path.getError()); + auto path = file_spec.GetPath(); int descriptor = llvm::sys::RetryAfterSignal( - -1, OpenWithFS, *this, path->c_str(), open_flags, open_mode); + -1, OpenWithFS, *this, path.c_str(), open_flags, open_mode); if (!File::DescriptorIsValid(descriptor)) return llvm::errorCodeToError( @@ -474,29 +451,6 @@ Expected FileSystem::Open(const FileSpec &file_spec, return std::move(file); } -ErrorOr FileSystem::GetExternalPath(const llvm::Twine &path) { - if (!m_mapped) - return path.str(); - - // If VFS mapped we know the underlying FS is a RedirectingFileSystem. - ErrorOr Result = - static_cast(*m_fs).lookupPath(path.str()); - if (!Result) { - if (Result.getError() == llvm::errc::no_such_file_or_directory) { - return path.str(); - } - return Result.getError(); - } - - if (Optional ExtRedirect = Result->getExternalRedirect()) - return std::string(*ExtRedirect); - return make_error_code(llvm::errc::not_supported); -} - -ErrorOr FileSystem::GetExternalPath(const FileSpec &file_spec) { - return GetExternalPath(file_spec.GetPath()); -} - void FileSystem::Collect(const FileSpec &file_spec) { Collect(file_spec.GetPath()); } diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm index 06d14ede35c38..0a51e534896a1 100644 --- a/lldb/source/Host/macosx/objcxx/Host.mm +++ b/lldb/source/Host/macosx/objcxx/Host.mm @@ -1305,15 +1305,12 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info) { lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; - // From now on we'll deal with the external (devirtualized) path. - auto exe_path = fs.GetExternalPath(exe_spec); - if (!exe_path) - return Status(exe_path.getError()); + auto exe_path = exe_spec.GetPath(); if (ShouldLaunchUsingXPC(launch_info)) - error = LaunchProcessXPC(exe_path->c_str(), launch_info, pid); + error = LaunchProcessXPC(exe_path.c_str(), launch_info, pid); else - error = LaunchProcessPosixSpawn(exe_path->c_str(), launch_info, pid); + error = LaunchProcessPosixSpawn(exe_path.c_str(), launch_info, pid); if (pid != LLDB_INVALID_PROCESS_ID) { // If all went well, then set the process ID into the launch info diff --git a/lldb/source/Initialization/SystemInitializerCommon.cpp b/lldb/source/Initialization/SystemInitializerCommon.cpp index 7994aefa185c8..bb44d9116717c 100644 --- a/lldb/source/Initialization/SystemInitializerCommon.cpp +++ b/lldb/source/Initialization/SystemInitializerCommon.cpp @@ -43,36 +43,6 @@ SystemInitializerCommon::~SystemInitializerCommon() = default; /// Initialize the FileSystem based on the current reproducer mode. static llvm::Error InitializeFileSystem() { auto &r = repro::Reproducer::Instance(); - if (repro::Loader *loader = r.GetLoader()) { - FileSpec vfs_mapping = loader->GetFile(); - if (vfs_mapping) { - if (llvm::Error e = FileSystem::Initialize(vfs_mapping)) - return e; - } else { - FileSystem::Initialize(); - } - - // Set the current working directory form the reproducer. - llvm::Expected working_dir = - repro::GetDirectoryFrom(loader); - if (!working_dir) - return working_dir.takeError(); - if (std::error_code ec = FileSystem::Instance() - .GetVirtualFileSystem() - ->setCurrentWorkingDirectory(*working_dir)) { - return llvm::errorCodeToError(ec); - } - - // Set the home directory from the reproducer. - llvm::Expected home_dir = - repro::GetDirectoryFrom(loader); - if (!home_dir) - return home_dir.takeError(); - FileSystem::Instance().SetHomeDirectory(*home_dir); - - return llvm::Error::success(); - } - if (repro::Generator *g = r.GetGenerator()) { repro::VersionProvider &vp = g->GetOrCreate(); vp.SetVersion(lldb_private::GetVersion());