[frdp] Add optional dart isolate filter. (#22590)

* [frdp] Add optional dart isolate filter.

It's now default to filter out non-flutter isolates when searching
across Dart VM's.  This is due to a possible issue wherein an Isolate
for testing might have the same name as the flutter Isolate.

In addition, logging messages have been added in dart_vm.dart for
debugging.
This commit is contained in:
Andrew Davies
2018-10-05 12:31:05 -07:00
committed by GitHub
parent f7e0f83678
commit 39daab2900
2 changed files with 37 additions and 19 deletions

View File

@@ -120,16 +120,24 @@ class DartVm {
///
/// This is not limited to Isolates running Flutter, but to any Isolate on the
/// VM.
///
/// `includeNonFlutterIsolates` makes sure to add non-flutter Dart isolates,
/// and defaults to `false`.
Future<List<IsolateRef>> getMainIsolatesByPattern(
Pattern pattern, {
Duration timeout = _kRpcTimeout,
bool includeNonFlutterIsolates = false,
}) async {
final Map<String, dynamic> jsonVmRef =
await invokeRpc('getVM', timeout: timeout);
final List<IsolateRef> result = <IsolateRef>[];
for (Map<String, dynamic> jsonIsolate in jsonVmRef['isolates']) {
final String name = jsonIsolate['name'];
if (name.contains(pattern)) {
// `:main()` is included at the end of a flutter isolate, whereas the
// name of a dart Isolate is concluded as if the name were a function.
if (name.contains(pattern) &&
(includeNonFlutterIsolates || name.contains(RegExp(r':main\(\)')))) {
_log.fine('Found Isolate matching "$pattern": "$name"');
result.add(IsolateRef._fromJson(jsonIsolate, this));
}
}