diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2020-05-19 09:55:07 -0700 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2020-05-19 10:55:35 -0700 |
commit | 225f241c84469d7d29c9ef626558c302134c48ff (patch) | |
tree | 4c8a63f53717a9fc1dedb88c6d40afc52093140a /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | |
parent | 81a73fde5cea304d31294fd26c2f051f1685e97c (diff) | |
download | llvm-225f241c84469d7d29c9ef626558c302134c48ff.zip llvm-225f241c84469d7d29c9ef626558c302134c48ff.tar.gz llvm-225f241c84469d7d29c9ef626558c302134c48ff.tar.bz2 |
[lldb/Reproducers] Move connection logic into replay server (NFC)
Move the logic for connecting to the replay server into the replay
server itself, so it can be reused outside of ProcessGDBRemote.
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index dbad49d..58e9712 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -649,8 +649,8 @@ Status ProcessGDBRemote::DoConnectRemote(Stream *strm, if (error.Fail()) return error; - if (repro::Loader *loader = repro::Reproducer::Instance().GetLoader()) - error = ConnectToReplayServer(loader); + if (repro::Reproducer::Instance().IsReplaying()) + error = ConnectToReplayServer(); else error = ConnectToDebugserver(remote_url); @@ -3355,30 +3355,10 @@ Status ProcessGDBRemote::DoSignal(int signo) { return error; } -Status ProcessGDBRemote::ConnectToReplayServer(repro::Loader *loader) { - if (!loader) - return Status("No loader provided."); - - static std::unique_ptr<repro::MultiLoader<repro::GDBRemoteProvider>> - multi_loader = repro::MultiLoader<repro::GDBRemoteProvider>::Create( - repro::Reproducer::Instance().GetLoader()); - - if (!multi_loader) - return Status("No gdb remote provider found."); - - llvm::Optional<std::string> history_file = multi_loader->GetNextFile(); - if (!history_file) - return Status("No gdb remote packet log found."); - - // Load replay history. - if (auto error = - m_gdb_replay_server.LoadReplayHistory(FileSpec(*history_file))) - return Status("Unable to load replay history"); - - // Make a local connection. - if (auto error = GDBRemoteCommunication::ConnectLocally(m_gdb_comm, - m_gdb_replay_server)) - return Status("Unable to connect to replay server"); +Status ProcessGDBRemote::ConnectToReplayServer() { + Status status = m_gdb_replay_server.Connect(m_gdb_comm); + if (status.Fail()) + return status; // Enable replay mode. m_replay_mode = true; @@ -3403,8 +3383,8 @@ ProcessGDBRemote::EstablishConnectionIfNeeded(const ProcessInfo &process_info) { if (platform_sp && !platform_sp->IsHost()) return Status("Lost debug server connection"); - if (repro::Loader *loader = repro::Reproducer::Instance().GetLoader()) - return ConnectToReplayServer(loader); + if (repro::Reproducer::Instance().IsReplaying()) + return ConnectToReplayServer(); auto error = LaunchAndConnectToDebugserver(process_info); if (error.Fail()) { |