forked from OSchip/llvm-project
[lldb/Reproducers] Collect files imported by command script import
Files imported by the script interpreter aren't opened by LLDB so they don't end up in the reproducer. The solution is to explicitly add them to the FileCollector. Differential revision: https://reviews.llvm.org/D76626
This commit is contained in:
parent
f8c79b94af
commit
1f80e51546
|
@ -186,8 +186,10 @@ public:
|
|||
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;
|
||||
|
|
|
@ -279,7 +279,7 @@ void FileSystem::Resolve(FileSpec &file_spec) {
|
|||
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 @@ static mode_t GetOpenMode(uint32_t permissions) {
|
|||
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 @@ ErrorOr<std::string> FileSystem::GetExternalPath(const FileSpec &file_spec) {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ bool ScriptInterpreterLua::LoadScriptingModule(
|
|||
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)));
|
||||
|
|
|
@ -2772,6 +2772,7 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule(
|
|||
{
|
||||
FileSpec target_file(pathname);
|
||||
FileSystem::Instance().Resolve(target_file);
|
||||
FileSystem::Instance().Collect(target_file);
|
||||
std::string basename(target_file.GetFilename().GetCString());
|
||||
|
||||
StreamString command_stream;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
print('95126')
|
|
@ -0,0 +1 @@
|
|||
print('95126')
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue