Index: include/lldb/API/SBHostOS.h =================================================================== --- include/lldb/API/SBHostOS.h +++ include/lldb/API/SBHostOS.h @@ -25,6 +25,8 @@ static lldb::SBFileSpec GetUserHomeDirectory(); + static bool SetCurrentWorkingDirectory(const char *cwd); + static void ThreadCreated(const char *name); static lldb::thread_t ThreadCreate(const char *name, Index: include/lldb/Host/FileSystem.h =================================================================== --- include/lldb/Host/FileSystem.h +++ include/lldb/Host/FileSystem.h @@ -130,6 +130,11 @@ void Resolve(FileSpec &file_spec); /// @} + /// Set current working directory. + /// @{ + bool SetCurrentWorkingDirectory(const llvm::Twine &cwd); + /// @} + //// Create memory buffer from path. /// @{ std::shared_ptr CreateDataBuffer(const llvm::Twine &path, Index: packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- packages/Python/lldbsuite/test/lldbtest.py +++ packages/Python/lldbsuite/test/lldbtest.py @@ -552,6 +552,9 @@ print("Change dir to:", full_dir, file=sys.stderr) os.chdir(full_dir) + if not lldb.SBHostOS.SetCurrentWorkingDirectory(full_dir): + raise Exception("Failed to re-write cached cwd value.") + # Set platform context. cls.platformContext = lldbplatformutil.createPlatformContext() Index: scripts/interface/SBHostOS.i =================================================================== --- scripts/interface/SBHostOS.i +++ scripts/interface/SBHostOS.i @@ -24,6 +24,9 @@ static lldb::SBFileSpec GetUserHomeDirectory (); + + static bool + SetCurrentWorkingDirectory(const char *cwd); static void ThreadCreated (const char *name); Index: source/API/SBHostOS.cpp =================================================================== --- source/API/SBHostOS.cpp +++ source/API/SBHostOS.cpp @@ -94,6 +94,10 @@ return sb_fspec; } +bool SBHostOS::SetCurrentWorkingDirectory(const char *cwd) { + return cwd ? FileSystem::Instance().SetCurrentWorkingDirectory(cwd) : false; +} + lldb::thread_t SBHostOS::ThreadCreate(const char *name, lldb::thread_func_t thread_function, void *thread_arg, SBError *error_ptr) { Index: source/Host/common/FileSystem.cpp =================================================================== --- source/Host/common/FileSystem.cpp +++ source/Host/common/FileSystem.cpp @@ -247,6 +247,11 @@ file_spec.SetIsResolved(true); } +bool FileSystem::SetCurrentWorkingDirectory(const llvm::Twine &cwd) { + std::error_code error = m_fs->setCurrentWorkingDirectory(cwd); + return !error; +} + std::shared_ptr FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size, uint64_t offset) {