Skip to content

Commit

Permalink
[lldb] Removed gdbserver ports map from lldb-server (llvm#104238)
Browse files Browse the repository at this point in the history
Listen to gdbserver-port, accept the connection and run `lldb-server gdbserver --fd` on all platforms.
Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now.

This is the part 2 of llvm#101283.

Fixes llvm#97537.
  • Loading branch information
slydiman authored Oct 3, 2024
1 parent 00c1989 commit 2e89312
Show file tree
Hide file tree
Showing 13 changed files with 361 additions and 739 deletions.
17 changes: 2 additions & 15 deletions lldb/docs/man/lldb-server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,8 @@ GDB-SERVER CONNECTIONS

.. option:: --gdbserver-port <port>

Define a port to be used for gdb-server connections. Can be specified multiple
times to allow multiple ports. Has no effect if --min-gdbserver-port
and --max-gdbserver-port are specified.

.. option:: --min-gdbserver-port <port>
.. option:: --max-gdbserver-port <port>

Specify the range of ports that can be used for gdb-server connections. Both
options need to be specified simultaneously. Overrides --gdbserver-port.

.. option:: --port-offset <offset>

Add the specified offset to port numbers returned by server. This is useful
if the server is running behind a firewall, and a range of ports is redirected
to it with an offset.
Define a port to be used for gdb-server connections. This port is used for
multiple connections.

EXAMPLES
--------
Expand Down
19 changes: 5 additions & 14 deletions lldb/docs/resources/qemu-testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,30 +149,21 @@ to the host (refer to QEMU's manuals for the specific options).
* At least one to connect to the intial ``lldb-server``.
* One more if you want to use ``lldb-server`` in ``platform mode``, and have it
start a ``gdbserver`` instance for you.
* A bunch more if you want to run tests against the ``lldb-server`` platform.

If you are doing either of the latter 2 you should also restrict what ports
``lldb-server tries`` to use, otherwise it will randomly pick one that is almost
certainly not forwarded. An example of this is shown below.

::

$ lldb-server plaform --server --listen 0.0.0.0:54321 \
--min-gdbserver-port 49140 --max-gdbserver-port 49150
$ lldb-server plaform --server --listen 0.0.0.0:54321 --gdbserver-port 49140

The result of this is that:

* ``lldb-server`` platform mode listens externally on port ``54321``.

* When it is asked to start a new gdbserver mode instance, it will use a port
in the range ``49140`` to ``49150``.
* When it is asked to start a new gdbserver mode instance, it will use the port
``49140``.

Your VM configuration should have ports ``54321``, and ``49140`` to ``49150``
forwarded for this to work.

.. note::
These options are used to create a "port map" within ``lldb-server``.
Unfortunately this map is not cleaned up on Windows on connection close,
and across a few uses you may run out of valid ports. To work around this,
restart the platform every so often, especially after running a set of tests.
This is tracked here: https://github.com/llvm/llvm-project/issues/90923
Your VM configuration should have ports ``54321`` and ``49140`` forwarded for
this to work.
Loading

0 comments on commit 2e89312

Please sign in to comment.