12 Commits

Author SHA1 Message Date
Chad Smith
2675dcd72d
[lldb] update lldb-server platform help parsing (attempt 3) (#164904)
* original change #162730
* with windows fix #164843
* remove timeout that was pointed out in the comment above
* Remove test that starts and listens on a socket to avoid timeout
issues
2025-11-18 08:46:40 -08:00
Adrian Prantl
aac036a7f6 Revert "[lldb] update lldb-server platform help parsing (#162730)"
This reverts commit faf7af864f9258768133894764f1fae58d43bb09.

This is failing on the Darwin bots.

https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/16164/changes#faf7af864f9258768133894764f1fae58d43bb09
2025-10-23 13:56:14 -07:00
Adrian Prantl
4456afcf0b Revert "[lldb] fix lldb-server test failures on windows (#164843)"
This reverts commit 930b36cfbbc873fe6c329b95e1c56c6ae1ea1d94.

Reverting because it depends on 5fc40a5f2bedaf6ca3f024aa2a91c5f4ce187061.
2025-10-23 13:56:14 -07:00
Chad Smith
930b36cfbb
[lldb] fix lldb-server test failures on windows (#164843)
Fix windows test failures from
https://github.com/llvm/llvm-project/pull/162730 by including and
optional .exe on the lldb-server name. Still passes on linux, but should
pass on windows now.

```
> bin/llvm-lit -v tools/lldb/test/Shell/lldb-server/
llvm-lit: llvm-project/llvm/utils/lit/lit/llvm/config.py:531: note: using clang: llvm-project/build/bin/clang
llvm-lit: llvm-project/llvm/utils/lit/lit/llvm/config.py:531: note: using ld.lld: /usr/bin/ld.lld
llvm-lit: llvm-project/llvm/utils/lit/lit/llvm/config.py:531: note: using lld-link: /usr/bin/lld-link
llvm-lit: llvm-project/llvm/utils/lit/lit/llvm/config.py:531: note: using ld64.lld: /usr/bin/ld64.lld
llvm-lit: llvm-project/llvm/utils/lit/lit/llvm/config.py:531: note: using wasm-ld: /usr/bin/wasm-ld
llvm-lit: llvm-project/llvm/utils/lit/lit/llvm/subst.py:126: note: Did not find obj2yaml in llvm-project/build/./bin:llvm-project/build/./bin
llvm-lit: llvm-project/llvm/utils/lit/lit/llvm/subst.py:126: note: Did not find llvm-objdump in llvm-project/build/./bin:llvm-project/build/./bin
llvm-lit: llvm-project/lldb/test/Shell/lit.cfg.py:125: warning: Could not set a default per-test timeout. Requires the Python psutil module but it could not be found. Try installing it via pip or via your operating system's package manager.
-- Testing: 4 tests, 4 workers --
PASS: lldb-shell :: lldb-server/TestGdbserverErrorMessages.test (1 of 4)
PASS: lldb-shell :: lldb-server/TestPlatformHelp.test (2 of 4)
PASS: lldb-shell :: lldb-server/TestPlatformErrorMessages.test (3 of 4)
PASS: lldb-shell :: lldb-server/TestPlatformSuccessfulStartup.test (4 of 4)

Testing Time: 1.10s

Total Discovered Tests: 4
  Passed: 4 (100.00%)

1 warning(s) in tests
```
2025-10-23 17:53:43 +01:00
Chad Smith
faf7af864f
[lldb] update lldb-server platform help parsing (#162730)
The lldb-server platform help text is inconsistent with lldb-server
gdbserver help text. This PR modernizes the platform server to use
LLVM's [TableGen](https://llvm.org/docs/TableGen/)-based option parsing
(matching the existing gdbserver implementation), which auto-generates
option parsing code and help text.

The changes improve documentation quality by adding comprehensive option
descriptions,, adding support for `-h`/`--help` flags, and organizing
help output with DESCRIPTION and EXAMPLES sections. Internal-only
options (`--child-platform-fd`) and unused legacy options (`--debug`,
`--verbose`) are now hidden from help while maintaining backward
compatibility. All functional behavior remains unchanged—this is purely
a documentation and code modernization improvement.

## before
```
> /opt/llvm/bin/lldb-server p -h
p: unrecognized option '-h'
Usage:
  /opt/llvm/bin/lldb-server p [--log-file log-file-name] [--log-channels log-channel-list] [--port-file port-file-path] --server --listen port
```

## after
```
lldb-server p -h 
OVERVIEW: lldb-server platform

USAGE: lldb-server p [options] --listen <[host]:port> [[--] program args...]

CONNECTION OPTIONS:
  --gdbserver-port <port> Port to use for spawned gdbserver instances. If 0 or unspecified, a port will be chosen automatically. Short form: -P
  --listen <[host]:port>  Host and port to listen on. Format: [host]:port or protocol://[host]:port (e.g., tcp://localhost:1234, unix:///path/to/socket). Short form: -L
  --socket-file <path>    Write listening socket information (port number for TCP or path for Unix domain sockets) to the specified file. Short form: -f

GENERAL OPTIONS:
  --help            Display this help message and exit.
  --log-channels <channel1 categories...:channel2 categories...>
                    Channels to log. A colon-separated list of entries. Each entry starts with a channel followed by a space-separated list of categories. Common channels: lldb, gdb-remote, platform, process. Short form: -c
  --log-file <file> Destination file to log to. If empty, log to stderr. Short form: -l
  --server          Run in server mode, accepting multiple client connections sequentially. Without this flag, the server exits after handling the first connection.

OPTIONS:
  -- program args Arguments to pass to launched gdbserver instances.

DESCRIPTION
  Acts as a platform server for remote debugging. When LLDB clients connect,
  the platform server handles platform operations (file transfers, process
  launching) and spawns debug server instances (lldb-server gdbserver) to
  handle actual debugging sessions.

  By default, the server exits after handling one connection. Use --server
  to keep running and accept multiple connections sequentially.

EXAMPLES
  # Listen on port 1234, exit after first connection
  lldb-server platform --listen tcp://0.0.0.0:1234

  # Listen on port 5555, accept multiple connections
  lldb-server platform --server --listen tcp://localhost:5555

  # Listen on Unix domain socket
  lldb-server platform --listen unix:///tmp/lldb-server.sock

```

For comparison, here is the **gdbserver** help text:
```
lldb-server g -h
OVERVIEW: lldb-server

USAGE: lldb-server g[dbserver] [options] [[host]:port] [[--] program args...]

CONNECTION:
  --fd <fd>           Communicate over the given file descriptor.
  --named-pipe <name> Write port lldb-server will listen on to the given named pipe.
  --pipe <fd>         Write port lldb-server will listen on to the given file descriptor.
  --reverse-connect   Connect to the client instead of passively waiting for a connection. In this case [host]:port denotes the remote address to connect to.

GENERAL OPTIONS:
  --help            Prints out the usage information for lldb-server.
  --log-channels <channel1 categories...:channel2 categories...>
                    Channels to log. A colon-separated list of entries. Each entry starts with a channel followed by a space-separated list of categories.
  --log-file <file> Destination file to log to. If empty, log to stderr.
  --setsid          Run lldb-server in a new session.

TARGET SELECTION:
  --attach <pid-or-name> Attach to the process given by a (numeric) process id or a name.
  -- program args        Launch program for debugging.

DESCRIPTION
  lldb-server connects to the LLDB client, which drives the debugging session.
  If no connection options are given, the [host]:port argument must be present
  and will denote the address that lldb-server will listen on. [host] defaults
  to "localhost" if empty. Port can be zero, in which case the port number will
  be chosen dynamically and written to destinations given by --named-pipe and
  --pipe arguments.

  If no target is selected at startup, lldb-server can be directed by the LLDB
  client to launch or attach to a process.
```
2025-10-23 16:04:57 +01:00
Dmitry Vasilyev
2e89312419
[lldb] Removed gdbserver ports map from lldb-server (#104238)
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 #101283.

Fixes #97537.
2024-10-03 21:00:47 +04:00
Alex Langford
0cfa50154a [LLDB] Only run lldb-server Shell tests if it gets built
It's easy enough to disable the lldb-server build. The lldb-server unit
tests already have logic to disable them if we don't build, so this just
makes it even.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D135825
2022-10-14 12:00:57 -07:00
Raphael Isemann
bbcb4d6bc0 Revert "[lldb server] Tidy up LLDB server return codes and associated tests"
This reverts commit e387c8c413e2127bc93950fb6d786290237b4a9f. The
TestErrorMessages.test is failing on the Linux bots.
2021-09-02 15:27:39 +02:00
Sebastian Schwartz
e387c8c413 [lldb server] Tidy up LLDB server return codes and associated tests
This diff modifies the LLDB server return codes to more accurately reflect usage
error paths. Specifically we always propagate the return codes from the main
entrypoints into GDB remote LLDB server, and platform LLDB server. This way, the
top-level caller of LLDB server will be able to correctly check whether the
executable exited with or without an error.

We additionally modify and extend the associated shell unit tests to expect
nonzero return codes on error conditions.

Test Plan:
LLDB tests pass:

```
ninja check-lldb
```

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D108351
2021-09-02 11:16:37 +02:00
Raphael Isemann
9b0578d546 [lldb] Reinstate TestGdbserverPort.test
This test was deleted by accident in the great lldb-mi removal:
37fed664022e07c2293b674e9c9d2b50aac547ba
2020-11-10 15:51:15 +01:00
Raphael Isemann
c50faf5c9d [lldb] Fix TestErrorMessages test on standalone builds by adding lldb-server substitution
It seems that TestErrorMessages.test is failing on the standalone + Xcode builds
as lldb-server executable can't be found by lit's default PATH search. I assume
invoking lldb-server via a lit substitution gets this working again as
everything else is working, so that's what this patch is doing.

I had to add the lldb-server substitution as the test seems lldb-server specific
and we don't want it to default to debugserver on Darwin.

Using a substitution also seems in general like a good idea so that the commands
lit is printing on failure are using the full path to lldb-server and can be
re-run in a terminal.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D91155
2020-11-10 15:26:19 +01:00
Pavel Labath
fa5fa63fd1 [lldb] Port lldb gdb-server to libOption
The existing help text was very terse and was missing several important
options. In the new version, I add a short description of each option
and a slightly longer description of the tool as a whole.

The new option list does not include undocumented no-op options:
--debug and --verbose. It also does not include undocumented short
aliases for long options, with two exceptions: -h, because it's
well-known; and -S (--setsid), as it's used in one test. Using these
options will now produce an error. I believe that is acceptable as users
aren't generally invoking lldb-server directly, and the only way to
learn about the short aliases was by looking at the source.

Differential Revision: https://reviews.llvm.org/D89477
2020-10-21 16:16:18 +02:00