From a262531dd2ed2c5591c72adf4949a0cdc65ef061 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 21 Mar 2019 04:08:31 +0000 Subject: [Reproducers] Properly handle QEnvironment packets On Linux, a QEnvironment packet is sent for every environment variable. This breaks replay when the number of environment variables is different then during capture. The solution is to always reply with OK. llvm-svn: 356643 --- .../gdb-remote/GDBRemoteCommunicationReplayServer.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp') diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp index 2aa121b11e8..1fdb688b0ca 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp @@ -107,6 +107,13 @@ GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse( m_send_acks = false; } + // A QEnvironment packet is sent for every environment variable. If the + // number of environment variables is different during replay, the replies + // become out of sync. + if (packet.GetStringRef().find("QEnvironment") == 0) { + return SendRawPacketNoLock("$OK#9a", true); + } + Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); while (!m_packet_history.empty()) { // Pop last packet from the history. @@ -122,6 +129,14 @@ GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse( "GDBRemoteCommunicationReplayServer actual packet: '{}'\n", packet.GetStringRef()); } + + // Ignore QEnvironment packets as they're handled earlier. + if (entry.packet.data.find("QEnvironment") == 1) { + assert(m_packet_history.back().type == + GDBRemoteCommunicationHistory::ePacketTypeRecv); + m_packet_history.pop_back(); + } + continue; } -- cgit v1.2.3