[Lldb-commits] [lldb] [lldb] Fix broken pipe error (PR #127100)

2025-02-14 Thread Georgiy Samoylov via lldb-commits


@@ -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()

sga-sc wrote:

Python somehow manages to create a socket when the server-side port is not yet 
open. Because of this, the first time we try to read data from the socket the 
code crashes with an exception:
```
4: test_qHostInfo_returns_at_least_one_key_val_pair_llgs 
(TestGdbRemoteHostInfo.TestGdbRemoteHostInfo.test_qHostInfo_returns_at_least_one_key_val_pair_llgs)
 ... ERROR
FAIL: LLDB (/home/jorik/work/llvm-project/build/Release/bin/clang-rv64gc) :: 
test_qHostInfo_returns_at_least_one_key_val_pair_llgs 
(TestGdbRemoteHostInfo.TestGdbRemoteHostInfo.test_qHostInfo_returns_at_least_one_key_val_pair_llgs)
2025-02-14 12:04:31,718 WARNING  failed to send kill packet to debug monitor: 
; ignoring

==
ERROR: test_qHostInfo_returns_at_least_one_key_val_pair_llgs 
(TestGdbRemoteHostInfo.TestGdbRemoteHostInfo.test_qHostInfo_returns_at_least_one_key_val_pair_llgs)
--
Traceback (most recent call last):
  File 
"/home/jorik/work/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py",
 line 48, in test_method
return attrvalue(self)
   ^^^
  File 
"/home/jorik/work/llvm-project/lldb/test/API/tools/lldb-server/TestGdbRemoteHostInfo.py",
 line 122, in test_qHostInfo_returns_at_least_one_key_val_pair
self.get_qHostInfo_response()
  File 
"/home/jorik/work/llvm-project/lldb/test/API/tools/lldb-server/TestGdbRemoteHostInfo.py",
 line 90, in get_qHostInfo_response
self.do_handshake()
  File 
"/home/jorik/work/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py",
 line 546, in do_handshake
self.assertEqual(server.get_normal_packet(), b"+")
 ^^
  File 
"/home/jorik/work/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py",
 line 943, in get_normal_packet
frame = self.get_raw_normal_packet()

  File 
"/home/jorik/work/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py",
 line 932, in get_raw_normal_packet
return self._read(self._normal_queue)
   ^^
  File 
"/home/jorik/work/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py",
 line 885, in _read
new_bytes = self._sock.recv(4096)
^
ConnectionResetError: [Errno 104] Connection reset by peer
```

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


[Lldb-commits] [lldb] [lldb] Adapt llgs tests for RISC-V (PR #130034)

2025-03-15 Thread Georgiy Samoylov via lldb-commits

sga-sc wrote:

Could you merge it, please?

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


[Lldb-commits] [lldb] [lldb] Fix TestGdbRemoteForkNonStop.py test (PR #131293)

2025-03-19 Thread Georgiy Samoylov via lldb-commits

https://github.com/sga-sc updated 
https://github.com/llvm/llvm-project/pull/131293

>From cb1c55bd6015520a1b0834546d083f22823d1d2e Mon Sep 17 00:00:00 2001
From: Georgiy Samoylov 
Date: Mon, 17 Mar 2025 19:21:22 +0300
Subject: [PATCH 1/2] [lldb] Adapted test for remote debugging case

---
 .../Python/lldbsuite/test/lldbtest.py | 24 +++
 .../lldb-server/TestGdbRemoteForkNonStop.py   | 12 +-
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 590024ef77119..4b388a156fb56 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -743,6 +743,20 @@ def getBuildArtifact(self, name="a.out"):
 """Return absolute path to an artifact in the test's build 
directory."""
 return os.path.join(self.getBuildDir(), name)
 
+def get_process_working_directory(self):
+"""Get the working directory that should be used when launching 
processes for local or remote processes."""
+if lldb.remote_platform:
+# Remote tests set the platform working directory up in
+# TestBase.setUp()
+return lldb.remote_platform.GetWorkingDirectory()
+else:
+# local tests change directory into each test subdirectory
+return self.getBuildDir()
+
+def getWorkingDirArtifact(self, name="a.out"):
+"""Return absolute path to an artifact in the test's working 
directory."""
+return os.path.join(self.get_process_working_directory(), name)
+
 def getSourcePath(self, name):
 """Return absolute path to a file in the test's source directory."""
 return os.path.join(self.getSourceDir(), name)
@@ -2018,16 +2032,6 @@ def frame(self):
 .GetSelectedFrame()
 )
 
-def get_process_working_directory(self):
-"""Get the working directory that should be used when launching 
processes for local or remote processes."""
-if lldb.remote_platform:
-# Remote tests set the platform working directory up in
-# TestBase.setUp()
-return lldb.remote_platform.GetWorkingDirectory()
-else:
-# local tests change directory into each test subdirectory
-return self.getBuildDir()
-
 def tearDown(self):
 # Ensure all the references to SB objects have gone away so that we can
 # be sure that all test-specific resources have been freed before we
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py
index 090d4e1bcac95..35da92e3cc2f5 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py
@@ -156,8 +156,8 @@ def get_all_output_via_vStdio(self, output_test):
 
 @add_test_categories(["fork"])
 def test_c_both_nonstop(self):
-lock1 = self.getBuildArtifact("lock1")
-lock2 = self.getBuildArtifact("lock2")
+lock1 = self.getWorkingDirArtifact("lock1")
+lock2 = self.getWorkingDirArtifact("lock2")
 parent_pid, parent_tid, child_pid, child_tid = self.start_fork_test(
 [
 "fork",
@@ -194,8 +194,8 @@ def test_c_both_nonstop(self):
 
 @add_test_categories(["fork"])
 def test_vCont_both_nonstop(self):
-lock1 = self.getBuildArtifact("lock1")
-lock2 = self.getBuildArtifact("lock2")
+lock1 = self.getWorkingDirArtifact("lock1")
+lock2 = self.getWorkingDirArtifact("lock2")
 parent_pid, parent_tid, child_pid, child_tid = self.start_fork_test(
 [
 "fork",
@@ -227,8 +227,8 @@ def test_vCont_both_nonstop(self):
 self.assertIn("PID: {}".format(int(child_pid, 16)).encode(), output)
 
 def vCont_both_nonstop_test(self, vCont_packet):
-lock1 = self.getBuildArtifact("lock1")
-lock2 = self.getBuildArtifact("lock2")
+lock1 = self.getWorkingDirArtifact("lock1")
+lock2 = self.getWorkingDirArtifact("lock2")
 parent_pid, parent_tid, child_pid, child_tid = self.start_fork_test(
 [
 "fork",

>From 47f1555422bde7753908026fa68693a4dd0ca4cb Mon Sep 17 00:00:00 2001
From: Georgiy Samoylov 
Date: Wed, 19 Mar 2025 15:50:00 +0300
Subject: [PATCH 2/2] [lldb] Rewrote with lldbutil function

---
 .../tools/lldb-server/TestGdbRemoteForkNonStop.py  | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py
index 35da92e3cc2f5..beb0ecf1b3484 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py
@@ -1,6 +1,6 @@
 from lldbsuite.test.decorators import *
 f

[Lldb-commits] [lldb] [lldb] Fix TestGdbRemoteForkNonStop.py test (PR #131293)

2025-03-21 Thread Georgiy Samoylov via lldb-commits

sga-sc wrote:

I don’t have merge rights, so could you merge it, please?

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


[Lldb-commits] [lldb] [lldb] Fix TestGdbRemoteForkNonStop.py test (PR #131293)

2025-03-19 Thread Georgiy Samoylov via lldb-commits

https://github.com/sga-sc updated 
https://github.com/llvm/llvm-project/pull/131293

>From 09aa2a57cdc4be801589141390c02d0f1991cf45 Mon Sep 17 00:00:00 2001
From: Georgiy Samoylov 
Date: Wed, 19 Mar 2025 15:50:00 +0300
Subject: [PATCH 1/2] [lldb] Rewrote with lldbutil function

---
 .../tools/lldb-server/TestGdbRemoteForkNonStop.py  | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py
index 090d4e1bcac95..beb0ecf1b3484 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py
@@ -1,6 +1,6 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
-
+from lldbsuite.test.lldbutil import append_to_process_working_directory
 from fork_testbase import GdbRemoteForkTestBase
 
 
@@ -156,8 +156,8 @@ def get_all_output_via_vStdio(self, output_test):
 
 @add_test_categories(["fork"])
 def test_c_both_nonstop(self):
-lock1 = self.getBuildArtifact("lock1")
-lock2 = self.getBuildArtifact("lock2")
+lock1 = lldbutil.append_to_process_working_directory(self, "lock1")
+lock2 = lldbutil.append_to_process_working_directory(self, "lock2")
 parent_pid, parent_tid, child_pid, child_tid = self.start_fork_test(
 [
 "fork",
@@ -194,8 +194,8 @@ def test_c_both_nonstop(self):
 
 @add_test_categories(["fork"])
 def test_vCont_both_nonstop(self):
-lock1 = self.getBuildArtifact("lock1")
-lock2 = self.getBuildArtifact("lock2")
+lock1 = lldbutil.append_to_process_working_directory(self, "lock1")
+lock2 = lldbutil.append_to_process_working_directory(self, "lock2")
 parent_pid, parent_tid, child_pid, child_tid = self.start_fork_test(
 [
 "fork",
@@ -227,8 +227,8 @@ def test_vCont_both_nonstop(self):
 self.assertIn("PID: {}".format(int(child_pid, 16)).encode(), output)
 
 def vCont_both_nonstop_test(self, vCont_packet):
-lock1 = self.getBuildArtifact("lock1")
-lock2 = self.getBuildArtifact("lock2")
+lock1 = lldbutil.append_to_process_working_directory(self, "lock1")
+lock2 = lldbutil.append_to_process_working_directory(self, "lock2")
 parent_pid, parent_tid, child_pid, child_tid = self.start_fork_test(
 [
 "fork",

>From 77f27179c14defcaa4e5aab02dd197d3fcf82e18 Mon Sep 17 00:00:00 2001
From: Georgiy Samoylov 
Date: Wed, 19 Mar 2025 15:58:49 +0300
Subject: [PATCH 2/2] [lldb] Fixed typo

---
 lldb/packages/Python/lldbsuite/test/lldbtest.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 590024ef77119..b3397648ad619 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2022,7 +2022,7 @@ def get_process_working_directory(self):
 """Get the working directory that should be used when launching 
processes for local or remote processes."""
 if lldb.remote_platform:
 # Remote tests set the platform working directory up in
-# TestBase.setUp()
+# Base.setUp()
 return lldb.remote_platform.GetWorkingDirectory()
 else:
 # local tests change directory into each test subdirectory

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix TestGdbRemoteForkNonStop.py test (PR #131293)

2025-03-19 Thread Georgiy Samoylov via lldb-commits


@@ -743,6 +743,20 @@ def getBuildArtifact(self, name="a.out"):
 """Return absolute path to an artifact in the test's build 
directory."""
 return os.path.join(self.getBuildDir(), name)
 
+def get_process_working_directory(self):
+"""Get the working directory that should be used when launching 
processes for local or remote processes."""
+if lldb.remote_platform:
+# Remote tests set the platform working directory up in
+# TestBase.setUp()

sga-sc wrote:

Addressed

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


[Lldb-commits] [lldb] [lldb] Fix TestGdbRemoteForkNonStop.py test (PR #131293)

2025-03-19 Thread Georgiy Samoylov via lldb-commits


@@ -743,6 +743,20 @@ def getBuildArtifact(self, name="a.out"):
 """Return absolute path to an artifact in the test's build 
directory."""
 return os.path.join(self.getBuildDir(), name)
 
+def get_process_working_directory(self):
+"""Get the working directory that should be used when launching 
processes for local or remote processes."""
+if lldb.remote_platform:
+# Remote tests set the platform working directory up in
+# TestBase.setUp()
+return lldb.remote_platform.GetWorkingDirectory()
+else:
+# local tests change directory into each test subdirectory
+return self.getBuildDir()
+
+def getWorkingDirArtifact(self, name="a.out"):
+"""Return absolute path to an artifact in the test's working 
directory."""
+return os.path.join(self.get_process_working_directory(), name)

sga-sc wrote:

Addressed

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


[Lldb-commits] [lldb] [lldb] Fix TestGdbRemoteForkNonStop.py test (PR #131293)

2025-03-17 Thread Georgiy Samoylov via lldb-commits

sga-sc wrote:

@labath Addressed

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


[Lldb-commits] [lldb] [lldb] Fix broken pipe error (PR #127100)

2025-02-13 Thread Georgiy Samoylov via lldb-commits

https://github.com/sga-sc created 
https://github.com/llvm/llvm-project/pull/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.

>From 1fdc2f811c239bc8992fba9aa8e3d4eb9c76e96a Mon Sep 17 00:00:00 2001
From: Georgiy Samoylov 
Date: Thu, 6 Feb 2025 13:23:13 +0300
Subject: [PATCH 1/2] [lldb] Fixed a typo

---
 .../test/tools/lldb-server/gdbremote_testcase.py  | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

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..cf94bf08a5bce 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
@@ -397,13 +397,13 @@ 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:
+while connect_attempts < MAX_CONNECT_ATTEMPTS:
 # Create a socket to talk to the server
 try:
-logger.info("Connect attempt %d", connect_attemps + 1)
+logger.info("Connect attempt %d", connect_attempts + 1)
 self.sock = self.create_socket()
 self._server = Server(self.sock, server)
 return server
@@ -411,7 +411,7 @@ def connect_to_debug_monitor(self, attach_pid=None):
 # 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()

>From 8844cd67967e7a55682f2b0fd06e8bebe63dd604 Mon Sep 17 00:00:00 2001
From: Georgiy Samoylov 
Date: Thu, 6 Feb 2025 13:21:42 +0300
Subject: [PATCH 2/2] [lldb] Added function for socket checking

---
 .../tools/lldb-server/gdbremote_testcase.py   | 36 ++-
 1 file changed, 27 insertions(+), 9 deletions(-)

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 cf94bf08a5bce..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(
@@ -401,15 +417,17 @@ def connect_to_debug_monitor(self, attach_pid=None):
 MAX_CONNECT_ATTEMPTS = 10
 
 while connect_attempts < MAX_CONNECT_ATTEMPTS:
- 

[Lldb-commits] [lldb] [lldb] Fix broken pipe error (PR #127100)

2025-02-14 Thread Georgiy Samoylov via lldb-commits

https://github.com/sga-sc edited 
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


[Lldb-commits] [lldb] [lldb] Fix broken pipe error (PR #127100)

2025-02-14 Thread Georgiy Samoylov via lldb-commits

https://github.com/sga-sc updated 
https://github.com/llvm/llvm-project/pull/127100

>From 1fdc2f811c239bc8992fba9aa8e3d4eb9c76e96a Mon Sep 17 00:00:00 2001
From: Georgiy Samoylov 
Date: Thu, 6 Feb 2025 13:23:13 +0300
Subject: [PATCH 1/2] [lldb] Fixed a typo

---
 .../test/tools/lldb-server/gdbremote_testcase.py  | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

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..cf94bf08a5bce 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
@@ -397,13 +397,13 @@ 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:
+while connect_attempts < MAX_CONNECT_ATTEMPTS:
 # Create a socket to talk to the server
 try:
-logger.info("Connect attempt %d", connect_attemps + 1)
+logger.info("Connect attempt %d", connect_attempts + 1)
 self.sock = self.create_socket()
 self._server = Server(self.sock, server)
 return server
@@ -411,7 +411,7 @@ def connect_to_debug_monitor(self, attach_pid=None):
 # 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()

>From 9aab5677f83b826b796c3884c4c09364b27a38f2 Mon Sep 17 00:00:00 2001
From: Georgiy Samoylov 
Date: Fri, 14 Feb 2025 15:53:04 +0300
Subject: [PATCH 2/2] [lldb] Made socket verification process more generic

---
 .../lldbsuite/test/tools/lldb-server/gdbremote_testcase.py | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

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 cf94bf08a5bce..fb96b3d4de560 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
@@ -249,14 +249,11 @@ def remove_port_forward():
 
 def _verify_socket(self, sock):
 # Normally, when the remote stub is not ready, we will get 
ECONNREFUSED during the
-# connect() attempt. However, due to the way how ADB forwarding works, 
on android targets
+# connect() attempt. However, due to the way how port forwarding can 
work, on some targets
 # the connect() will always be successful, but the connection will be 
immediately dropped
-# if ADB could not connect on the remote side. This function tries to 
detect this
+# if we could not connect on the remote side. This function tries to 
detect this
 # situation, and report it as "connection refused" so that the upper 
layers attempt the
 # connection again.
-triple = self.dbg.GetSelectedPlatform().GetTriple()
-if not re.match(".*-.*-.*-android", triple):
-return  # Not android.
 can_read, _, _ = select.select([sock], [], [], 0.1)
 if sock not in can_read:
 return  # Data is not available, but the connection is alive.

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix broken pipe error (PR #127100)

2025-02-14 Thread Georgiy Samoylov via lldb-commits


@@ -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")

sga-sc wrote:

Removed this function

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


[Lldb-commits] [lldb] [lldb] Fix broken pipe error (PR #127100)

2025-02-14 Thread Georgiy Samoylov via lldb-commits


@@ -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")

sga-sc wrote:

I agree with Jonas about dependency on `netstat`. But llgs tests themselves are 
very linux-oriented: 
https://github.com/llvm/llvm-project/blob/8844cd67967e7a55682f2b0fd06e8bebe63dd604/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py#L199

I also agree that filtering should be done using Python


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


[Lldb-commits] [lldb] [lldb] Fix broken pipe error (PR #127100)

2025-02-14 Thread Georgiy Samoylov via lldb-commits


@@ -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()

sga-sc wrote:

@labath Thank you for your advice! After removing check for android platform 
tests passed. I execute tests on `qemu-system-riscv64` and it's port forwarding 
behaves probably like android's (judging by passed tests). What should I do 
with this check for android?

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


[Lldb-commits] [lldb] [lldb] Fix broken pipe error (PR #127100)

2025-02-14 Thread Georgiy Samoylov via lldb-commits


@@ -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()

sga-sc wrote:

Addressed.

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


[Lldb-commits] [lldb] [lldb] Fix broken pipe error (PR #127100)

2025-02-14 Thread Georgiy Samoylov via lldb-commits

sga-sc wrote:

Thank you for a review, guys, can you merge it, please? I don't have merge 
rights

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