From: Jonas Devlieghere Date: Mon, 20 Jul 2020 18:23:43 +0000 (-0700) Subject: [lldb/Reproducers] Always record the current working directory X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8df2e1a19913e997d8d6dbe573de977406e736e;p=platform%2Fupstream%2Fllvm.git [lldb/Reproducers] Always record the current working directory Setting the current working directory in the VFS will fail if the given path doesn't exist in the YAML mapping or on disk. --- diff --git a/lldb/include/lldb/Utility/Reproducer.h b/lldb/include/lldb/Utility/Reproducer.h index 2714db8..6fcb839 100644 --- a/lldb/include/lldb/Utility/Reproducer.h +++ b/lldb/include/lldb/Utility/Reproducer.h @@ -11,6 +11,7 @@ #include "lldb/Utility/FileSpec.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/FileCollector.h" #include "llvm/Support/YAMLTraits.h" @@ -149,6 +150,7 @@ public: } void Update(llvm::StringRef path) { m_cwd = std::string(path); } + llvm::StringRef GetWorkingDirectory() { return m_cwd; } struct Info { static const char *name; diff --git a/lldb/source/API/SBReproducer.cpp b/lldb/source/API/SBReproducer.cpp index 0eb3429..9815bf1 100644 --- a/lldb/source/API/SBReproducer.cpp +++ b/lldb/source/API/SBReproducer.cpp @@ -234,7 +234,10 @@ const char *SBReproducer::GetPath() { void SBReproducer::SetWorkingDirectory(const char *path) { if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) { - g->GetOrCreate().Update(path); + auto &wp = g->GetOrCreate(); + wp.Update(path); + auto &fp = g->GetOrCreate(); + fp.RecordInterestingDirectory(wp.GetWorkingDirectory()); } } diff --git a/lldb/source/Initialization/SystemInitializerCommon.cpp b/lldb/source/Initialization/SystemInitializerCommon.cpp index 0cef2a4..3d07f92 100644 --- a/lldb/source/Initialization/SystemInitializerCommon.cpp +++ b/lldb/source/Initialization/SystemInitializerCommon.cpp @@ -94,6 +94,8 @@ llvm::Error SystemInitializerCommon::Initialize() { vp.SetVersion(lldb_private::GetVersion()); repro::FileProvider &fp = g->GetOrCreate(); FileSystem::Initialize(fp.GetFileCollector()); + repro::WorkingDirectoryProvider &wp = g->GetOrCreate(); + fp.RecordInterestingDirectory(wp.GetWorkingDirectory()); } else { FileSystem::Initialize(); } diff --git a/lldb/test/Shell/Reproducer/TestWorkingDir.test b/lldb/test/Shell/Reproducer/TestWorkingDir.test index 1d4c769..76df41f 100644 --- a/lldb/test/Shell/Reproducer/TestWorkingDir.test +++ b/lldb/test/Shell/Reproducer/TestWorkingDir.test @@ -15,3 +15,13 @@ # RUN: cat %t.repro/cwd.txt | FileCheck %t.check # RUN: %lldb --replay %t.repro | FileCheck %t.check + +# Make sure the current working directory is recorded even when it's not +# referenced. + +# RUN: rm -rf %t.repro +# RUN: mkdir -p %t/probably_unique +# RUN: cd %t/probably_unique +# RUN: %lldb -x -b -o 'reproducer generate' --capture --capture-path %t.repro +# RUN: cat %t.repro/cwd.txt | FileCheck %s +# CHECK: probably_unique