================
@@ -0,0 +1,68 @@
+"""
+Test that LLDB ignores notification packets (those beginning with '%')
+when waiting for a response to a '$' packet.
+
+OpenOCD is one debug server that uses notification packets to reset
+the connection timeout if a memory read takes too long. So that's what
+we test here, but it should apply to any exchange.
+"""
+
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
+
+
+class NotifyingServerResponder(MockGDBServerResponder):
+ def readMemory(self, addr, length):
+ return "01" * length
+
+
+class NotifyingServer(MockGDBServer):
+ def __init__(self, socket):
+ self._socket = socket
+ self.responder = NotifyingServerResponder()
+ self.sent_notification = False
+
+ def _sendPacket(self, packet: str, prefix="$"):
+ # In theory we could add notifies before all packets, but it always
+ # goes through the same code and just makes the test take longer.
+ if packet == "01010101":
+ # Send more than one to make sure we clear them all to find
+ # the real response.
+ super()._sendPacket("this_is_a_notification", prefix="%")
+ super()._sendPacket("this_is_a_2nd_notification", prefix="%")
+ self.sent_notification = True
+
+ super()._sendPacket(packet)
----------------
DavidSpickett wrote:
Send a notification after sending `packet` here. In theory it won't even be
read by the test but it would be embarrassing if it was in fact mishandled.
https://github.com/llvm/llvm-project/pull/204788
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits