[Lldb-commits] [lldb] [lldb][gdb-remote] Fix packet send loop to use loop index (PR #193694)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 23 02:21:35 PDT 2026


================
@@ -0,0 +1,58 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
+from lldbsuite.test import lldbutil
+
+
+class TestGDBRemotePacketSend(GDBRemoteTestBase):
+    class MyResponder(MockGDBServerResponder):
+        def __init__(self):
+            super().__init__()
+            self.custom_packets_received = []
+
+        def qfThreadInfo(self):
+            return "m1"
+
+        def qsThreadInfo(self):
+            return "l"
+
+        def qC(self):
+            return "QC1"
+
+        def haltReason(self):
+            return "T05thread:1;"
+
+        def other(self, packet):
+            if packet.startswith("qTestPacket"):
+                self.custom_packets_received.append(packet)
+                return "response-for-" + packet
+            return ""
+
+    def test_packet_send_multiple_arguments(self):
+        """Each packet argument should be forwarded individually."""
+        responder = self.MyResponder()
+        self.server.responder = responder
+
+        target = self.createTarget("a.yaml")
+        process = self.connect(target)
+        lldbutil.expect_state_changes(
+            self, self.dbg.GetListener(), process, [lldb.eStateStopped]
+        )
+
+        self.expect(
+            "process plugin packet send qTestPacketA qTestPacketB qTestPacketC",
----------------
DavidSpickett wrote:

I had a go at generating parts of this from the packet list:
```
>>> test_packets = ["qA", "qB", "qC"]
>>> f"process plugin packet send {' '.join(test_packets)}"
'process plugin packet send qA qB qC'
>>> list(chain(*[[f"packet: {p}", f"response: response-for-{p}"] for p in test_packets]))
['packet: qA', 'response: response-for-qA', 'packet: qB', 'response: response-for-qB', 'packet: qC', 'response: response-for-qC']
```
I woudn't bother generating the output lines because it is way harder to parse that code, but you could do this for the `packet send` itself, and for the assert of `custom_packets_received`.

https://github.com/llvm/llvm-project/pull/193694


More information about the lldb-commits mailing list