diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-03-12 17:10:28 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-03-12 17:10:28 +0000 |
commit | 5650eb5b005fbb987c515c8354eac85130b393a4 (patch) | |
tree | 07ca374b2e2d8c83299278a8ab5e70315402bfec /lldb | |
parent | 6c0bbfc0c94b24bfe52745323656e81beb8334e7 (diff) | |
download | bcm5719-llvm-5650eb5b005fbb987c515c8354eac85130b393a4.tar.gz bcm5719-llvm-5650eb5b005fbb987c515c8354eac85130b393a4.zip |
[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.
llvm-svn: 355940
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/include/lldb/Utility/Reproducer.h | 8 | ||||
-rw-r--r-- | lldb/source/Utility/Reproducer.cpp | 4 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lldb/include/lldb/Utility/Reproducer.h b/lldb/include/lldb/Utility/Reproducer.h index cf7887a2c76..4cad298f6d9 100644 --- a/lldb/include/lldb/Utility/Reproducer.h +++ b/lldb/include/lldb/Utility/Reproducer.h @@ -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 { diff --git a/lldb/source/Utility/Reproducer.cpp b/lldb/source/Utility/Reproducer.cpp index 3e2ffcda281..20d255e0019 100644 --- a/lldb/source/Utility/Reproducer.cpp +++ b/lldb/source/Utility/Reproducer.cpp @@ -247,8 +247,10 @@ DataRecorder *CommandProvider::GetNewDataRecorder() { 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; |