Author: jdevlieghere Date: Wed Mar 20 18:57:33 2019 New Revision: 356638 URL: http://llvm.org/viewvc/llvm-project?rev=356638&view=rev Log: [Reproducers] Log inconsistencies during replay (NFC)
Make debugging of the GDB remote packet aspect of reproducers easier by logging both requests and replies. This enables some sanity checking during replay. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp?rev=356638&r1=356637&r2=356638&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp Wed Mar 20 18:57:33 2019 @@ -45,7 +45,7 @@ void GDBRemoteCommunicationHistory::AddP m_packets[idx].bytes_transmitted = bytes_transmitted; m_packets[idx].packet_idx = m_total_packet_count; m_packets[idx].tid = llvm::get_threadid(); - if (m_stream && type == ePacketTypeRecv) + if (m_stream) m_packets[idx].Serialize(*m_stream); } @@ -62,7 +62,7 @@ void GDBRemoteCommunicationHistory::AddP m_packets[idx].bytes_transmitted = bytes_transmitted; m_packets[idx].packet_idx = m_total_packet_count; m_packets[idx].tid = llvm::get_threadid(); - if (m_stream && type == ePacketTypeRecv) + if (m_stream) m_packets[idx].Serialize(*m_stream); } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp?rev=356638&r1=356637&r2=356638&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp Wed Mar 20 18:57:33 2019 @@ -30,6 +30,26 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::process_gdb_remote; +static bool unexpected(llvm::StringRef expected, llvm::StringRef actual) { + // The 'expected' string contains the raw data, including the leading $ and + // trailing checksum. The 'actual' string contains only the packet's content. + if (expected.contains(actual)) + return false; + if (expected == "+" || actual == "+") + return false; + // Contains a PID which might be different. + if (expected.contains("vAttach")) + return false; + // Contains a ascii-hex-path. + if (expected.contains("QSetSTD")) + return false; + // Contains environment values. + if (expected.contains("QEnvironment")) + return false; + + return true; +} + GDBRemoteCommunicationReplayServer::GDBRemoteCommunicationReplayServer() : GDBRemoteCommunication("gdb-remote.server", "gdb-remote.server.rx_packet"), @@ -87,15 +107,31 @@ GDBRemoteCommunicationReplayServer::GetP m_send_acks = false; } + Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); while (!m_packet_history.empty()) { // Pop last packet from the history. GDBRemoteCommunicationHistory::Entry entry = m_packet_history.back(); m_packet_history.pop_back(); - // We only care about what we received from the server. Skip everything - // the client sent. - if (entry.type != GDBRemoteCommunicationHistory::ePacketTypeRecv) + if (entry.type == GDBRemoteCommunicationHistory::ePacketTypeSend) { + if (unexpected(entry.packet.data, packet.GetStringRef())) { + LLDB_LOG(log, + "GDBRemoteCommunicationReplayServer expected packet: '{}'\n", + entry.packet.data); + LLDB_LOG(log, + "GDBRemoteCommunicationReplayServer actual packet: '{}'\n", + packet.GetStringRef()); + } continue; + } + + if (entry.type == GDBRemoteCommunicationHistory::ePacketTypeInvalid) { + LLDB_LOG( + log, + "GDBRemoteCommunicationReplayServer skipped invalid packet: '{}'\n", + packet.GetStringRef()); + continue; + } return SendRawPacketNoLock(entry.packet.data, true); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits