Author: jdevlieghere Date: Tue Mar 12 10:10:28 2019 New Revision: 355940 URL: http://llvm.org/viewvc/llvm-project?rev=355940&view=rev Log: [Reproducers] Stop recording instead of deallocating
The command interpreter holds a pointer to a DataRecorder. After generating the reproducer, we deallocated all the DataRecorders, causing the command interpreter to hold a non-null reference to an invalid object. This patch changes the behavior of the command provider to stop the DataRecorders when a reproducer is generated, rather than deallocating them. Modified: lldb/trunk/include/lldb/Utility/Reproducer.h lldb/trunk/source/Utility/Reproducer.cpp Modified: lldb/trunk/include/lldb/Utility/Reproducer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Reproducer.h?rev=355940&r1=355939&r2=355940&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/Reproducer.h (original) +++ lldb/trunk/include/lldb/Utility/Reproducer.h Tue Mar 12 10:10:28 2019 @@ -115,7 +115,7 @@ class DataRecorder { public: DataRecorder(FileSpec filename, std::error_code &ec) : m_filename(std::move(filename)), - m_os(m_filename.GetPath(), ec, llvm::sys::fs::F_Text) {} + m_os(m_filename.GetPath(), ec, llvm::sys::fs::F_Text), m_record(true) {} static llvm::Expected<std::unique_ptr<DataRecorder>> Create(FileSpec filename); @@ -128,9 +128,15 @@ public: const FileSpec &GetFilename() { return m_filename; } + void Stop() { + assert(m_record); + m_record = false; + } + private: FileSpec m_filename; llvm::raw_fd_ostream m_os; + bool m_record; }; struct CommandInfo { Modified: lldb/trunk/source/Utility/Reproducer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Reproducer.cpp?rev=355940&r1=355939&r2=355940&view=diff ============================================================================== --- lldb/trunk/source/Utility/Reproducer.cpp (original) +++ lldb/trunk/source/Utility/Reproducer.cpp Tue Mar 12 10:10:28 2019 @@ -247,8 +247,10 @@ DataRecorder *CommandProvider::GetNewDat void CommandProvider::Keep() { std::vector<std::string> files; - for (auto &recorder : m_data_recorders) + for (auto &recorder : m_data_recorders) { + recorder->Stop(); files.push_back(recorder->GetFilename().GetPath()); + } FileSpec file = GetRoot().CopyByAppendingPathComponent(info::file); std::error_code ec; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits