[Lldb-commits] [lldb] [lldb] add --platform-available-ports option to the dotest.py (PR #112555)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 31 06:06:52 PDT 2025
================
@@ -185,6 +185,8 @@ def setUpServerLogging(self, is_llgs):
]
def get_next_port(self):
+ if available_ports := self.getPlatformAvailablePorts():
+ return int(random.choice(available_ports))
----------------
dlav-sc wrote:
I haven't encountered this issue.
LLDB testsuite starts `lldb-server` in `gdbserver` mode before running each LLGS test. The `get_next_port` function is used to select a port to listen by `lldb-server`. At the end of the test, the testsuite kills `lldb-server`, making the port available again. If the testsuite is unable to start `lldb-server` on the chosen port, it waits for a second or so, selects another port using `get_next_port`, and tries to run `lldb-server` again. This can take several attempts, but it almost always works on the first try.
Currently, I pass 10 ports in this option, which is more than enough to successfully pass all LLGS tests.
To remove the randomization, we could introduce a counter and choose ports in ascending or descending order by modulo. However, I don't think this would significantly change anything.
The initial issue was that `get_next_port` selected a port from a pool of not non forwarded ports, so there was no chance to get a suitable port. Now we can choose a busy port, but it's not a big problem in fact.
https://github.com/llvm/llvm-project/pull/112555
More information about the lldb-commits
mailing list