|
57 | 57 | using namespace lldb;
|
58 | 58 | using namespace lldb_private;
|
59 | 59 |
|
60 |
| -/// Helper class for replaying commands through the reproducer. |
61 |
| -class CommandLoader { |
62 |
| -public: |
63 |
| - CommandLoader(std::vector<std::string> files) : m_files(files) {} |
64 |
| - |
65 |
| - static std::unique_ptr<CommandLoader> Create() { |
66 |
| - repro::Loader *loader = repro::Reproducer::Instance().GetLoader(); |
67 |
| - if (!loader) |
68 |
| - return {}; |
69 |
| - |
70 |
| - FileSpec file = loader->GetFile<repro::CommandProvider::Info>(); |
71 |
| - if (!file) |
72 |
| - return {}; |
73 |
| - |
74 |
| - auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath()); |
75 |
| - if (auto err = error_or_file.getError()) |
76 |
| - return {}; |
77 |
| - |
78 |
| - std::vector<std::string> files; |
79 |
| - llvm::yaml::Input yin((*error_or_file)->getBuffer()); |
80 |
| - yin >> files; |
81 |
| - |
82 |
| - if (auto err = yin.error()) |
83 |
| - return {}; |
84 |
| - |
85 |
| - for (auto &file : files) { |
86 |
| - FileSpec absolute_path = |
87 |
| - loader->GetRoot().CopyByAppendingPathComponent(file); |
88 |
| - file = absolute_path.GetPath(); |
89 |
| - } |
90 |
| - |
91 |
| - return std::make_unique<CommandLoader>(std::move(files)); |
92 |
| - } |
93 |
| - |
94 |
| - FILE *GetNextFile() { |
95 |
| - if (m_index >= m_files.size()) |
96 |
| - return nullptr; |
97 |
| - return FileSystem::Instance().Fopen(m_files[m_index++].c_str(), "r"); |
98 |
| - } |
99 |
| - |
100 |
| -private: |
101 |
| - std::vector<std::string> m_files; |
102 |
| - unsigned m_index = 0; |
103 |
| -}; |
104 |
| - |
105 | 60 | static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp,
|
106 | 61 | const FileSpec &spec,
|
107 | 62 | Status &error) {
|
@@ -344,9 +299,12 @@ void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) {
|
344 | 299 | if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator())
|
345 | 300 | recorder = g->GetOrCreate<repro::CommandProvider>().GetNewDataRecorder();
|
346 | 301 |
|
347 |
| - static std::unique_ptr<CommandLoader> loader = CommandLoader::Create(); |
348 |
| - if (loader) |
349 |
| - fh = loader->GetNextFile(); |
| 302 | + static std::unique_ptr<repro::CommandLoader> loader = |
| 303 | + repro::CommandLoader::Create(repro::Reproducer::Instance().GetLoader()); |
| 304 | + if (loader) { |
| 305 | + llvm::Optional<std::string> file = loader->GetNextFile(); |
| 306 | + fh = file ? FileSystem::Instance().Fopen(file->c_str(), "r") : nullptr; |
| 307 | + } |
350 | 308 |
|
351 | 309 | m_opaque_sp->SetInputFileHandle(fh, transfer_ownership, recorder);
|
352 | 310 | }
|
|
0 commit comments