aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/VirtualFileSystem.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2024-09-06 14:14:44 -0700
committerGitHub <noreply@github.com>2024-09-06 14:14:44 -0700
commit70fcdb3d52272eba96d4b268d334826690524f50 (patch)
tree3376b22d8498ac5672b9cd7108456be82103567f /llvm/lib/Support/VirtualFileSystem.cpp
parent7815abec165114da29e191022c2816f857b1984f (diff)
downloadllvm-70fcdb3d52272eba96d4b268d334826690524f50.zip
llvm-70fcdb3d52272eba96d4b268d334826690524f50.tar.gz
llvm-70fcdb3d52272eba96d4b268d334826690524f50.tar.bz2
[llvm][support] Implement tracing virtual file system (#88326)
LLVM-based tools often use the `llvm::vfs::FileSystem` instrastructure to access the file system. This patch adds new kind of a VFS that performs lightweight tracing of file system operations on an underlying VFS. This is supposed to aid in investigating file system traffic without resorting to instrumentation on the operating system level. There will be follow-up patches that integrate this into Clang and its dependency scanner.
Diffstat (limited to 'llvm/lib/Support/VirtualFileSystem.cpp')
-rw-r--r--llvm/lib/Support/VirtualFileSystem.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index 6d756f4..928c0b5 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -2945,8 +2945,34 @@ recursive_directory_iterator::increment(std::error_code &EC) {
return *this;
}
+void TracingFileSystem::printImpl(raw_ostream &OS, PrintType Type,
+ unsigned IndentLevel) const {
+ printIndent(OS, IndentLevel);
+ OS << "TracingFileSystem\n";
+ if (Type == PrintType::Summary)
+ return;
+
+ printIndent(OS, IndentLevel);
+ OS << "NumStatusCalls=" << NumStatusCalls << "\n";
+ printIndent(OS, IndentLevel);
+ OS << "NumOpenFileForReadCalls=" << NumOpenFileForReadCalls << "\n";
+ printIndent(OS, IndentLevel);
+ OS << "NumDirBeginCalls=" << NumDirBeginCalls << "\n";
+ printIndent(OS, IndentLevel);
+ OS << "NumGetRealPathCalls=" << NumGetRealPathCalls << "\n";
+ printIndent(OS, IndentLevel);
+ OS << "NumExistsCalls=" << NumExistsCalls << "\n";
+ printIndent(OS, IndentLevel);
+ OS << "NumIsLocalCalls=" << NumIsLocalCalls << "\n";
+
+ if (Type == PrintType::Contents)
+ Type = PrintType::Summary;
+ getUnderlyingFS().print(OS, Type, IndentLevel + 1);
+}
+
const char FileSystem::ID = 0;
const char OverlayFileSystem::ID = 0;
const char ProxyFileSystem::ID = 0;
const char InMemoryFileSystem::ID = 0;
const char RedirectingFileSystem::ID = 0;
+const char TracingFileSystem::ID = 0;