[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:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user