================
@@ -0,0 +1,202 @@
+"""
+Test lldb-dap "port" configuration to "attach" request
+"""
+
+
+import dap_server
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbplatformutil
+import lldbdap_testcase
+import os
+import shutil
+import subprocess
+import tempfile
+import threading
+import sys
+import socket
+import select
+
+
+# A class representing a pipe for communicating with debug server.
+# This class includes menthods to open the pipe and read the port number from 
it.
+class Pipe(object):
+    def __init__(self, prefix):
+        self.name = os.path.join(prefix, "stub_port_number")
+        os.mkfifo(self.name)
+        self._fd = os.open(self.name, os.O_RDONLY | os.O_NONBLOCK)
+
+    def finish_connection(self, timeout):
+        pass
+
+    def read(self, size, timeout):
+        (readers, _, _) = select.select([self._fd], [], [], timeout)
+        if self._fd not in readers:
+            raise TimeoutError
+        return os.read(self._fd, size)
+
+    def close(self):
+        os.close(self._fd)
----------------
santhoshe447 wrote:

I agree but the specific class is defined based on the host platform. If the 
host platform is windows, it uses the same Pipe class with different APIs, and 
for other platforms, it behaves differently.
Therefore, I did not place Pipe class in a common location.


Ref: lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py

https://github.com/llvm/llvm-project/pull/91570
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to