[Lldb-commits] [PATCH] D91634: [lldb] Error when there are no ports to launch a gdbserver on

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 17 07:52:41 PST 2020


DavidSpickett created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
DavidSpickett requested review of this revision.
Herald added a subscriber: JDevlieghere.

Previously if you did:
$ lldb-server platform --server <...> --min-gdbserver-port 12346
--max-gdbserver-port 12347
(meaning only use port 12346 for gdbservers)

Then tried to launch two gdbservers on the same connection,
the second one would return port 65535. Which is a real port
number but it actually means lldb-server didn't find one it was
allowed to use.

send packet: $qLaunchGDBServer;<...>
read packet: $pid:1919;port:12346;#c0
<...>
send packet: $qLaunchGDBServer;<...>
read packet: $pid:1927;port:65535;#c7

This situation should be an error even if port 65535 does happen
to be available on the current machine.

Found while investigating: https://bugs.llvm.org/show_bug.cgi?id=48205


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91634

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -97,6 +97,8 @@
     uint16_t &port, std::string &socket_name) {
   if (port == UINT16_MAX)
     port = GetNextAvailablePort();
+  if (port == UINT16_MAX)
+    return Status("Could not find an available port to launch a gdbserver.");
 
   // Spawn a new thread to accept the port that gets bound after binding to
   // port 0 (zero).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91634.305797.patch
Type: text/x-patch
Size: 659 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201117/b2c6b7da/attachment-0001.bin>


More information about the lldb-commits mailing list