Skip to content

Commit eab11a4

Browse files
committed
update lldb-server platform help text
1 parent e07914b commit eab11a4

File tree

7 files changed

+346
-108
lines changed

7 files changed

+346
-108
lines changed
File renamed without changes.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# UNSUPPORTED: system-windows
2+
3+
RUN: %platformserver 2>&1 | FileCheck --check-prefixes=NO_LISTEN,ALL %s
4+
NO_LISTEN: error: either --listen or --child-platform-fd is required
5+
6+
RUN: %lldb-server platform --listen 2>&1 | FileCheck --check-prefixes=LISTEN_MISSING,ALL %s
7+
LISTEN_MISSING: error: --listen: missing argument
8+
9+
RUN: %lldb-server p --bogus 2>&1 | FileCheck --check-prefixes=BOGUS,ALL %s
10+
BOGUS: error: unknown argument '--bogus'
11+
12+
RUN: %platformserver --gdbserver-port 2>&1 | FileCheck --check-prefixes=GDBPORT_MISSING,ALL %s
13+
GDBPORT_MISSING: error: --gdbserver-port: missing argument
14+
15+
RUN: %platformserver --gdbserver-port notanumber --listen :1234 2>&1 | FileCheck --check-prefixes=GDBPORT_INVALID %s
16+
GDBPORT_INVALID: error: invalid --gdbserver-port value
17+
18+
RUN: %platformserver --socket-file 2>&1 | FileCheck --check-prefixes=SOCKETFILE_MISSING,ALL %s
19+
SOCKETFILE_MISSING: error: --socket-file: missing argument
20+
21+
RUN: %platformserver --log-file 2>&1 | FileCheck --check-prefixes=LOGFILE_MISSING,ALL %s
22+
LOGFILE_MISSING: error: --log-file: missing argument
23+
24+
RUN: %platformserver --log-channels 2>&1 | FileCheck --check-prefixes=LOGCHANNELS_MISSING,ALL %s
25+
LOGCHANNELS_MISSING: error: --log-channels: missing argument
26+
27+
ALL: Use 'lldb-server {{p|platform}} --help' for a complete list of options.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# UNSUPPORTED: system-windows
2+
3+
RUN: %platformserver --help 2>&1 | FileCheck %s
4+
RUN: %platformserver -h 2>&1 | FileCheck %s
5+
RUN: %lldb-server p --help 2>&1 | FileCheck %s
6+
RUN: %lldb-server p -h 2>&1 | FileCheck %s
7+
RUN: %lldb-server platform --help 2>&1 | FileCheck %s
8+
RUN: %lldb-server platform -h 2>&1 | FileCheck %s
9+
10+
CHECK: OVERVIEW: lldb-server platform
11+
CHECK: USAGE: lldb-server {{p|platform}} [options] --listen <{{[[]}}host]:port> {{[[]}}[--] program args...]
12+
13+
CHECK: CONNECTION OPTIONS:
14+
CHECK: --gdbserver-port <port>
15+
CHECK-SAME: Short form: -P
16+
CHECK: --listen <{{[[]}}host]:port>
17+
CHECK-SAME: Short form: -L
18+
CHECK: --socket-file <path>
19+
CHECK-SAME: Short form: -f
20+
21+
CHECK: GENERAL OPTIONS:
22+
CHECK: --help
23+
CHECK: --log-channels <channel1 categories...:channel2 categories...>
24+
CHECK: Short form: -c
25+
CHECK: --log-file <file>
26+
CHECK-SAME: Short form: -l
27+
CHECK: --server
28+
29+
CHECK: OPTIONS:
30+
CHECK: -- program args
31+
32+
CHECK: DESCRIPTION
33+
CHECK: Acts as a platform server for remote debugging
34+
35+
CHECK: EXAMPLES
36+
CHECK: # Listen on port 1234, exit after first connection
37+
CHECK: lldb-server platform --listen tcp://0.0.0.0:1234
38+
CHECK: # Listen on port 5555, accept multiple connections
39+
CHECK: lldb-server platform --server --listen tcp://localhost:5555
40+
CHECK: # Listen on Unix domain socket
41+
CHECK: lldb-server platform --listen unix:///tmp/lldb-server.sock
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# UNSUPPORTED: system-windows
2+
3+
# Test successful startup with valid TCP listen address
4+
# The socket file is created immediately when the server is ready to accept connections,
5+
# so we can verify successful startup without arbitrary sleep delays.
6+
RUN: rm -f %t.socket1
7+
RUN: timeout 0.2s %platformserver --listen tcp://127.0.0.1:0 --socket-file %t.socket1 > %t.out1 2>&1 || true
8+
RUN: test -f %t.socket1
9+
RUN: FileCheck --allow-empty --check-prefix=NO-ERROR %s < %t.out1
10+
11+
# Test successful startup with valid gdbserver-port
12+
RUN: rm -f %t.socket3
13+
RUN: timeout 0.2s %platformserver --listen tcp://127.0.0.1:0 --gdbserver-port 0 --socket-file %t.socket3 > %t.out3 2>&1 || true
14+
RUN: test -f %t.socket3
15+
RUN: FileCheck --allow-empty --check-prefix=NO-ERROR %s < %t.out3
16+
17+
# Test successful startup with specific valid gdbserver-port number
18+
RUN: rm -f %t.socket4
19+
RUN: timeout 0.2s %platformserver --listen tcp://127.0.0.1:0 --gdbserver-port 12345 --socket-file %t.socket4 > %t.out4 2>&1 || true
20+
RUN: test -f %t.socket4
21+
RUN: FileCheck --allow-empty --check-prefix=NO-ERROR %s < %t.out4
22+
23+
# Test successful startup with server mode (accepting multiple connections)
24+
RUN: rm -f %t.socket5
25+
RUN: timeout 0.2s %platformserver --server --listen tcp://127.0.0.1:0 --socket-file %t.socket5 > %t.out5 2>&1 || true
26+
RUN: test -f %t.socket5
27+
RUN: FileCheck --allow-empty --check-prefix=NO-ERROR %s < %t.out5
28+
29+
# Test successful startup with abbreviated 'p' command
30+
RUN: rm -f %t.socket6
31+
RUN: timeout 0.2s %lldb-server p --listen tcp://127.0.0.1:0 --socket-file %t.socket6 > %t.out6 2>&1 || true
32+
RUN: test -f %t.socket6
33+
RUN: FileCheck --allow-empty --check-prefix=NO-ERROR %s < %t.out6
34+
35+
# Verify no error or warning messages appear in successful startup
36+
NO-ERROR-NOT: error:
37+
NO-ERROR-NOT: warning:

lldb/tools/lldb-server/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ set(LLVM_TARGET_DEFINITIONS LLGSOptions.td)
22
tablegen(LLVM LLGSOptions.inc -gen-opt-parser-defs)
33
add_public_tablegen_target(LLGSOptionsTableGen)
44

5+
set(LLVM_TARGET_DEFINITIONS LLPlatformOptions.td)
6+
tablegen(LLVM LLPlatformOptions.inc -gen-opt-parser-defs)
7+
add_public_tablegen_target(LLPlatformOptionsTableGen)
8+
59
set(LLDB_PLUGINS)
610

711
if(CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
@@ -67,6 +71,7 @@ add_lldb_tool(lldb-server
6771

6872
add_dependencies(lldb-server
6973
LLGSOptionsTableGen
74+
LLPlatformOptionsTableGen
7075
${tablegen_deps}
7176
)
7277
target_include_directories(lldb-server PRIVATE "${LLDB_SOURCE_DIR}/source")
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
include "llvm/Option/OptParser.td"
2+
3+
class F<string name>: Flag<["--", "-"], name>;
4+
class R<list<string> prefixes, string name>
5+
: Option<prefixes, name, KIND_REMAINING_ARGS>;
6+
7+
multiclass SJ<string name, string help> {
8+
def NAME: Separate<["--", "-"], name>,
9+
HelpText<help>;
10+
def NAME # _eq: Joined<["--", "-"], name # "=">,
11+
Alias<!cast<Separate>(NAME)>;
12+
}
13+
14+
def grp_connect : OptionGroup<"connection">, HelpText<"CONNECTION OPTIONS">;
15+
16+
defm listen: SJ<"listen", "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">,
17+
MetaVarName<"<[host]:port>">,
18+
Group<grp_connect>;
19+
def: Separate<["-"], "L">, Alias<listen>,
20+
Group<grp_connect>;
21+
22+
defm socket_file: SJ<"socket-file", "Write listening socket information (port number for TCP or path for Unix domain sockets) to the specified file. Short form: -f">,
23+
MetaVarName<"<path>">,
24+
Group<grp_connect>;
25+
def: Separate<["-"], "f">, Alias<socket_file>,
26+
Group<grp_connect>;
27+
28+
defm gdbserver_port: SJ<"gdbserver-port", "Port to use for spawned gdbserver instances. If 0 or unspecified, a port will be chosen automatically. Short form: -P">,
29+
MetaVarName<"<port>">,
30+
Group<grp_connect>;
31+
def: Separate<["-"], "P">, Alias<gdbserver_port>,
32+
Group<grp_connect>;
33+
34+
defm child_platform_fd: SJ<"child-platform-fd", "File descriptor for communication with parent platform process (internal use only).">,
35+
MetaVarName<"<fd>">,
36+
Group<grp_connect>,
37+
Flags<[HelpHidden]>;
38+
39+
def grp_general : OptionGroup<"general options">, HelpText<"GENERAL OPTIONS">;
40+
41+
def server: F<"server">,
42+
HelpText<"Run in server mode, accepting multiple client connections sequentially. Without this flag, the server exits after handling the first connection.">,
43+
Group<grp_general>;
44+
45+
defm log_channels: SJ<"log-channels", "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">,
46+
MetaVarName<"<channel1 categories...:channel2 categories...>">,
47+
Group<grp_general>;
48+
def: Separate<["-"], "c">, Alias<log_channels>,
49+
Group<grp_general>;
50+
51+
defm log_file: SJ<"log-file", "Destination file to log to. If empty, log to stderr. Short form: -l">,
52+
MetaVarName<"<file>">,
53+
Group<grp_general>;
54+
def: Separate<["-"], "l">, Alias<log_file>,
55+
Group<grp_general>;
56+
57+
def debug: F<"debug">,
58+
HelpText<"(Unused, kept for backward compatibility)">,
59+
Group<grp_general>,
60+
Flags<[HelpHidden]>;
61+
62+
def verbose: F<"verbose">,
63+
HelpText<"(Unused, kept for backward compatibility)">,
64+
Group<grp_general>,
65+
Flags<[HelpHidden]>;
66+
67+
def help: F<"help">,
68+
HelpText<"Display this help message and exit.">,
69+
Group<grp_general>;
70+
def: Flag<["-"], "h">, Alias<help>,
71+
Group<grp_general>;
72+
73+
def REM : R<["--"], "">,
74+
HelpText<"Arguments to pass to launched gdbserver instances.">,
75+
MetaVarName<"program args">;

0 commit comments

Comments
 (0)