mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:09:48 +00:00
[ VM / CLI ] Remove service flags from VM and the CLI when building in
PRODUCT mode Fixes https://github.com/dart-lang/sdk/issues/47813 TEST=Manual testing, CQ Change-Id: I50e57fa653c45c892e748d4e283617200cee0c0a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224860 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
parent
0453a47fa2
commit
dc0b571335
|
@ -20,6 +20,7 @@ import '../utils.dart';
|
||||||
import '../vm_interop_handler.dart';
|
import '../vm_interop_handler.dart';
|
||||||
|
|
||||||
class RunCommand extends DartdevCommand {
|
class RunCommand extends DartdevCommand {
|
||||||
|
static const bool isProductMode = bool.fromEnvironment("dart.vm.product");
|
||||||
static const String cmdName = 'run';
|
static const String cmdName = 'run';
|
||||||
|
|
||||||
// kErrorExitCode, as defined in runtime/bin/error_exit.h
|
// kErrorExitCode, as defined in runtime/bin/error_exit.h
|
||||||
|
@ -47,97 +48,103 @@ class RunCommand extends DartdevCommand {
|
||||||
// the list of flags in Options::ProcessVMDebuggingOptions in
|
// the list of flags in Options::ProcessVMDebuggingOptions in
|
||||||
// runtime/bin/main_options.cc. Failure to do so will result in those VM
|
// runtime/bin/main_options.cc. Failure to do so will result in those VM
|
||||||
// options being ignored.
|
// options being ignored.
|
||||||
argParser
|
argParser.addSeparator(
|
||||||
..addSeparator(
|
'Debugging options:',
|
||||||
'Debugging options:',
|
);
|
||||||
)
|
if (!isProductMode) {
|
||||||
..addOption(
|
argParser
|
||||||
'observe',
|
..addOption(
|
||||||
help: 'The observe flag is a convenience flag used to run a program '
|
'observe',
|
||||||
'with a set of common options useful for debugging.',
|
help: 'The observe flag is a convenience flag used to run a program '
|
||||||
valueHelp: '[<port>[/<bind-address>]]',
|
'with a set of common options useful for debugging.',
|
||||||
)
|
valueHelp: '[<port>[/<bind-address>]]',
|
||||||
..addOption('launch-dds', hide: true, help: 'Launch DDS.')
|
)
|
||||||
..addSeparator(
|
..addOption('launch-dds', hide: true, help: 'Launch DDS.')
|
||||||
'Options implied by --observe are currently:',
|
..addSeparator(
|
||||||
)
|
'Options implied by --observe are currently:',
|
||||||
..addOption(
|
)
|
||||||
'enable-vm-service',
|
..addOption(
|
||||||
help: 'Enables the VM service and listens on the specified port for '
|
'enable-vm-service',
|
||||||
'connections (default port number is 8181, default bind address '
|
help: 'Enables the VM service and listens on the specified port for '
|
||||||
'is localhost).',
|
'connections (default port number is 8181, default bind address '
|
||||||
valueHelp: '[<port>[/<bind-address>]]',
|
'is localhost).',
|
||||||
)
|
valueHelp: '[<port>[/<bind-address>]]',
|
||||||
..addFlag(
|
)
|
||||||
'serve-devtools',
|
..addFlag(
|
||||||
help: 'Serves an instance of the Dart DevTools debugger and profiler '
|
'serve-devtools',
|
||||||
'via the VM service at <vm-service-uri>/devtools.',
|
help: 'Serves an instance of the Dart DevTools debugger and profiler '
|
||||||
defaultsTo: true,
|
'via the VM service at <vm-service-uri>/devtools.',
|
||||||
)
|
defaultsTo: true,
|
||||||
..addFlag(
|
)
|
||||||
'pause-isolates-on-exit',
|
..addFlag(
|
||||||
help: 'Pause isolates on exit when '
|
'pause-isolates-on-exit',
|
||||||
'running with --enable-vm-service.',
|
help: 'Pause isolates on exit when '
|
||||||
)
|
'running with --enable-vm-service.',
|
||||||
..addFlag(
|
)
|
||||||
'pause-isolates-on-unhandled-exceptions',
|
..addFlag(
|
||||||
help: 'Pause isolates when an unhandled exception is encountered '
|
'pause-isolates-on-unhandled-exceptions',
|
||||||
'when running with --enable-vm-service.',
|
help: 'Pause isolates when an unhandled exception is encountered '
|
||||||
)
|
'when running with --enable-vm-service.',
|
||||||
..addFlag(
|
)
|
||||||
'warn-on-pause-with-no-debugger',
|
..addFlag(
|
||||||
help: 'Print a warning when an isolate pauses with no attached debugger'
|
'warn-on-pause-with-no-debugger',
|
||||||
' when running with --enable-vm-service.',
|
help:
|
||||||
)
|
'Print a warning when an isolate pauses with no attached debugger'
|
||||||
..addSeparator(
|
' when running with --enable-vm-service.',
|
||||||
'Other debugging options:',
|
)
|
||||||
)
|
..addSeparator(
|
||||||
..addFlag(
|
'Other debugging options:',
|
||||||
'pause-isolates-on-start',
|
)
|
||||||
help: 'Pause isolates on start when '
|
..addFlag(
|
||||||
'running with --enable-vm-service.',
|
'pause-isolates-on-start',
|
||||||
)
|
help: 'Pause isolates on start when '
|
||||||
..addFlag(
|
'running with --enable-vm-service.',
|
||||||
'enable-asserts',
|
)
|
||||||
help: 'Enable assert statements.',
|
..addFlag(
|
||||||
)
|
'enable-asserts',
|
||||||
..addOption(
|
help: 'Enable assert statements.',
|
||||||
'verbosity',
|
);
|
||||||
help: 'Sets the verbosity level of the compilation.',
|
}
|
||||||
defaultsTo: Verbosity.defaultValue,
|
argParser.addOption(
|
||||||
allowed: Verbosity.allowedValues,
|
'verbosity',
|
||||||
allowedHelp: Verbosity.allowedValuesHelp,
|
help: 'Sets the verbosity level of the compilation.',
|
||||||
);
|
defaultsTo: Verbosity.defaultValue,
|
||||||
|
allowed: Verbosity.allowedValues,
|
||||||
|
allowedHelp: Verbosity.allowedValuesHelp,
|
||||||
|
);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
argParser.addSeparator(
|
argParser.addSeparator(
|
||||||
'Advanced options:',
|
'Advanced options:',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
argParser.addMultiOption(
|
||||||
|
'define',
|
||||||
|
abbr: 'D',
|
||||||
|
valueHelp: 'key=value',
|
||||||
|
help: 'Define an environment declaration.',
|
||||||
|
);
|
||||||
|
if (!isProductMode) {
|
||||||
|
argParser
|
||||||
|
..addFlag(
|
||||||
|
'disable-service-auth-codes',
|
||||||
|
hide: !verbose,
|
||||||
|
negatable: false,
|
||||||
|
help: 'Disables the requirement for an authentication code to '
|
||||||
|
'communicate with the VM service. Authentication codes help '
|
||||||
|
'protect against CSRF attacks, so it is not recommended to '
|
||||||
|
'disable them unless behind a firewall on a secure device.',
|
||||||
|
)
|
||||||
|
..addFlag(
|
||||||
|
'enable-service-port-fallback',
|
||||||
|
hide: !verbose,
|
||||||
|
negatable: false,
|
||||||
|
help: 'When the VM service is told to bind to a particular port, '
|
||||||
|
'fallback to 0 if it fails to bind instread of failing to '
|
||||||
|
'start.',
|
||||||
|
);
|
||||||
|
}
|
||||||
argParser
|
argParser
|
||||||
..addMultiOption(
|
|
||||||
'define',
|
|
||||||
abbr: 'D',
|
|
||||||
valueHelp: 'key=value',
|
|
||||||
help: 'Define an environment declaration.',
|
|
||||||
)
|
|
||||||
..addFlag(
|
|
||||||
'disable-service-auth-codes',
|
|
||||||
hide: !verbose,
|
|
||||||
negatable: false,
|
|
||||||
help: 'Disables the requirement for an authentication code to '
|
|
||||||
'communicate with the VM service. Authentication codes help '
|
|
||||||
'protect against CSRF attacks, so it is not recommended to '
|
|
||||||
'disable them unless behind a firewall on a secure device.',
|
|
||||||
)
|
|
||||||
..addFlag(
|
|
||||||
'enable-service-port-fallback',
|
|
||||||
hide: !verbose,
|
|
||||||
negatable: false,
|
|
||||||
help: 'When the VM service is told to bind to a particular port, '
|
|
||||||
'fallback to 0 if it fails to bind instread of failing to '
|
|
||||||
'start.',
|
|
||||||
)
|
|
||||||
..addOption(
|
..addOption(
|
||||||
'namespace',
|
'namespace',
|
||||||
hide: !verbose,
|
hide: !verbose,
|
||||||
|
@ -164,17 +171,22 @@ class RunCommand extends DartdevCommand {
|
||||||
hide: !verbose,
|
hide: !verbose,
|
||||||
negatable: false,
|
negatable: false,
|
||||||
help: 'Enables tracing of library and script loading.',
|
help: 'Enables tracing of library and script loading.',
|
||||||
)
|
|
||||||
..addFlag('dds',
|
|
||||||
hide: !verbose,
|
|
||||||
help: 'Use the Dart Development Service (DDS) for enhanced debugging '
|
|
||||||
'functionality. Note: Disabling DDS may break some functionality '
|
|
||||||
'in IDEs and other tooling.',
|
|
||||||
defaultsTo: true)
|
|
||||||
..addFlag(
|
|
||||||
'debug-dds',
|
|
||||||
hide: true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!isProductMode) {
|
||||||
|
argParser
|
||||||
|
..addFlag('dds',
|
||||||
|
hide: !verbose,
|
||||||
|
help:
|
||||||
|
'Use the Dart Development Service (DDS) for enhanced debugging '
|
||||||
|
'functionality. Note: Disabling DDS may break some functionality '
|
||||||
|
'in IDEs and other tooling.',
|
||||||
|
defaultsTo: true)
|
||||||
|
..addFlag(
|
||||||
|
'debug-dds',
|
||||||
|
hide: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
addExperimentalFlags(argParser, verbose);
|
addExperimentalFlags(argParser, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,40 +203,43 @@ class RunCommand extends DartdevCommand {
|
||||||
// The command line arguments after the command name.
|
// The command line arguments after the command name.
|
||||||
runArgs = argResults.rest.skip(1).toList();
|
runArgs = argResults.rest.skip(1).toList();
|
||||||
}
|
}
|
||||||
// --launch-dds is provided by the VM if the VM service is to be enabled. In
|
|
||||||
// that case, we need to launch DDS as well.
|
|
||||||
String launchDdsArg = argResults['launch-dds'];
|
|
||||||
String ddsHost = '';
|
|
||||||
String ddsPort = '';
|
|
||||||
|
|
||||||
bool launchDevTools = argResults['serve-devtools'];
|
if (!isProductMode) {
|
||||||
bool launchDds = false;
|
// --launch-dds is provided by the VM if the VM service is to be enabled. In
|
||||||
if (launchDdsArg != null) {
|
// that case, we need to launch DDS as well.
|
||||||
launchDds = true;
|
String launchDdsArg = argResults['launch-dds'];
|
||||||
final ddsUrl = launchDdsArg.split('\\:');
|
String ddsHost = '';
|
||||||
ddsHost = ddsUrl[0];
|
String ddsPort = '';
|
||||||
ddsPort = ddsUrl[1];
|
|
||||||
}
|
|
||||||
final bool debugDds = argResults['debug-dds'];
|
|
||||||
|
|
||||||
bool disableServiceAuthCodes = argResults['disable-service-auth-codes'];
|
bool launchDevTools = argResults['serve-devtools'];
|
||||||
|
bool launchDds = false;
|
||||||
|
if (launchDdsArg != null) {
|
||||||
|
launchDds = true;
|
||||||
|
final ddsUrl = launchDdsArg.split('\\:');
|
||||||
|
ddsHost = ddsUrl[0];
|
||||||
|
ddsPort = ddsUrl[1];
|
||||||
|
}
|
||||||
|
final bool debugDds = argResults['debug-dds'];
|
||||||
|
|
||||||
// If the user wants to start a debugging session we need to do some extra
|
bool disableServiceAuthCodes = argResults['disable-service-auth-codes'];
|
||||||
// work and spawn a Dart Development Service (DDS) instance. DDS is a VM
|
|
||||||
// service intermediary which implements the VM service protocol and
|
// If the user wants to start a debugging session we need to do some extra
|
||||||
// provides non-VM specific extensions (e.g., log caching, client
|
// work and spawn a Dart Development Service (DDS) instance. DDS is a VM
|
||||||
// synchronization).
|
// service intermediary which implements the VM service protocol and
|
||||||
_DebuggingSession debugSession;
|
// provides non-VM specific extensions (e.g., log caching, client
|
||||||
if (launchDds) {
|
// synchronization).
|
||||||
debugSession = _DebuggingSession();
|
_DebuggingSession debugSession;
|
||||||
if (!await debugSession.start(
|
if (launchDds) {
|
||||||
ddsHost,
|
debugSession = _DebuggingSession();
|
||||||
ddsPort,
|
if (!await debugSession.start(
|
||||||
disableServiceAuthCodes,
|
ddsHost,
|
||||||
launchDevTools,
|
ddsPort,
|
||||||
debugDds,
|
disableServiceAuthCodes,
|
||||||
)) {
|
launchDevTools,
|
||||||
return errorExitCode;
|
debugDds,
|
||||||
|
)) {
|
||||||
|
return errorExitCode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,8 +141,10 @@ void Options::PrintUsage() {
|
||||||
if (!Options::verbose_option()) {
|
if (!Options::verbose_option()) {
|
||||||
Syslog::Print(
|
Syslog::Print(
|
||||||
"Common VM flags:\n"
|
"Common VM flags:\n"
|
||||||
|
#if !defined(PRODUCT)
|
||||||
"--enable-asserts\n"
|
"--enable-asserts\n"
|
||||||
" Enable assert statements.\n"
|
" Enable assert statements.\n"
|
||||||
|
#endif // !defined(PRODUCT)
|
||||||
"--help or -h\n"
|
"--help or -h\n"
|
||||||
" Display this message (add -v or --verbose for information about\n"
|
" Display this message (add -v or --verbose for information about\n"
|
||||||
" all VM options).\n"
|
" all VM options).\n"
|
||||||
|
@ -151,6 +153,7 @@ void Options::PrintUsage() {
|
||||||
"--define=<key>=<value> or -D<key>=<value>\n"
|
"--define=<key>=<value> or -D<key>=<value>\n"
|
||||||
" Define an environment declaration. To specify multiple declarations,\n"
|
" Define an environment declaration. To specify multiple declarations,\n"
|
||||||
" use multiple instances of this option.\n"
|
" use multiple instances of this option.\n"
|
||||||
|
#if !defined(PRODUCT)
|
||||||
"--observe[=<port>[/<bind-address>]]\n"
|
"--observe[=<port>[/<bind-address>]]\n"
|
||||||
" The observe flag is a convenience flag used to run a program with a\n"
|
" The observe flag is a convenience flag used to run a program with a\n"
|
||||||
" set of options which are often useful for debugging under Observatory.\n"
|
" set of options which are often useful for debugging under Observatory.\n"
|
||||||
|
@ -166,6 +169,7 @@ void Options::PrintUsage() {
|
||||||
" Outputs information necessary to connect to the VM service to the\n"
|
" Outputs information necessary to connect to the VM service to the\n"
|
||||||
" specified file in JSON format. Useful for clients which are unable to\n"
|
" specified file in JSON format. Useful for clients which are unable to\n"
|
||||||
" listen to stdout for the Observatory listening message.\n"
|
" listen to stdout for the Observatory listening message.\n"
|
||||||
|
#endif // !defined(PRODUCT)
|
||||||
"--snapshot-kind=<snapshot_kind>\n"
|
"--snapshot-kind=<snapshot_kind>\n"
|
||||||
"--snapshot=<file_name>\n"
|
"--snapshot=<file_name>\n"
|
||||||
" These snapshot options are used to generate a snapshot of the loaded\n"
|
" These snapshot options are used to generate a snapshot of the loaded\n"
|
||||||
|
@ -178,8 +182,10 @@ void Options::PrintUsage() {
|
||||||
} else {
|
} else {
|
||||||
Syslog::Print(
|
Syslog::Print(
|
||||||
"Supported options:\n"
|
"Supported options:\n"
|
||||||
|
#if !defined(PRODUCT)
|
||||||
"--enable-asserts\n"
|
"--enable-asserts\n"
|
||||||
" Enable assert statements.\n"
|
" Enable assert statements.\n"
|
||||||
|
#endif // !defined(PRODUCT)
|
||||||
"--help or -h\n"
|
"--help or -h\n"
|
||||||
" Display this message (add -v or --verbose for information about\n"
|
" Display this message (add -v or --verbose for information about\n"
|
||||||
" all VM options).\n"
|
" all VM options).\n"
|
||||||
|
@ -188,6 +194,7 @@ void Options::PrintUsage() {
|
||||||
"--define=<key>=<value> or -D<key>=<value>\n"
|
"--define=<key>=<value> or -D<key>=<value>\n"
|
||||||
" Define an environment declaration. To specify multiple declarations,\n"
|
" Define an environment declaration. To specify multiple declarations,\n"
|
||||||
" use multiple instances of this option.\n"
|
" use multiple instances of this option.\n"
|
||||||
|
#if !defined(PRODUCT)
|
||||||
"--observe[=<port>[/<bind-address>]]\n"
|
"--observe[=<port>[/<bind-address>]]\n"
|
||||||
" The observe flag is a convenience flag used to run a program with a\n"
|
" The observe flag is a convenience flag used to run a program with a\n"
|
||||||
" set of options which are often useful for debugging under Observatory.\n"
|
" set of options which are often useful for debugging under Observatory.\n"
|
||||||
|
@ -199,12 +206,14 @@ void Options::PrintUsage() {
|
||||||
" --warn-on-pause-with-no-debugger\n"
|
" --warn-on-pause-with-no-debugger\n"
|
||||||
" This set is subject to change.\n"
|
" This set is subject to change.\n"
|
||||||
" Please see these options for further documentation.\n"
|
" Please see these options for further documentation.\n"
|
||||||
|
#endif // !defined(PRODUCT)
|
||||||
"--version\n"
|
"--version\n"
|
||||||
" Print the VM version.\n"
|
" Print the VM version.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"--trace-loading\n"
|
"--trace-loading\n"
|
||||||
" enables tracing of library and script loading\n"
|
" enables tracing of library and script loading\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
#if !defined(PRODUCT)
|
||||||
"--enable-vm-service[=<port>[/<bind-address>]]\n"
|
"--enable-vm-service[=<port>[/<bind-address>]]\n"
|
||||||
" Enables the VM service and listens on specified port for connections\n"
|
" Enables the VM service and listens on specified port for connections\n"
|
||||||
" (default port number is 8181, default bind address is localhost).\n"
|
" (default port number is 8181, default bind address is localhost).\n"
|
||||||
|
@ -219,6 +228,7 @@ void Options::PrintUsage() {
|
||||||
" When the VM service is told to bind to a particular port, fallback to 0 if\n"
|
" When the VM service is told to bind to a particular port, fallback to 0 if\n"
|
||||||
" it fails to bind instead of failing to start.\n"
|
" it fails to bind instead of failing to start.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
#endif // !defined(PRODUCT)
|
||||||
"--root-certs-file=<path>\n"
|
"--root-certs-file=<path>\n"
|
||||||
" The path to a file containing the trusted root certificates to use for\n"
|
" The path to a file containing the trusted root certificates to use for\n"
|
||||||
" secure socket connections.\n"
|
" secure socket connections.\n"
|
||||||
|
@ -321,6 +331,7 @@ const char* Options::vm_service_server_ip_ = DEFAULT_VM_SERVICE_SERVER_IP;
|
||||||
int Options::vm_service_server_port_ = INVALID_VM_SERVICE_SERVER_PORT;
|
int Options::vm_service_server_port_ = INVALID_VM_SERVICE_SERVER_PORT;
|
||||||
bool Options::ProcessEnableVmServiceOption(const char* arg,
|
bool Options::ProcessEnableVmServiceOption(const char* arg,
|
||||||
CommandLineOptions* vm_options) {
|
CommandLineOptions* vm_options) {
|
||||||
|
#if !defined(PRODUCT)
|
||||||
const char* value =
|
const char* value =
|
||||||
OptionProcessor::ProcessOption(arg, "--enable-vm-service");
|
OptionProcessor::ProcessOption(arg, "--enable-vm-service");
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
|
@ -339,10 +350,15 @@ bool Options::ProcessEnableVmServiceOption(const char* arg,
|
||||||
#endif // !defined(DART_PRECOMPILED_RUNTIME)
|
#endif // !defined(DART_PRECOMPILED_RUNTIME)
|
||||||
enable_vm_service_ = true;
|
enable_vm_service_ = true;
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
// VM service not available in product mode.
|
||||||
|
return false;
|
||||||
|
#endif // !defined(PRODUCT)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Options::ProcessObserveOption(const char* arg,
|
bool Options::ProcessObserveOption(const char* arg,
|
||||||
CommandLineOptions* vm_options) {
|
CommandLineOptions* vm_options) {
|
||||||
|
#if !defined(PRODUCT)
|
||||||
const char* value = OptionProcessor::ProcessOption(arg, "--observe");
|
const char* value = OptionProcessor::ProcessOption(arg, "--observe");
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -366,6 +382,10 @@ bool Options::ProcessObserveOption(const char* arg,
|
||||||
#endif // !defined(DART_PRECOMPILED_RUNTIME)
|
#endif // !defined(DART_PRECOMPILED_RUNTIME)
|
||||||
enable_vm_service_ = true;
|
enable_vm_service_ = true;
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
// VM service not available in product mode.
|
||||||
|
return false;
|
||||||
|
#endif // !defined(PRODUCT)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicitly handle VM flags that can be parsed by DartDev's run command.
|
// Explicitly handle VM flags that can be parsed by DartDev's run command.
|
||||||
|
|
|
@ -128,6 +128,7 @@ template("_application_snapshot") {
|
||||||
# (Instead of ensuring every user of the "application_snapshot" /
|
# (Instead of ensuring every user of the "application_snapshot" /
|
||||||
# "kernel_snapshot" passes this if needed, we always pass it)
|
# "kernel_snapshot" passes this if needed, we always pass it)
|
||||||
"-Dsdk_hash=$sdk_hash",
|
"-Dsdk_hash=$sdk_hash",
|
||||||
|
"-Ddart.vm.product=$is_product",
|
||||||
]
|
]
|
||||||
args += [ rebase_path(main_dart) ]
|
args += [ rebase_path(main_dart) ]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue