[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
This commit is contained in:
Jonas Devlieghere 2019-03-21 04:08:31 +00:00
parent 60212be619
commit a262531dd2
2 changed files with 16 additions and 1 deletions

View File

@ -9,7 +9,7 @@
# RUN: rm -rf %t.repro
# RUN: %clang %S/Inputs/simple.c -g -o %t.out
# RUN: %lldb -x -b -s %S/Inputs/GDBRemoteCapture.in --capture --capture-path %t.repro %t.out | FileCheck %s --check-prefix CHECK --check-prefix CAPTURE
# RUN: %lldb --replay %t.repro | FileCheck %s --check-prefix CHECK --check-prefix REPLAY
# RUN: env FOO=BAR %lldb --replay %t.repro | FileCheck %s --check-prefix CHECK --check-prefix REPLAY
# CHECK: Breakpoint 1
# CHECK: Process {{.*}} stopped

View File

@ -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;
}