Author: Jonas Devlieghere Date: 2020-01-22T15:01:53-08:00 New Revision: 4c2b0a63661576c1849862bad3978050fc6a2ff7
URL: https://github.com/llvm/llvm-project/commit/4c2b0a63661576c1849862bad3978050fc6a2ff7 DIFF: https://github.com/llvm/llvm-project/commit/4c2b0a63661576c1849862bad3978050fc6a2ff7.diff LOG: [lldb/Utility] Don't forward directories to the file collector The VFS mapping writer assumes that all the paths it gets are files. When passed a directory, it ends up as a file in the VFS mapping twice, once as a file and once as a directory. { 'type': 'file', 'name': "Output", 'external-contents': "/root/path/to/Output" }, { 'type': 'directory', 'name': "Output", 'contents': [ ... ] } Added: Modified: lldb/include/lldb/Host/FileSystem.h lldb/source/Host/common/FileSystem.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Host/FileSystem.h b/lldb/include/lldb/Host/FileSystem.h index 528c43519a32..af1bbbd1c397 100644 --- a/lldb/include/lldb/Host/FileSystem.h +++ b/lldb/include/lldb/Host/FileSystem.h @@ -187,6 +187,7 @@ class FileSystem { } private: + void AddFile(const llvm::Twine &file); static llvm::Optional<FileSystem> &InstanceImpl(); llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs; std::shared_ptr<llvm::FileCollector> m_collector; diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp index 2db5bff3207f..7f15a6bdb094 100644 --- a/lldb/source/Host/common/FileSystem.cpp +++ b/lldb/source/Host/common/FileSystem.cpp @@ -279,8 +279,7 @@ void FileSystem::Resolve(FileSpec &file_spec) { std::shared_ptr<DataBufferLLVM> FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size, uint64_t offset) { - if (m_collector) - m_collector->addFile(path); + AddFile(path); const bool is_volatile = !IsLocal(path); const ErrorOr<std::string> external_path = GetExternalPath(path); @@ -418,8 +417,7 @@ static mode_t GetOpenMode(uint32_t permissions) { Expected<FileUP> FileSystem::Open(const FileSpec &file_spec, File::OpenOptions options, uint32_t permissions, bool should_close_fd) { - if (m_collector) - m_collector->addFile(file_spec.GetPath()); + AddFile(file_spec.GetPath()); const int open_flags = GetOpenFlags(options); const mode_t open_mode = @@ -466,3 +464,9 @@ ErrorOr<std::string> FileSystem::GetExternalPath(const llvm::Twine &path) { ErrorOr<std::string> FileSystem::GetExternalPath(const FileSpec &file_spec) { return GetExternalPath(file_spec.GetPath()); } + +void FileSystem::AddFile(const llvm::Twine &file) { + if (m_collector && !llvm::sys::fs::is_directory(file)) { + m_collector->addFile(file); + } +} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits