[fuchsia] Fix isolate filter (#30458)
This commit is contained in:
parent
9fe6be8a65
commit
39ebae2bab
@ -128,24 +128,18 @@ class DartVm {
|
||||
/// Returns a [List] of [IsolateRef] objects whose name matches `pattern`.
|
||||
///
|
||||
/// 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`.
|
||||
/// VM. Therefore, the [pattern] argument should be written to exclude
|
||||
/// matching unintended isolates.
|
||||
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'];
|
||||
// `: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\(\)')))) {
|
||||
if (pattern.matchAsPrefix(name) != null) {
|
||||
_log.fine('Found Isolate matching "$pattern": "$name"');
|
||||
result.add(IsolateRef._fromJson(jsonIsolate, this));
|
||||
}
|
||||
|
@ -289,14 +289,10 @@ class FuchsiaRemoteConnection {
|
||||
/// If there are no live Dart VM's or the Isolate cannot be found, waits until
|
||||
/// either `timeout` is reached, or a Dart VM starts up with a name that
|
||||
/// matches `pattern`.
|
||||
///
|
||||
/// `includeNonFlutterIsolates` can be set to true to include all isolates
|
||||
/// found instead of just Flutter Isolates.
|
||||
Future<List<IsolateRef>> getMainIsolatesByPattern(
|
||||
Pattern pattern, {
|
||||
Duration timeout = _kIsolateFindTimeout,
|
||||
Duration vmConnectionTimeout = _kDartVmConnectionTimeout,
|
||||
bool includeNonFlutterIsolates = false,
|
||||
}) async {
|
||||
// If for some reason there are no Dart VM's that are alive, wait for one to
|
||||
// start with the Isolate in question.
|
||||
@ -315,10 +311,7 @@ class FuchsiaRemoteConnection {
|
||||
if (vmService == null) {
|
||||
continue;
|
||||
}
|
||||
isolates.add(vmService.getMainIsolatesByPattern(
|
||||
pattern,
|
||||
includeNonFlutterIsolates: includeNonFlutterIsolates,
|
||||
));
|
||||
isolates.add(vmService.getMainIsolatesByPattern(pattern));
|
||||
}
|
||||
final List<IsolateRef> result =
|
||||
await Future.wait<List<IsolateRef>>(isolates)
|
||||
|
@ -241,7 +241,7 @@ void main() {
|
||||
'type': '@Isolate',
|
||||
'fixedId': 'true',
|
||||
'id': 'isolates/3',
|
||||
'name': 'file://flutterBinary2:main()',
|
||||
'name': 'flutterBinary.cmx',
|
||||
'number': '3',
|
||||
},
|
||||
<String, dynamic>{
|
||||
@ -268,13 +268,9 @@ void main() {
|
||||
await DartVm.connect(Uri.parse('http://whatever.com/ws'));
|
||||
expect(vm, isNot(null));
|
||||
final List<IsolateRef> matchingFlutterIsolates =
|
||||
await vm.getMainIsolatesByPattern('flutterBinary');
|
||||
await vm.getMainIsolatesByPattern('flutterBinary.cmx');
|
||||
expect(matchingFlutterIsolates.length, 1);
|
||||
final List<IsolateRef> allFlutterIsolates =
|
||||
await vm.getMainIsolatesByPattern('');
|
||||
expect(allFlutterIsolates.length, 2);
|
||||
final List<IsolateRef> allIsolates = await vm.getMainIsolatesByPattern('',
|
||||
includeNonFlutterIsolates: true);
|
||||
final List<IsolateRef> allIsolates = await vm.getMainIsolatesByPattern('');
|
||||
expect(allIsolates.length, 4);
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user