Author: jdevlieghere Date: Mon Sep 16 13:02:57 2019 New Revision: 372028 URL: http://llvm.org/viewvc/llvm-project?rev=372028&view=rev Log: [NFC] Move dumping into GDBRemotePacket
This moves the dumping logic from the GDBRemoteCommunicationHistory class into the GDBRemotePacket so that it can be reused from the reproducer command object. Modified: lldb/trunk/include/lldb/Utility/GDBRemote.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp lldb/trunk/source/Utility/GDBRemote.cpp Modified: lldb/trunk/include/lldb/Utility/GDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/GDBRemote.h?rev=372028&r1=372027&r2=372028&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/GDBRemote.h (original) +++ lldb/trunk/include/lldb/Utility/GDBRemote.h Mon Sep 16 13:02:57 2019 @@ -70,12 +70,16 @@ struct GDBRemotePacket { }; void Serialize(llvm::raw_ostream &strm) const; + void Dump(Stream &strm) const; BinaryData packet; Type type; uint32_t bytes_transmitted; uint32_t packet_idx; lldb::tid_t tid; + +private: + llvm::StringRef GetTypeStr() const; }; } // namespace lldb_private 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=372028&r1=372027&r2=372028&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp Mon Sep 16 13:02:57 2019 @@ -72,11 +72,8 @@ void GDBRemoteCommunicationHistory::Dump if (entry.type == GDBRemotePacket::ePacketTypeInvalid || entry.packet.data.empty()) break; - strm.Printf("history[%u] tid=0x%4.4" PRIx64 " <%4u> %s packet: %s\n", - entry.packet_idx, entry.tid, entry.bytes_transmitted, - (entry.type == GDBRemotePacket::ePacketTypeSend) ? "send" - : "read", - entry.packet.data.c_str()); + strm.Printf("history[%u] ", entry.packet_idx); + entry.Dump(strm); } } Modified: lldb/trunk/source/Utility/GDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/GDBRemote.cpp?rev=372028&r1=372027&r2=372028&view=diff ============================================================================== --- lldb/trunk/source/Utility/GDBRemote.cpp (original) +++ lldb/trunk/source/Utility/GDBRemote.cpp Mon Sep 16 13:02:57 2019 @@ -51,6 +51,23 @@ void GDBRemotePacket::Serialize(raw_ostr strm.flush(); } +llvm::StringRef GDBRemotePacket::GetTypeStr() const { + switch (type) { + case GDBRemotePacket::ePacketTypeSend: + return "send"; + case GDBRemotePacket::ePacketTypeRecv: + return "read"; + case GDBRemotePacket::ePacketTypeInvalid: + return "invalid"; + } + llvm_unreachable("All enum cases should be handled"); +} + +void GDBRemotePacket::Dump(Stream &strm) const { + strm.Printf("tid=0x%4.4" PRIx64 " <%4u> %s packet: %s\n", tid, + bytes_transmitted, GetTypeStr().data(), packet.data.c_str()); +} + void yaml::ScalarEnumerationTraits<GDBRemotePacket::Type>::enumeration( IO &io, GDBRemotePacket::Type &value) { io.enumCase(value, "Invalid", GDBRemotePacket::ePacketTypeInvalid); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits