Skip to content

Commit 0cfa969

Browse files
committed
[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. llvm-svn: 372028 (cherry picked from commit 4e053ff)
1 parent 423f3ba commit 0cfa969

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

lldb/include/lldb/Utility/GDBRemote.h

+4
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,16 @@ struct GDBRemotePacket {
7070
};
7171

7272
void Serialize(llvm::raw_ostream &strm) const;
73+
void Dump(Stream &strm) const;
7374

7475
BinaryData packet;
7576
Type type;
7677
uint32_t bytes_transmitted;
7778
uint32_t packet_idx;
7879
lldb::tid_t tid;
80+
81+
private:
82+
llvm::StringRef GetTypeStr() const;
7983
};
8084

8185
} // namespace lldb_private

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,8 @@ void GDBRemoteCommunicationHistory::Dump(Stream &strm) const {
7272
if (entry.type == GDBRemotePacket::ePacketTypeInvalid ||
7373
entry.packet.data.empty())
7474
break;
75-
strm.Printf("history[%u] tid=0x%4.4" PRIx64 " <%4u> %s packet: %s\n",
76-
entry.packet_idx, entry.tid, entry.bytes_transmitted,
77-
(entry.type == GDBRemotePacket::ePacketTypeSend) ? "send"
78-
: "read",
79-
entry.packet.data.c_str());
75+
strm.Printf("history[%u] ", entry.packet_idx);
76+
entry.Dump(strm);
8077
}
8178
}
8279

lldb/source/Utility/GDBRemote.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ void GDBRemotePacket::Serialize(raw_ostream &strm) const {
5151
strm.flush();
5252
}
5353

54+
llvm::StringRef GDBRemotePacket::GetTypeStr() const {
55+
switch (type) {
56+
case GDBRemotePacket::ePacketTypeSend:
57+
return "send";
58+
case GDBRemotePacket::ePacketTypeRecv:
59+
return "read";
60+
case GDBRemotePacket::ePacketTypeInvalid:
61+
return "invalid";
62+
}
63+
llvm_unreachable("All enum cases should be handled");
64+
}
65+
66+
void GDBRemotePacket::Dump(Stream &strm) const {
67+
strm.Printf("tid=0x%4.4" PRIx64 " <%4u> %s packet: %s\n", tid,
68+
bytes_transmitted, GetTypeStr().data(), packet.data.c_str());
69+
}
70+
5471
void yaml::ScalarEnumerationTraits<GDBRemotePacket::Type>::enumeration(
5572
IO &io, GDBRemotePacket::Type &value) {
5673
io.enumCase(value, "Invalid", GDBRemotePacket::ePacketTypeInvalid);

0 commit comments

Comments
 (0)