Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lldb/test/Shell/lldb-server/TestPlatformErrorMessages.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
RUN: %platformserver 2>&1 | FileCheck --check-prefixes=NO_LISTEN,ALL %s
NO_LISTEN: error: either --listen or --child-platform-fd is required

RUN: %lldb-server platform --listen 2>&1 | FileCheck --check-prefixes=LISTEN_MISSING,ALL %s
LISTEN_MISSING: error: --listen: missing argument

RUN: %lldb-server p --bogus 2>&1 | FileCheck --check-prefixes=BOGUS,ALL %s
BOGUS: error: unknown argument '--bogus'

RUN: %platformserver --gdbserver-port 2>&1 | FileCheck --check-prefixes=GDBPORT_MISSING,ALL %s
GDBPORT_MISSING: error: --gdbserver-port: missing argument

RUN: %platformserver --gdbserver-port notanumber --listen :1234 2>&1 | FileCheck --check-prefixes=GDBPORT_INVALID %s
GDBPORT_INVALID: error: invalid --gdbserver-port value

RUN: %platformserver --socket-file 2>&1 | FileCheck --check-prefixes=SOCKETFILE_MISSING,ALL %s
SOCKETFILE_MISSING: error: --socket-file: missing argument

RUN: %platformserver --log-file 2>&1 | FileCheck --check-prefixes=LOGFILE_MISSING,ALL %s
LOGFILE_MISSING: error: --log-file: missing argument

RUN: %platformserver --log-channels 2>&1 | FileCheck --check-prefixes=LOGCHANNELS_MISSING,ALL %s
LOGCHANNELS_MISSING: error: --log-channels: missing argument

ALL: Use 'lldb-server{{(\.exe)?}} {{p|platform}} --help' for a complete list of options.
40 changes: 40 additions & 0 deletions lldb/test/Shell/lldb-server/TestPlatformHelp.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
RUN: %platformserver --help 2>&1 | FileCheck %s
RUN: %platformserver -h 2>&1 | FileCheck %s
RUN: %lldb-server p --help 2>&1 | FileCheck %s
RUN: %lldb-server p -h 2>&1 | FileCheck %s
RUN: %lldb-server platform --help 2>&1 | FileCheck %s
RUN: %lldb-server platform -h 2>&1 | FileCheck %s

CHECK: OVERVIEW: lldb-server{{(\.exe)?}} platform

CHECK: USAGE: lldb-server{{(\.exe)?}} {{p|platform}} [options] --listen <[host]:port> {{\[}}[--] program args...]

CHECK: CONNECTION OPTIONS:
CHECK: --gdbserver-port <port>
CHECK-SAME: Short form: -P
CHECK: --listen <[host]:port>
CHECK-SAME: Short form: -L
CHECK: --socket-file <path>
CHECK-SAME: Short form: -f

CHECK: GENERAL OPTIONS:
CHECK: --help
CHECK: --log-channels <channel1 categories...:channel2 categories...>
CHECK: Short form: -c
CHECK: --log-file <file>
CHECK-SAME: Short form: -l
CHECK: --server

CHECK: OPTIONS:
CHECK: -- program args

CHECK: DESCRIPTION
CHECK: Acts as a platform server for remote debugging

CHECK: EXAMPLES
CHECK: # Listen on port 1234, exit after first connection
CHECK: lldb-server{{(\.exe)?}} platform --listen tcp://0.0.0.0:1234
CHECK: # Listen on port 5555, accept multiple connections
CHECK: lldb-server{{(\.exe)?}} platform --server --listen tcp://localhost:5555
CHECK: # Listen on Unix domain socket
CHECK: lldb-server{{(\.exe)?}} platform --listen unix:///tmp/lldb-server.sock
5 changes: 5 additions & 0 deletions lldb/tools/lldb-server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ set(LLVM_TARGET_DEFINITIONS LLGSOptions.td)
tablegen(LLVM LLGSOptions.inc -gen-opt-parser-defs)
add_public_tablegen_target(LLGSOptionsTableGen)

set(LLVM_TARGET_DEFINITIONS PlatformOptions.td)
tablegen(LLVM PlatformOptions.inc -gen-opt-parser-defs)
add_public_tablegen_target(PlatformOptionsTableGen)

set(LLDB_PLUGINS)

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

add_dependencies(lldb-server
LLGSOptionsTableGen
PlatformOptionsTableGen
${tablegen_deps}
)
target_include_directories(lldb-server PRIVATE "${LLDB_SOURCE_DIR}/source")
Expand Down
75 changes: 75 additions & 0 deletions lldb/tools/lldb-server/PlatformOptions.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
include "llvm/Option/OptParser.td"

class F<string name>: Flag<["--", "-"], name>;
class R<list<string> prefixes, string name>
: Option<prefixes, name, KIND_REMAINING_ARGS>;

multiclass SJ<string name, string help> {
def NAME: Separate<["--", "-"], name>,
HelpText<help>;
def NAME # _eq: Joined<["--", "-"], name # "=">,
Alias<!cast<Separate>(NAME)>;
}

def grp_connect : OptionGroup<"connection">, HelpText<"CONNECTION OPTIONS">;

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">,
MetaVarName<"<[host]:port>">,
Group<grp_connect>;
def: Separate<["-"], "L">, Alias<listen>,
Group<grp_connect>;

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">,
MetaVarName<"<path>">,
Group<grp_connect>;
def: Separate<["-"], "f">, Alias<socket_file>,
Group<grp_connect>;

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">,
MetaVarName<"<port>">,
Group<grp_connect>;
def: Separate<["-"], "P">, Alias<gdbserver_port>,
Group<grp_connect>;

defm child_platform_fd: SJ<"child-platform-fd", "File descriptor for communication with parent platform process (internal use only).">,
MetaVarName<"<fd>">,
Group<grp_connect>,
Flags<[HelpHidden]>;

def grp_general : OptionGroup<"general options">, HelpText<"GENERAL OPTIONS">;

def server: F<"server">,
HelpText<"Run in server mode, accepting multiple client connections sequentially. Without this flag, the server exits after handling the first connection.">,
Group<grp_general>;

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">,
MetaVarName<"<channel1 categories...:channel2 categories...>">,
Group<grp_general>;
def: Separate<["-"], "c">, Alias<log_channels>,
Group<grp_general>;

defm log_file: SJ<"log-file", "Destination file to log to. If empty, log to stderr. Short form: -l">,
MetaVarName<"<file>">,
Group<grp_general>;
def: Separate<["-"], "l">, Alias<log_file>,
Group<grp_general>;

def debug: F<"debug">,
HelpText<"(Unused, kept for backward compatibility)">,
Group<grp_general>,
Flags<[HelpHidden]>;

def verbose: F<"verbose">,
HelpText<"(Unused, kept for backward compatibility)">,
Group<grp_general>,
Flags<[HelpHidden]>;

def help: F<"help">,
HelpText<"Display this help message and exit.">,
Group<grp_general>;
def: Flag<["-"], "h">, Alias<help>,
Group<grp_general>;

def REM : R<["--"], "">,
HelpText<"Arguments to pass to launched gdbserver instances.">,
MetaVarName<"program args">;
Loading
Loading