Skip to content

Commit d27b2b0

Browse files
sga-scjoaosaffran
authored andcommitted
[lldb] Fix broken pipe error (llvm#127100)
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.
1 parent 71cc52f commit d27b2b0

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,11 @@ def remove_port_forward():
249249

250250
def _verify_socket(self, sock):
251251
# Normally, when the remote stub is not ready, we will get ECONNREFUSED during the
252-
# connect() attempt. However, due to the way how ADB forwarding works, on android targets
252+
# connect() attempt. However, due to the way how port forwarding can work, on some targets
253253
# the connect() will always be successful, but the connection will be immediately dropped
254-
# if ADB could not connect on the remote side. This function tries to detect this
254+
# if we could not connect on the remote side. This function tries to detect this
255255
# situation, and report it as "connection refused" so that the upper layers attempt the
256256
# connection again.
257-
triple = self.dbg.GetSelectedPlatform().GetTriple()
258-
if not re.match(".*-.*-.*-android", triple):
259-
return # Not android.
260257
can_read, _, _ = select.select([sock], [], [], 0.1)
261258
if sock not in can_read:
262259
return # Data is not available, but the connection is alive.
@@ -397,21 +394,21 @@ def connect_to_debug_monitor(self, attach_pid=None):
397394
# Schedule debug monitor to be shut down during teardown.
398395
logger = self.logger
399396

400-
connect_attemps = 0
397+
connect_attempts = 0
401398
MAX_CONNECT_ATTEMPTS = 10
402399

403-
while connect_attemps < MAX_CONNECT_ATTEMPTS:
400+
while connect_attempts < MAX_CONNECT_ATTEMPTS:
404401
# Create a socket to talk to the server
405402
try:
406-
logger.info("Connect attempt %d", connect_attemps + 1)
403+
logger.info("Connect attempt %d", connect_attempts + 1)
407404
self.sock = self.create_socket()
408405
self._server = Server(self.sock, server)
409406
return server
410407
except _ConnectionRefused as serr:
411408
# Ignore, and try again.
412409
pass
413410
time.sleep(0.5)
414-
connect_attemps += 1
411+
connect_attempts += 1
415412

416413
# We should close the server here to be safe.
417414
server.terminate()

0 commit comments

Comments
 (0)