Skip to content

Commit 4c2b0a6

Browse files
committed
[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': [ ... ] }
1 parent b32013b commit 4c2b0a6

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lldb/include/lldb/Host/FileSystem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ class FileSystem {
187187
}
188188

189189
private:
190+
void AddFile(const llvm::Twine &file);
190191
static llvm::Optional<FileSystem> &InstanceImpl();
191192
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs;
192193
std::shared_ptr<llvm::FileCollector> m_collector;

lldb/source/Host/common/FileSystem.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ void FileSystem::Resolve(FileSpec &file_spec) {
279279
std::shared_ptr<DataBufferLLVM>
280280
FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size,
281281
uint64_t offset) {
282-
if (m_collector)
283-
m_collector->addFile(path);
282+
AddFile(path);
284283

285284
const bool is_volatile = !IsLocal(path);
286285
const ErrorOr<std::string> external_path = GetExternalPath(path);
@@ -418,8 +417,7 @@ static mode_t GetOpenMode(uint32_t permissions) {
418417
Expected<FileUP> FileSystem::Open(const FileSpec &file_spec,
419418
File::OpenOptions options,
420419
uint32_t permissions, bool should_close_fd) {
421-
if (m_collector)
422-
m_collector->addFile(file_spec.GetPath());
420+
AddFile(file_spec.GetPath());
423421

424422
const int open_flags = GetOpenFlags(options);
425423
const mode_t open_mode =
@@ -466,3 +464,9 @@ ErrorOr<std::string> FileSystem::GetExternalPath(const llvm::Twine &path) {
466464
ErrorOr<std::string> FileSystem::GetExternalPath(const FileSpec &file_spec) {
467465
return GetExternalPath(file_spec.GetPath());
468466
}
467+
468+
void FileSystem::AddFile(const llvm::Twine &file) {
469+
if (m_collector && !llvm::sys::fs::is_directory(file)) {
470+
m_collector->addFile(file);
471+
}
472+
}

0 commit comments

Comments
 (0)