Skip to content

Commit f80f15e

Browse files
committed
[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
1 parent f567b00 commit f80f15e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lldb/source/Initialization/SystemInitializerCommon.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ llvm::Error SystemInitializerCommon::Initialize() {
7878
} else {
7979
FileSystem::Initialize();
8080
}
81+
if (llvm::Expected<std::string> cwd =
82+
loader->LoadBuffer<WorkingDirectoryProvider>()) {
83+
FileSystem::Instance().GetVirtualFileSystem()->setCurrentWorkingDirectory(
84+
*cwd);
85+
} else {
86+
return cwd.takeError();
87+
}
8188
} else if (repro::Generator *g = r.GetGenerator()) {
8289
repro::VersionProvider &vp = g->GetOrCreate<repro::VersionProvider>();
8390
vp.SetVersion(lldb_private::GetVersion());
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
# This tests relative capture paths.
1+
# This tests that the reproducer can deal with relative files. We create a
2+
# binary in a subdirectory and pass its relative path to LLDB. The subdirectory
3+
# is removed before replay so that it only exists in the reproducer's VFS.
24

35
# RUN: echo "CHECK: %t" > %t.check
46

57
# RUN: rm -rf %t.repro
68
# RUN: mkdir -p %t.repro
79
# RUN: mkdir -p %t
10+
# RUN: mkdir -p %t/binary
811
# RUN: cd %t
9-
# RUN: %clang %S/Inputs/simple.c -g -o %t/reproducer.out
10-
# RUN: %lldb -x -b -s %S/Inputs/WorkingDir.in --capture --capture-path %t.repro %t/reproducer.out
12+
# RUN: %clang %S/Inputs/simple.c -g -o binary/reproducer.out
13+
# RUN: %lldb -x -b -s %S/Inputs/WorkingDir.in --capture --capture-path %t.repro binary/reproducer.out
14+
# RUN: rm -rf %t/binary
1115

1216
# RUN: cat %t.repro/cwd.txt | FileCheck %t.check
1317
# RUN: %lldb --replay %t.repro | FileCheck %t.check

0 commit comments

Comments
 (0)