This revision was automatically updated to reflect the committed changes.
Closed by commit rG1f80e51546bf: [lldb/Reproducers] Collect files imported by 
command script import (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76626/new/

https://reviews.llvm.org/D76626

Files:
  lldb/include/lldb/Host/FileSystem.h
  lldb/source/Host/common/FileSystem.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/test/Shell/Reproducer/Inputs/foo.lua
  lldb/test/Shell/Reproducer/Inputs/foo.py
  lldb/test/Shell/Reproducer/TestLuaImport.test
  lldb/test/Shell/Reproducer/TestPythonImport.test

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
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/Inputs/foo.py
===================================================================
--- /dev/null
+++ lldb/test/Shell/Reproducer/Inputs/foo.py
@@ -0,0 +1 @@
+print('95126')
Index: lldb/test/Shell/Reproducer/Inputs/foo.lua
===================================================================
--- /dev/null
+++ lldb/test/Shell/Reproducer/Inputs/foo.lua
@@ -0,0 +1 @@
+print('95126')
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/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/Host/common/FileSystem.cpp
===================================================================
--- lldb/source/Host/common/FileSystem.cpp
+++ lldb/source/Host/common/FileSystem.cpp
@@ -279,7 +279,7 @@
 std::shared_ptr<DataBufferLLVM>
 FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size,
                              uint64_t offset) {
-  AddFile(path);
+  Collect(path);
 
   const bool is_volatile = !IsLocal(path);
   const ErrorOr<std::string> external_path = GetExternalPath(path);
@@ -417,7 +417,7 @@
 Expected<FileUP> 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/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<FileSystem> &InstanceImpl();
   llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs;
   std::shared_ptr<llvm::FileCollector> m_collector;
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to