This revision was automatically updated to reflect the committed changes. Closed by commit rG6671a81bc71c: [lldb/Reproducers] Add test-specific API to set the test CWD (authored by JDevlieghere). Herald added a project: LLDB.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79825/new/ https://reviews.llvm.org/D79825 Files: lldb/bindings/interface/SBReproducer.i lldb/include/lldb/API/SBReproducer.h lldb/include/lldb/Utility/Reproducer.h lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/source/API/SBReproducer.cpp Index: lldb/source/API/SBReproducer.cpp =================================================================== --- lldb/source/API/SBReproducer.cpp +++ lldb/source/API/SBReproducer.cpp @@ -231,6 +231,12 @@ return path.c_str(); } +void SBReproducer::SetWorkingDirectory(const char *path) { + if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) { + g->GetOrCreate<WorkingDirectoryProvider>().Update(path); + } +} + char lldb_private::repro::SBProvider::ID = 0; const char *SBProvider::Info::name = "sbapi"; const char *SBProvider::Info::file = "sbapi.bin"; Index: lldb/packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- lldb/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -526,6 +526,7 @@ if traceAlways: print("Change dir to:", full_dir, file=sys.stderr) os.chdir(full_dir) + lldb.SBReproducer.SetWorkingDirectory(full_dir) # Set platform context. cls.platformContext = lldbplatformutil.createPlatformContext() Index: lldb/include/lldb/Utility/Reproducer.h =================================================================== --- lldb/include/lldb/Utility/Reproducer.h +++ lldb/include/lldb/Utility/Reproducer.h @@ -147,6 +147,9 @@ return; m_cwd = std::string(cwd.str()); } + + void Update(llvm::StringRef path) { m_cwd = std::string(path); } + struct Info { static const char *name; static const char *file; Index: lldb/include/lldb/API/SBReproducer.h =================================================================== --- lldb/include/lldb/API/SBReproducer.h +++ lldb/include/lldb/API/SBReproducer.h @@ -26,6 +26,13 @@ static const char *GetPath(); static bool SetAutoGenerate(bool b); static bool Generate(); + + /// The working directory is set to the current working directory when the + /// reproducers are initialized. This method allows setting a different + /// working directory. This is used by the API test suite which temporarily + /// changes the directory to where the test lives. This is a NO-OP in every + /// mode but capture. + static void SetWorkingDirectory(const char *path); }; } // namespace lldb Index: lldb/bindings/interface/SBReproducer.i =================================================================== --- lldb/bindings/interface/SBReproducer.i +++ lldb/bindings/interface/SBReproducer.i @@ -13,5 +13,6 @@ static const char *Capture(const char *path); static const char *PassiveReplay(const char *path); static bool SetAutoGenerate(bool b); + static void SetWorkingDirectory(const char *path); }; }
Index: lldb/source/API/SBReproducer.cpp =================================================================== --- lldb/source/API/SBReproducer.cpp +++ lldb/source/API/SBReproducer.cpp @@ -231,6 +231,12 @@ return path.c_str(); } +void SBReproducer::SetWorkingDirectory(const char *path) { + if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) { + g->GetOrCreate<WorkingDirectoryProvider>().Update(path); + } +} + char lldb_private::repro::SBProvider::ID = 0; const char *SBProvider::Info::name = "sbapi"; const char *SBProvider::Info::file = "sbapi.bin"; Index: lldb/packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- lldb/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -526,6 +526,7 @@ if traceAlways: print("Change dir to:", full_dir, file=sys.stderr) os.chdir(full_dir) + lldb.SBReproducer.SetWorkingDirectory(full_dir) # Set platform context. cls.platformContext = lldbplatformutil.createPlatformContext() Index: lldb/include/lldb/Utility/Reproducer.h =================================================================== --- lldb/include/lldb/Utility/Reproducer.h +++ lldb/include/lldb/Utility/Reproducer.h @@ -147,6 +147,9 @@ return; m_cwd = std::string(cwd.str()); } + + void Update(llvm::StringRef path) { m_cwd = std::string(path); } + struct Info { static const char *name; static const char *file; Index: lldb/include/lldb/API/SBReproducer.h =================================================================== --- lldb/include/lldb/API/SBReproducer.h +++ lldb/include/lldb/API/SBReproducer.h @@ -26,6 +26,13 @@ static const char *GetPath(); static bool SetAutoGenerate(bool b); static bool Generate(); + + /// The working directory is set to the current working directory when the + /// reproducers are initialized. This method allows setting a different + /// working directory. This is used by the API test suite which temporarily + /// changes the directory to where the test lives. This is a NO-OP in every + /// mode but capture. + static void SetWorkingDirectory(const char *path); }; } // namespace lldb Index: lldb/bindings/interface/SBReproducer.i =================================================================== --- lldb/bindings/interface/SBReproducer.i +++ lldb/bindings/interface/SBReproducer.i @@ -13,5 +13,6 @@ static const char *Capture(const char *path); static const char *PassiveReplay(const char *path); static bool SetAutoGenerate(bool b); + static void SetWorkingDirectory(const char *path); }; }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits