Skip to content

[lldb/Utility] Don't forward directories to the file collector #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lldb/include/lldb/Host/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class FileSystem {
}

private:
void AddFile(const llvm::Twine &file);
static llvm::Optional<FileSystem> &InstanceImpl();
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs;
FileCollector *m_collector;
Expand Down
12 changes: 8 additions & 4 deletions lldb/source/Host/common/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -417,8 +416,7 @@ static mode_t GetOpenMode(uint32_t permissions) {

Status FileSystem::Open(File &File, const FileSpec &file_spec, uint32_t options,
uint32_t permissions, bool should_close_fd) {
if (m_collector)
m_collector->AddFile(file_spec);
AddFile(file_spec.GetPath());

if (File.IsValid())
File.Close();
Expand Down Expand Up @@ -469,3 +467,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);
}
}