[Lldb-commits] [lldb] r375064 - [Reproducer] Set the working directory in the VFS

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 16 17:24:39 PDT 2019


Author: jdevlieghere
Date: Wed Oct 16 17:24:37 2019
New Revision: 375064

URL: http://llvm.org/viewvc/llvm-project?rev=375064&view=rev
Log:
[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.

Modified:
    lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
    lldb/trunk/test/Shell/Reproducer/TestWorkingDir.test

Modified: lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/SystemInitializerCommon.cpp?rev=375064&r1=375063&r2=375064&view=diff
==============================================================================
--- lldb/trunk/source/Initialization/SystemInitializerCommon.cpp (original)
+++ lldb/trunk/source/Initialization/SystemInitializerCommon.cpp Wed Oct 16 17:24:37 2019
@@ -78,6 +78,13 @@ llvm::Error SystemInitializerCommon::Ini
     } 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());

Modified: lldb/trunk/test/Shell/Reproducer/TestWorkingDir.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/Reproducer/TestWorkingDir.test?rev=375064&r1=375063&r2=375064&view=diff
==============================================================================
--- lldb/trunk/test/Shell/Reproducer/TestWorkingDir.test (original)
+++ lldb/trunk/test/Shell/Reproducer/TestWorkingDir.test Wed Oct 16 17:24:37 2019
@@ -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




More information about the lldb-commits mailing list