-
Notifications
You must be signed in to change notification settings - Fork 14.8k
update lldb-server platform help parsing #162730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cs01
wants to merge
1
commit into
llvm:main
Choose a base branch
from
cs01:cs01/lldb-platform-help-text
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+341
−109
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
lldb/test/Shell/lldb-server/TestPlatformErrorMessages.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# UNSUPPORTED: system-windows | ||
|
||
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 {{p|platform}} --help' for a complete list of options. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# UNSUPPORTED: system-windows | ||
|
||
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 platform | ||
CHECK: USAGE: lldb-server {{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 platform --listen tcp://0.0.0.0:1234 | ||
CHECK: # Listen on port 5555, accept multiple connections | ||
CHECK: lldb-server platform --server --listen tcp://localhost:5555 | ||
CHECK: # Listen on Unix domain socket | ||
CHECK: lldb-server platform --listen unix:///tmp/lldb-server.sock |
37 changes: 37 additions & 0 deletions
37
lldb/test/Shell/lldb-server/TestPlatformSuccessfulStartup.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# UNSUPPORTED: system-windows | ||
|
||
# Test successful startup with valid TCP listen address | ||
# The socket file is created immediately when the server is ready to accept connections, | ||
# so we can verify successful startup without arbitrary sleep delays. | ||
RUN: rm -f %t.socket1 | ||
RUN: timeout 0.2s %platformserver --listen tcp://127.0.0.1:0 --socket-file %t.socket1 > %t.out1 2>&1 || true | ||
RUN: test -f %t.socket1 | ||
RUN: FileCheck --allow-empty --check-prefix=NO-ERROR %s < %t.out1 | ||
|
||
# Test successful startup with valid gdbserver-port | ||
RUN: rm -f %t.socket3 | ||
RUN: timeout 0.2s %platformserver --listen tcp://127.0.0.1:0 --gdbserver-port 0 --socket-file %t.socket3 > %t.out3 2>&1 || true | ||
RUN: test -f %t.socket3 | ||
RUN: FileCheck --allow-empty --check-prefix=NO-ERROR %s < %t.out3 | ||
|
||
# Test successful startup with specific valid gdbserver-port number | ||
RUN: rm -f %t.socket4 | ||
RUN: timeout 0.2s %platformserver --listen tcp://127.0.0.1:0 --gdbserver-port 12345 --socket-file %t.socket4 > %t.out4 2>&1 || true | ||
RUN: test -f %t.socket4 | ||
RUN: FileCheck --allow-empty --check-prefix=NO-ERROR %s < %t.out4 | ||
|
||
# Test successful startup with server mode (accepting multiple connections) | ||
RUN: rm -f %t.socket5 | ||
RUN: timeout 0.2s %platformserver --server --listen tcp://127.0.0.1:0 --socket-file %t.socket5 > %t.out5 2>&1 || true | ||
RUN: test -f %t.socket5 | ||
RUN: FileCheck --allow-empty --check-prefix=NO-ERROR %s < %t.out5 | ||
|
||
# Test successful startup with abbreviated 'p' command | ||
RUN: rm -f %t.socket6 | ||
RUN: timeout 0.2s %lldb-server p --listen tcp://127.0.0.1:0 --socket-file %t.socket6 > %t.out6 2>&1 || true | ||
RUN: test -f %t.socket6 | ||
RUN: FileCheck --allow-empty --check-prefix=NO-ERROR %s < %t.out6 | ||
|
||
# Verify no error or warning messages appear in successful startup | ||
NO-ERROR-NOT: error: | ||
NO-ERROR-NOT: warning: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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">; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm what {{ are part of the output and which are some kind of escape character? ISTR FileCheck regex uses {{}} so not sure what is what.