Skip to content

Commit f1bff1b

Browse files
committed
Add option to run ddb with observatory
- Add arg parsing for both `--observe` and `--vm-service-port` for the cases where we need to specify a port other than the default. We need both since we can't treat the same name as either a flag or an option based on whether a value was given, which is the behavior of the VM. - Follow the `debug` paths when any of `--debug`, `--observe`, or `--vm-service-port` is used. - Whenever using observatory always use `--pause-isolates-on-start` since the process would otherwise finish before getting a chance to use it. Change-Id: I30c3f9136ba9a7e8bea4220f88026b13963efc21 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117595 Auto-Submit: Nate Bosch <[email protected]> Reviewed-by: Nicholas Shahan <[email protected]>
1 parent ea969c3 commit f1bff1b

File tree

1 file changed

+22
-3
lines changed
  • pkg/dev_compiler/tool

1 file changed

+22
-3
lines changed

pkg/dev_compiler/tool/ddb

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ void main(List<String> args) async {
3737
abbr: 'd',
3838
help: 'Use current source instead of built SDK.',
3939
defaultsTo: false)
40+
..addFlag('observe',
41+
help:
42+
'Run the compiler in the Dart VM with --observe. Implies --debug.',
43+
defaultsTo: false)
44+
..addOption('vm-service-port',
45+
help: 'Specify the observatory port. Implied --observe.')
4046
..addFlag('summarize-text',
4147
help: 'Emit API summary in a .js.txt file.\n'
4248
'Ignored when not passed with --kernel.',
@@ -70,7 +76,9 @@ void main(List<String> args) async {
7076
printUsage();
7177
exit(1);
7278
}
73-
var debug = options['debug'] as bool;
79+
var debug = options['debug'] as bool ||
80+
options['observe'] as bool ||
81+
options.wasParsed('vm-service-port');
7482
var kernel = options['kernel'] as bool;
7583
var summarizeText = options['summarize-text'] as bool;
7684
var binary = options['binary'] as String;
@@ -109,8 +117,19 @@ void main(List<String> args) async {
109117
Future<void> runDdc(String command, List<String> args) async {
110118
if (debug) {
111119
// Use unbuilt script. This only works from a source checkout.
112-
args.insertAll(
113-
0, ['--enable-asserts', p.join(ddcPath, 'bin', '$command.dart')]);
120+
var vmServicePort = options.wasParsed('vm-service-port')
121+
? '=${options['vm-service-port']}'
122+
: '';
123+
var observe =
124+
options.wasParsed('vm-service-port') || options['observe'] as bool;
125+
args.insertAll(0, [
126+
if (observe) ...[
127+
'--enable-vm-service$vmServicePort',
128+
'--pause-isolates-on-start',
129+
],
130+
'--enable-asserts',
131+
p.join(ddcPath, 'bin', '$command.dart')
132+
]);
114133
command = dartBinary;
115134
} else {
116135
// Use built snapshot.

0 commit comments

Comments
 (0)