diff options
author | Greg Clayton <gclayton@apple.com> | 2017-04-17 16:20:22 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2017-04-17 16:20:22 +0000 |
commit | 84577092ba220afd173dfccf08093bc46f0ebe33 (patch) | |
tree | 4a46634ae1e62fcbf88441dde86d41aeafd324ca /lldb/source/Plugins/Process/gdb-remote | |
parent | b5d1ea44af9717584fbbdf4f4a687dea57b9b461 (diff) | |
download | bcm5719-llvm-84577092ba220afd173dfccf08093bc46f0ebe33.tar.gz bcm5719-llvm-84577092ba220afd173dfccf08093bc46f0ebe33.zip |
Don't ever reduce the timeout of a packet, only increase it.
Differential Revision: https://reviews.llvm.org/D32087
llvm-svn: 300455
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | 14 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h | 4 |
2 files changed, 15 insertions, 3 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 7ef253decad..d527b4daaab 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -1310,12 +1310,20 @@ void GDBRemoteCommunication::DumpHistory(Stream &strm) { m_history.Dump(strm); } GDBRemoteCommunication::ScopedTimeout::ScopedTimeout( GDBRemoteCommunication &gdb_comm, std::chrono::seconds timeout) - : m_gdb_comm(gdb_comm) { - m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout); + : m_gdb_comm(gdb_comm), m_timeout_modified(false) { + auto curr_timeout = gdb_comm.GetPacketTimeout(); + // Only update the timeout if the timeout is greater than the current + // timeout. If the current timeout is larger, then just use that. + if (curr_timeout < timeout) { + m_timeout_modified = true; + m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout); + } } GDBRemoteCommunication::ScopedTimeout::~ScopedTimeout() { - m_gdb_comm.SetPacketTimeout(m_saved_timeout); + // Only restore the timeout if we set it in the constructor. + if (m_timeout_modified) + m_gdb_comm.SetPacketTimeout(m_saved_timeout); } // This function is called via the Communications class read thread when bytes diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h index 1f3fa17cfc2..b49e05e22d9 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h @@ -89,6 +89,10 @@ public: private: GDBRemoteCommunication &m_gdb_comm; std::chrono::seconds m_saved_timeout; + // Don't ever reduce the timeout for a packet, only increase it. If the + // requested timeout if less than the current timeout, we don't set it + // and won't need to restore it. + bool m_timeout_modified; }; GDBRemoteCommunication(const char *comm_name, const char *listener_name); |