summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-10-17 00:24:37 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-10-17 00:24:37 +0000
commitf80f15e38a21fb6a85d24853bdf2b8a6f1068571 (patch)
treefa37f54eec4ce018ade159d232141f74a0149720
parentf567b008804a019e12a050ada8c46ca7a6bf2720 (diff)
downloadbcm5719-llvm-f80f15e38a21fb6a85d24853bdf2b8a6f1068571.tar.gz
bcm5719-llvm-f80f15e38a21fb6a85d24853bdf2b8a6f1068571.zip
[Reproducer] Set the working directory in the VFS
Now that the VFS knows how to deal with virtual working directories, we can set the current working directory to the one we recorded during reproducer capture. This ensures that relative paths are resolved correctly during replay. llvm-svn: 375064
-rw-r--r--lldb/source/Initialization/SystemInitializerCommon.cpp7
-rw-r--r--lldb/test/Shell/Reproducer/TestWorkingDir.test10
2 files changed, 14 insertions, 3 deletions
diff --git a/lldb/source/Initialization/SystemInitializerCommon.cpp b/lldb/source/Initialization/SystemInitializerCommon.cpp
index e17dc65f671..5b8bd8926ac 100644
--- a/lldb/source/Initialization/SystemInitializerCommon.cpp
+++ b/lldb/source/Initialization/SystemInitializerCommon.cpp
@@ -78,6 +78,13 @@ llvm::Error SystemInitializerCommon::Initialize() {
} else {
FileSystem::Initialize();
}
+ if (llvm::Expected<std::string> cwd =
+ loader->LoadBuffer<WorkingDirectoryProvider>()) {
+ FileSystem::Instance().GetVirtualFileSystem()->setCurrentWorkingDirectory(
+ *cwd);
+ } else {
+ return cwd.takeError();
+ }
} else if (repro::Generator *g = r.GetGenerator()) {
repro::VersionProvider &vp = g->GetOrCreate<repro::VersionProvider>();
vp.SetVersion(lldb_private::GetVersion());
diff --git a/lldb/test/Shell/Reproducer/TestWorkingDir.test b/lldb/test/Shell/Reproducer/TestWorkingDir.test
index cef57e86511..c2f01244777 100644
--- a/lldb/test/Shell/Reproducer/TestWorkingDir.test
+++ b/lldb/test/Shell/Reproducer/TestWorkingDir.test
@@ -1,13 +1,17 @@
-# This tests relative capture paths.
+# This tests that the reproducer can deal with relative files. We create a
+# binary in a subdirectory and pass its relative path to LLDB. The subdirectory
+# is removed before replay so that it only exists in the reproducer's VFS.
# RUN: echo "CHECK: %t" > %t.check
# RUN: rm -rf %t.repro
# RUN: mkdir -p %t.repro
# RUN: mkdir -p %t
+# RUN: mkdir -p %t/binary
# RUN: cd %t
-# RUN: %clang %S/Inputs/simple.c -g -o %t/reproducer.out
-# RUN: %lldb -x -b -s %S/Inputs/WorkingDir.in --capture --capture-path %t.repro %t/reproducer.out
+# RUN: %clang %S/Inputs/simple.c -g -o binary/reproducer.out
+# RUN: %lldb -x -b -s %S/Inputs/WorkingDir.in --capture --capture-path %t.repro binary/reproducer.out
+# RUN: rm -rf %t/binary
# RUN: cat %t.repro/cwd.txt | FileCheck %t.check
# RUN: %lldb --replay %t.repro | FileCheck %t.check
OpenPOWER on IntegriCloud