Index: lldb/include/lldb/Host/FileSystem.h =================================================================== --- lldb/include/lldb/Host/FileSystem.h +++ lldb/include/lldb/Host/FileSystem.h @@ -186,8 +186,10 @@ return m_fs; } + void Collect(const FileSpec &file_spec); + void Collect(const llvm::Twine &file); + private: - void AddFile(const llvm::Twine &file); static llvm::Optional &InstanceImpl(); llvm::IntrusiveRefCntPtr m_fs; std::shared_ptr m_collector; Index: lldb/source/Host/common/FileSystem.cpp =================================================================== --- lldb/source/Host/common/FileSystem.cpp +++ lldb/source/Host/common/FileSystem.cpp @@ -279,7 +279,7 @@ std::shared_ptr FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size, uint64_t offset) { - AddFile(path); + Collect(path); const bool is_volatile = !IsLocal(path); const ErrorOr external_path = GetExternalPath(path); @@ -417,7 +417,7 @@ Expected FileSystem::Open(const FileSpec &file_spec, File::OpenOptions options, uint32_t permissions, bool should_close_fd) { - AddFile(file_spec.GetPath()); + Collect(file_spec.GetPath()); const int open_flags = GetOpenFlags(options); const mode_t open_mode = @@ -465,7 +465,11 @@ return GetExternalPath(file_spec.GetPath()); } -void FileSystem::AddFile(const llvm::Twine &file) { +void FileSystem::Collect(const FileSpec &file_spec) { + Collect(file_spec.GetPath()); +} + +void FileSystem::Collect(const llvm::Twine &file) { if (m_collector && !llvm::sys::fs::is_directory(file)) { m_collector->addFile(file); } Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp +++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp @@ -89,6 +89,7 @@ const char *filename, bool init_session, lldb_private::Status &error, StructuredData::ObjectSP *module_sp) { + FileSystem::Instance().Collect(filename); if (llvm::Error e = m_lua->LoadModule(filename)) { error.SetErrorStringWithFormatv("lua failed to import '{0}': {1}\n", filename, llvm::toString(std::move(e))); Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -2772,6 +2772,7 @@ { FileSpec target_file(pathname); FileSystem::Instance().Resolve(target_file); + FileSystem::Instance().Collect(target_file); std::string basename(target_file.GetFilename().GetCString()); StreamString command_stream; Index: lldb/test/Shell/Reproducer/Inputs/foo.lua =================================================================== --- /dev/null +++ lldb/test/Shell/Reproducer/Inputs/foo.lua @@ -0,0 +1 @@ +print('95126') Index: lldb/test/Shell/Reproducer/Inputs/foo.py =================================================================== --- /dev/null +++ lldb/test/Shell/Reproducer/Inputs/foo.py @@ -0,0 +1 @@ +print('95126') Index: lldb/test/Shell/Reproducer/TestLuaImport.test =================================================================== --- /dev/null +++ lldb/test/Shell/Reproducer/TestLuaImport.test @@ -0,0 +1,11 @@ +# REQUIRES: lua +# UNSUPPORTED: system-windows +# Ensure that the reproducers know about imported Lua modules. + +# RUN: rm -rf %t.repro +# RUN: %lldb -x -b --script-language lua --capture --capture-path %t.repro -o 'command script import %S/Inputs/foo.lua' -o 'reproducer generate' | FileCheck %s --check-prefix CAPTURE + +# CAPTURE: 95126 + +# RUN: %lldb -b -o 'reproducer dump -p files -f %t.repro' | FileCheck %s --check-prefix FILES +# FILES: foo.lua Index: lldb/test/Shell/Reproducer/TestPythonImport.test =================================================================== --- /dev/null +++ lldb/test/Shell/Reproducer/TestPythonImport.test @@ -0,0 +1,11 @@ +# REQUIRES: python +# UNSUPPORTED: system-windows +# Ensure that the reproducers know about imported Python modules. + +# RUN: rm -rf %t.repro +# RUN: %lldb -x -b --capture --capture-path %t.repro -o 'command script import %S/Inputs/foo.py' -o 'reproducer generate' | FileCheck %s --check-prefix CAPTURE + +# CAPTURE: 95126 + +# RUN: %lldb -b -o 'reproducer dump -p files -f %t.repro' | FileCheck %s --check-prefix FILES +# FILES: foo.py