[all-commits] [llvm/llvm-project] 98e87f: [lldb] Error when there are no ports to launch a g...

David Spickett via All-commits all-commits at lists.llvm.org
Mon Nov 30 02:24:13 PST 2020


  Branch: refs/heads/temp-test-main
  Home:   https://github.com/llvm/llvm-project
  Commit: 98e87f76d0f486122d76b334232102e0d7a9254d
      https://github.com/llvm/llvm-project/commit/98e87f76d0f486122d76b334232102e0d7a9254d
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2020-11-30 (Mon, 30 Nov 2020)

  Changed paths:
    M lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
    M lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
    M lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
    M lldb/tools/lldb-server/lldb-platform.cpp
    M lldb/unittests/Process/gdb-remote/CMakeLists.txt
    A lldb/unittests/Process/gdb-remote/PortMapTest.cpp

  Log Message:
  -----------
  [lldb] Error when there are no ports to launch a gdbserver on

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.

To fix this make PortMap it's own class within
GDBRemoteCommunicationServerPlatform.

This almost the same as the old typedef but for
GetNextAvailablePort() returning an llvm::Expected.
This means we have to handle not finding a port,
by returning an error packet.

Also add unit tests for this new PortMap class.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D91634




More information about the All-commits mailing list