diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-11-27 22:11:02 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-11-27 22:11:02 +0000 |
commit | 68ed93d2528f28e04c8b96dde59225d4cc87ff3a (patch) | |
tree | 499ebb8bf3f761095801a427d2572ae8b87b73a3 /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | |
parent | a116602475314e0b3e7e4e28bd7057df1937b761 (diff) | |
download | bcm5719-llvm-68ed93d2528f28e04c8b96dde59225d4cc87ff3a.tar.gz bcm5719-llvm-68ed93d2528f28e04c8b96dde59225d4cc87ff3a.zip |
[Reproducers] Improve reproducer API and add unit tests.
When I landed the initial reproducer framework I knew there were some
things that needed improvement. Rather than bundling it with a patch
that adds more functionality I split it off into this patch. I also
think the API is stable enough to add unit testing, which is included in
this patch as well.
Other improvements include:
- Refactor how we initialize the loader and generator.
- Improve naming consistency: capture and replay seems the least ambiguous.
- Index providers by name and make sure there's only one of each.
- Add convenience methods for creating and accessing providers.
Differential revision: https://reviews.llvm.org/D54616
llvm-svn: 347716
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index e1be28e2ca8..7225a39d0e3 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -157,7 +157,8 @@ static const ProcessKDPPropertiesSP &GetGlobalPluginProperties() { return g_settings_sp; } -class ProcessGDBRemoteProvider : public repro::Provider { +class ProcessGDBRemoteProvider + : public repro::Provider<ProcessGDBRemoteProvider> { public: ProcessGDBRemoteProvider(const FileSpec &directory) : Provider(directory) { m_info.name = "gdb-remote"; @@ -166,7 +167,7 @@ public: raw_ostream *GetHistoryStream() { FileSpec history_file = - GetDirectory().CopyByAppendingPathComponent("gdb-remote.yaml"); + GetRoot().CopyByAppendingPathComponent("gdb-remote.yaml"); std::error_code EC; m_stream_up = llvm::make_unique<raw_fd_ostream>(history_file.GetPath(), EC, @@ -182,11 +183,15 @@ public: void Discard() override { m_callback(); } + static char ID; + private: std::function<void()> m_callback; std::unique_ptr<raw_fd_ostream> m_stream_up; }; +char ProcessGDBRemoteProvider::ID = 0; + } // namespace // TODO Randomly assigning a port is unsafe. We should get an unused @@ -297,10 +302,9 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, m_async_broadcaster.SetEventName(eBroadcastBitAsyncThreadDidExit, "async thread did exit"); - repro::Generator *generator = repro::Reproducer::Instance().GetGenerator(); - if (generator) { + if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) { ProcessGDBRemoteProvider &provider = - generator->CreateProvider<ProcessGDBRemoteProvider>(); + g->GetOrCreate<ProcessGDBRemoteProvider>(); // Set the history stream to the stream owned by the provider. m_gdb_comm.SetHistoryStream(provider.GetHistoryStream()); // Make sure to clear the stream again when we're finished. @@ -3436,8 +3440,8 @@ Status ProcessGDBRemote::ConnectToReplayServer(repro::Loader *loader) { return Status("Provider for gdb-remote contains no files."); // Construct replay history path. - FileSpec history_file(loader->GetDirectory()); - history_file.AppendPathComponent(provider_info->files.front()); + FileSpec history_file = loader->GetRoot().CopyByAppendingPathComponent( + provider_info->files.front()); // Enable replay mode. m_replay_mode = true; |