Skip to content

Commit 6d8da22

Browse files
committed
[lldb] Add bidirectional packetLog to gdbclientutils.py
While debugging the tests for PR155000 I found it helpful to have both sides of the simulated gdb-rsp traffic rather than just the responses so I've added a packetLog to MockGDBServer. The existing response-only one in MockGDBServerResponder is used by tests so I chose not to change it
1 parent bd8a1e1 commit 6d8da22

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lldb/packages/Python/lldbsuite/test/gdbclientutils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import socket
77
import traceback
88
from lldbsuite.support import seven
9-
from typing import Optional
9+
from typing import Optional, Literal
1010

1111

1212
def checksum(message):
@@ -521,10 +521,12 @@ class MockGDBServer:
521521
_receivedData = None
522522
_receivedDataOffset = None
523523
_shouldSendAck = True
524+
packetLog: list[tuple[Literal["recv"] | Literal["send"], str | bytes]]
524525

525526
def __init__(self, socket):
526527
self._socket = socket
527528
self.responder = MockGDBServerResponder()
529+
self.packetLog = []
528530

529531
def start(self):
530532
# Start a thread that waits for a client connection.
@@ -651,11 +653,13 @@ def _parsePacket(self):
651653
# can start on the next packet the next time around
652654
self._receivedData = data[i:]
653655
self._receivedDataOffset = 0
656+
self.packetLog.append(("recv", packet))
654657
return packet
655658

656659
def _sendPacket(self, packet: str):
657660
assert self._socket is not None
658661
framed_packet = seven.bitcast_to_bytes(frame_packet(packet))
662+
self.packetLog.append(("send", framed_packet))
659663
self._socket.sendall(framed_packet)
660664

661665
def _handlePacket(self, packet):

0 commit comments

Comments
 (0)