summaryrefslogtreecommitdiff
path: root/lldb/source/Initialization/SystemInitializerCommon.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2020-08-20 16:19:17 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2020-08-20 18:08:59 -0700
commit73af341beb8435c7da1dd5e7a8abacb2de6a236d (patch)
tree57267efe91745a89b2c1976e81f09af4d9cb161d /lldb/source/Initialization/SystemInitializerCommon.cpp
parentc90ca0c8e4956e051e2f29cff0c38f9f03b32f87 (diff)
[lldb] Capture and load home directory from the reproducer.
When replaying the reproducer, lldb should source the .lldbinit file that was captured by the reproducer and not the one in the current home directory. This requires that we store the home directory as part of the reproducer. By returning the virtual home directory during replay, we ensure the correct virtual path gets constructed which the VFS can then find and remap to the correct file in the reproducer root. This patch adds a new HomeDirectoryProvider, similar to the existing WorkingDirectoryProvider. As the home directory is not part of the VFS, it is stored in LLDB's FileSystem instance.
Diffstat (limited to 'lldb/source/Initialization/SystemInitializerCommon.cpp')
-rw-r--r--lldb/source/Initialization/SystemInitializerCommon.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/lldb/source/Initialization/SystemInitializerCommon.cpp b/lldb/source/Initialization/SystemInitializerCommon.cpp
index c3bef4139bcc..4d72f6e2ad33 100644
--- a/lldb/source/Initialization/SystemInitializerCommon.cpp
+++ b/lldb/source/Initialization/SystemInitializerCommon.cpp
@@ -51,18 +51,24 @@ static llvm::Error InitializeFileSystem() {
FileSystem::Initialize();
}
- llvm::Expected<std::string> cwd =
- loader->LoadBuffer<WorkingDirectoryProvider>();
- if (!cwd)
- return cwd.takeError();
-
- llvm::StringRef working_dir = llvm::StringRef(*cwd).rtrim();
+ // Set the current working directory form the reproducer.
+ llvm::Expected<std::string> working_dir =
+ repro::GetDirectoryFrom<WorkingDirectoryProvider>(loader);
+ if (!working_dir)
+ return working_dir.takeError();
if (std::error_code ec = FileSystem::Instance()
.GetVirtualFileSystem()
- ->setCurrentWorkingDirectory(working_dir)) {
+ ->setCurrentWorkingDirectory(*working_dir)) {
return llvm::errorCodeToError(ec);
}
+ // Set the home directory from the reproducer.
+ llvm::Expected<std::string> home_dir =
+ repro::GetDirectoryFrom<HomeDirectoryProvider>(loader);
+ if (!home_dir)
+ return home_dir.takeError();
+ FileSystem::Instance().SetHomeDirectory(*home_dir);
+
return llvm::Error::success();
}