llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Georgiy Samoylov (sga-sc) <details> <summary>Changes</summary> During LLDB testing on slow machines with the remote-linux platform all tests from llgs category fail with python exception `BrokenPipeError`. The main reason of these failures is slow start of lldb-server in gdbserver mode. Due to this desired gdbserver socket does not have time to open by the time the Python script tries to establish a connection. List of failed tests: ``` TestAppleSimulatorOSType.py TestGdbRemoteAttach.py TestGdbRemoteAuxvSupport.py TestGdbRemoteCompletion.py TestGdbRemoteExitCode.py TestGdbRemoteExpeditedRegisters.py TestGdbRemoteHostInfo.py TestGdbRemoteKill.py TestGdbRemoteLaunch.py TestGdbRemoteModuleInfo.py TestGdbRemotePlatformFile.py TestGdbRemoteProcessInfo.py TestGdbRemoteRegisterState.py TestGdbRemoteSaveCore.py TestGdbRemoteSingleStep.py TestGdbRemoteThreadsInStopReply.py TestGdbRemote_qThreadStopInfo.py TestGdbRemote_vCont.py TestLldbGdbServer.py TestNonStop.py TestPtyServer.py TestGdbRemoteAttachWait.py TestGdbRemoteConnection.py TestStubSetSID.py TestGdbRemoteAbort.py TestGdbRemoteSegFault.py TestGdbRemoteLibrariesSvr4Support.py TestGdbRemoteMemoryAllocation.py TestGdbRemoteMemoryTagging.py TestGdbRemoteGPacket.py TestGdbRemoteTargetXmlPacket.py TestGdbRemote_QPassSignals.py TestGdbRemoteThreadName.py TestPartialResume.py TestSignal.py ``` This patch implements an additional check for the opened socket on lldb-server side and fixes this error. --- Full diff: https://github.com/llvm/llvm-project/pull/127100.diff 1 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py (+30-12) ``````````diff diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index cbe430c92fa7f..8ee41563da59d 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -343,6 +343,22 @@ def get_target_byte_order(self): target = self.dbg.CreateTarget(inferior_exe_path) return target.GetByteOrder() + def is_port_opened(self): + connect_port = self.port + + err, retcode, cmd_output = self.run_platform_command(f"netstat -ltn | grep {connect_port} | grep LISTEN") + + self.assertTrue( + err.Success(), + "Failed to get opened tcp sockets: %s, retcode: %d" + % (err.GetCString(), retcode), + ) + + if retcode == 0: + return True + else: + return False + def launch_debug_monitor(self, attach_pid=None, logfile=None): if self.reverse_connect: family, type, proto, _, addr = socket.getaddrinfo( @@ -397,21 +413,23 @@ def connect_to_debug_monitor(self, attach_pid=None): # Schedule debug monitor to be shut down during teardown. logger = self.logger - connect_attemps = 0 + connect_attempts = 0 MAX_CONNECT_ATTEMPTS = 10 - while connect_attemps < MAX_CONNECT_ATTEMPTS: - # Create a socket to talk to the server - try: - logger.info("Connect attempt %d", connect_attemps + 1) - self.sock = self.create_socket() - self._server = Server(self.sock, server) - return server - except _ConnectionRefused as serr: - # Ignore, and try again. - pass + while connect_attempts < MAX_CONNECT_ATTEMPTS: + if self.is_port_opened(): + # Create a socket to talk to the server + try: + logger.info("Connect attempt %d", connect_attempts + 1) + self.sock = self.create_socket() + self._server = Server(self.sock, server) + return server + except _ConnectionRefused as serr: + # Ignore, and try again. + pass + time.sleep(0.5) - connect_attemps += 1 + connect_attempts += 1 # We should close the server here to be safe. server.terminate() `````````` </details> https://github.com/llvm/llvm-project/pull/127100 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits