mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 09:43:08 +00:00
Revert "Reland "[ VM / Service ] Add lookupResolvedPackageUri and lookupPackageUri RPCs""
This reverts commit6c6dd13b14
. Reason for revert: Still seeing test failures in some configurations Original change's description: > Reland "[ VM / Service ] Add lookupResolvedPackageUri and lookupPackageUri RPCs" > > This reverts commitaa25975644
. > > TEST=uri_mappings_lookup_test.dart > > Change-Id: I311e3130bc14a392cfc4b5d81afb137505c5c202 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218324 > Commit-Queue: Ben Konyi <bkonyi@google.com> > Reviewed-by: Siva Annamalai <asiva@google.com> TBR=bkonyi@google.com,asiva@google.com Change-Id: Ia69d9cfd7b395f692679fdfd185ef757550104bf No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218360 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
parent
cc7fcb5f70
commit
711fdcc0de
16 changed files with 12 additions and 546 deletions
|
@ -30,10 +30,6 @@ dynamic assertDynamic(dynamic obj) {
|
|||
return obj;
|
||||
}
|
||||
|
||||
List<dynamic> assertListOfDynamic(List<dynamic> list) {
|
||||
return list;
|
||||
}
|
||||
|
||||
List<int> assertListOfInt(List<int> list) {
|
||||
for (int elem in list) {
|
||||
assertInt(elem);
|
||||
|
@ -1150,12 +1146,6 @@ vms.UnresolvedSourceLocation assertUnresolvedSourceLocation(
|
|||
return obj;
|
||||
}
|
||||
|
||||
vms.UriList assertUriList(vms.UriList obj) {
|
||||
assertNotNull(obj);
|
||||
assertListOfDynamic(obj.uris!);
|
||||
return obj;
|
||||
}
|
||||
|
||||
vms.Version assertVersion(vms.Version obj) {
|
||||
assertNotNull(obj);
|
||||
assertInt(obj.major!);
|
||||
|
|
2
pkg/vm_service/java/.gitignore
vendored
2
pkg/vm_service/java/.gitignore
vendored
|
@ -43,7 +43,6 @@ src/org/dartlang/vm/service/consumer/SuccessConsumer.java
|
|||
src/org/dartlang/vm/service/consumer/TimelineConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/TimelineFlagsConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/TimestampConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/UriListConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/VMConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/VersionConsumer.java
|
||||
src/org/dartlang/vm/service/element/AllocationProfile.java
|
||||
|
@ -132,7 +131,6 @@ src/org/dartlang/vm/service/element/TypeArguments.java
|
|||
src/org/dartlang/vm/service/element/TypeArgumentsRef.java
|
||||
src/org/dartlang/vm/service/element/TypeParameters.java
|
||||
src/org/dartlang/vm/service/element/UnresolvedSourceLocation.java
|
||||
src/org/dartlang/vm/service/element/UriList.java
|
||||
src/org/dartlang/vm/service/element/VM.java
|
||||
src/org/dartlang/vm/service/element/VMRef.java
|
||||
src/org/dartlang/vm/service/element/Version.java
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015, the Dart project authors.
|
||||
*
|
||||
* Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.dartlang.vm.service.consumer;
|
||||
|
||||
// This is a generated file.
|
||||
|
||||
import org.dartlang.vm.service.element.ResolvedPackageUri;
|
||||
import org.dartlang.vm.service.element.Sentinel;
|
||||
|
||||
@SuppressWarnings({"WeakerAccess", "unused"})
|
||||
public interface ResolvePackageUriConsumer extends Consumer {
|
||||
void received(ResolvedPackageUri response);
|
||||
|
||||
void received(Sentinel response);
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015, the Dart project authors.
|
||||
*
|
||||
* Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.dartlang.vm.service.element;
|
||||
|
||||
// This is a generated file.
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
@SuppressWarnings({"WeakerAccess", "unused"})
|
||||
public class ResolvedPackageUri extends Response {
|
||||
public ResolvedPackageUri(JsonObject json) {
|
||||
super(json);
|
||||
}
|
||||
|
||||
/**
|
||||
* The file URI for a given package.
|
||||
*/
|
||||
public String getResolvedUri() {
|
||||
return getAsString("resolvedUri");
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
version=3.52
|
||||
version=3.51
|
||||
|
|
|
@ -26,7 +26,7 @@ export 'snapshot_graph.dart'
|
|||
HeapSnapshotObjectNoData,
|
||||
HeapSnapshotObjectNullData;
|
||||
|
||||
const String vmServiceVersion = '3.52.0';
|
||||
const String vmServiceVersion = '3.51.0';
|
||||
|
||||
/// @optional
|
||||
const String optional = 'optional';
|
||||
|
@ -186,7 +186,6 @@ Map<String, Function> _typeFactories = {
|
|||
'TypeArguments': TypeArguments.parse,
|
||||
'TypeParameters': TypeParameters.parse,
|
||||
'UnresolvedSourceLocation': UnresolvedSourceLocation.parse,
|
||||
'UriList': UriList.parse,
|
||||
'Version': Version.parse,
|
||||
'@VM': VMRef.parse,
|
||||
'VM': VM.parse,
|
||||
|
@ -227,8 +226,6 @@ Map<String, List<String>> _methodReturnTypes = {
|
|||
'getVMTimelineMicros': const ['Timestamp'],
|
||||
'pause': const ['Success'],
|
||||
'kill': const ['Success'],
|
||||
'lookupResolvedPackageUris': const ['UriList'],
|
||||
'lookupPackageUris': const ['UriList'],
|
||||
'registerService': const ['Success'],
|
||||
'reloadSources': const ['ReloadReport'],
|
||||
'removeBreakpoint': const ['Success'],
|
||||
|
@ -923,37 +920,6 @@ abstract class VmServiceInterface {
|
|||
/// returned.
|
||||
Future<Success> kill(String isolateId);
|
||||
|
||||
/// The `lookupResolvedPackageUris` RPC is used to convert a list of URIs to
|
||||
/// their resolved (or absolute) paths. For example, URIs passed to this RPC
|
||||
/// are mapped in the following ways:
|
||||
///
|
||||
/// - `dart:io` -> `org-dartlang-sdk:///sdk/lib/io/io.dart`
|
||||
/// - `package:test/test.dart` ->
|
||||
/// `file:///$PACKAGE_INSTALLATION_DIR/lib/test.dart`
|
||||
/// - `file:///foo/bar/bazz.dart` -> `file:///foo/bar/bazz.dart`
|
||||
///
|
||||
/// If a URI is not known, the corresponding entry in the [UriList] response
|
||||
/// will be `null`.
|
||||
///
|
||||
/// See [UriList].
|
||||
Future<UriList> lookupResolvedPackageUris(
|
||||
String isolateId, List<String> uris);
|
||||
|
||||
/// The `lookupPackageUris` RPC is used to convert a list of URIs to their
|
||||
/// unresolved paths. For example, URIs passed to this RPC are mapped in the
|
||||
/// following ways:
|
||||
///
|
||||
/// - `org-dartlang-sdk:///sdk/lib/io/io.dart` -> `dart:io`
|
||||
/// - `file:///$PACKAGE_INSTALLATION_DIR/lib/test.dart` ->
|
||||
/// `package:test/test.dart`
|
||||
/// - `file:///foo/bar/bazz.dart` -> `file:///foo/bar/bazz.dart`
|
||||
///
|
||||
/// If a URI is not known, the corresponding entry in the [UriList] response
|
||||
/// will be `null`.
|
||||
///
|
||||
/// See [UriList].
|
||||
Future<UriList> lookupPackageUris(String isolateId, List<String> uris);
|
||||
|
||||
/// Registers a service that can be invoked by other VM service clients, where
|
||||
/// `service` is the name of the service to advertise and `alias` is an
|
||||
/// alternative name for the registered service.
|
||||
|
@ -1502,18 +1468,6 @@ class VmServerConnection {
|
|||
params!['isolateId'],
|
||||
);
|
||||
break;
|
||||
case 'lookupResolvedPackageUris':
|
||||
response = await _serviceImplementation.lookupResolvedPackageUris(
|
||||
params!['isolateId'],
|
||||
List<String>.from(params['uris'] ?? []),
|
||||
);
|
||||
break;
|
||||
case 'lookupPackageUris':
|
||||
response = await _serviceImplementation.lookupPackageUris(
|
||||
params!['isolateId'],
|
||||
List<String>.from(params['uris'] ?? []),
|
||||
);
|
||||
break;
|
||||
case 'reloadSources':
|
||||
response = await _serviceImplementation.reloadSources(
|
||||
params!['isolateId'],
|
||||
|
@ -2024,16 +1978,6 @@ class VmService implements VmServiceInterface {
|
|||
Future<Success> kill(String isolateId) =>
|
||||
_call('kill', {'isolateId': isolateId});
|
||||
|
||||
@override
|
||||
Future<UriList> lookupResolvedPackageUris(
|
||||
String isolateId, List<String> uris) =>
|
||||
_call(
|
||||
'lookupResolvedPackageUris', {'isolateId': isolateId, 'uris': uris});
|
||||
|
||||
@override
|
||||
Future<UriList> lookupPackageUris(String isolateId, List<String> uris) =>
|
||||
_call('lookupPackageUris', {'isolateId': isolateId, 'uris': uris});
|
||||
|
||||
@override
|
||||
Future<Success> registerService(String service, String alias) =>
|
||||
_call('registerService', {'service': service, 'alias': alias});
|
||||
|
@ -6168,8 +6112,9 @@ class MemoryUsage extends Response {
|
|||
/// example, memory associated with Dart objects through APIs such as
|
||||
/// Dart_NewFinalizableHandle, Dart_NewWeakPersistentHandle and
|
||||
/// Dart_NewExternalTypedData. This usage is only as accurate as the values
|
||||
/// supplied to these APIs from the VM embedder. This external memory applies
|
||||
/// GC pressure, but is separate from heapUsage and heapCapacity.
|
||||
/// supplied to these APIs from the VM embedder or native extensions. This
|
||||
/// external memory applies GC pressure, but is separate from heapUsage and
|
||||
/// heapCapacity.
|
||||
int? externalUsage;
|
||||
|
||||
/// The total capacity of the heap in bytes. This is the amount of memory used
|
||||
|
@ -7931,38 +7876,6 @@ class UnresolvedSourceLocation extends Response {
|
|||
String toString() => '[UnresolvedSourceLocation]';
|
||||
}
|
||||
|
||||
class UriList extends Response {
|
||||
static UriList? parse(Map<String, dynamic>? json) =>
|
||||
json == null ? null : UriList._fromJson(json);
|
||||
|
||||
/// A list of URIs.
|
||||
List<dynamic>? uris;
|
||||
|
||||
UriList({
|
||||
required this.uris,
|
||||
});
|
||||
|
||||
UriList._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
|
||||
uris = List<dynamic>.from(
|
||||
createServiceObject(json['uris'], const ['dynamic']) as List? ?? []);
|
||||
}
|
||||
|
||||
@override
|
||||
String get type => 'UriList';
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
json['type'] = type;
|
||||
json.addAll({
|
||||
'uris': uris?.map((f) => f.toJson()).toList(),
|
||||
});
|
||||
return json;
|
||||
}
|
||||
|
||||
String toString() => '[UriList uris: ${uris}]';
|
||||
}
|
||||
|
||||
/// See [Versioning].
|
||||
class Version extends Response {
|
||||
static Version? parse(Map<String, dynamic>? json) =>
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
import 'package:vm_service/vm_service.dart';
|
||||
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
(VmService service, IsolateRef isolate) async {
|
||||
final isolateId = isolate.id!;
|
||||
final unresolvedUris = <String>[
|
||||
'dart:io', // dart:io -> org-dartlang-sdk:///sdk/lib/io/io.dart
|
||||
Platform.script.toString(), // file:///abc.dart -> file:///abc.dart
|
||||
'package:test/test.dart', // package:test/test.dart -> file:///some_dir/test/lib/test.dart
|
||||
'package:does_not_exist/does_not_exist.dart', // invalid URI -> null
|
||||
];
|
||||
|
||||
var result = await service.lookupResolvedPackageUris(
|
||||
isolateId,
|
||||
unresolvedUris,
|
||||
);
|
||||
expect(result.uris, isNotNull);
|
||||
var uris = result.uris!;
|
||||
expect(uris.length, 4);
|
||||
expect(uris[0], 'org-dartlang-sdk:///sdk/lib/io/io.dart');
|
||||
expect(uris[1], Platform.script.toString());
|
||||
expect(uris[2], startsWith('file:///'));
|
||||
expect(uris[2], endsWith('third_party/pkg/test/pkgs/test/lib/test.dart'));
|
||||
expect(uris[3], isNull);
|
||||
|
||||
result = await service.lookupPackageUris(
|
||||
isolateId,
|
||||
[
|
||||
...uris.sublist(0, 3),
|
||||
'does_not_exist.dart',
|
||||
],
|
||||
);
|
||||
expect(result.uris, isNotNull);
|
||||
uris = result.uris!;
|
||||
expect(uris.length, 4);
|
||||
expect(uris[0], unresolvedUris[0]);
|
||||
expect(uris[1], unresolvedUris[1]);
|
||||
expect(uris[2], unresolvedUris[2]);
|
||||
expect(uris[3], isNull);
|
||||
},
|
||||
];
|
||||
|
||||
void main(args) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'uri_mappings_lookup_test.dart',
|
||||
);
|
|
@ -12,7 +12,7 @@ var tests = <VMTest>[
|
|||
final result = await vm.invokeRpcNoUpgrade('getVersion', {});
|
||||
expect(result['type'], 'Version');
|
||||
expect(result['major'], 3);
|
||||
expect(result['minor'], 52);
|
||||
expect(result['minor'], 51);
|
||||
expect(result['_privateMajor'], 0);
|
||||
expect(result['_privateMinor'], 0);
|
||||
},
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:observatory/service_io.dart';
|
||||
// Already a dependency of package:test.
|
||||
import 'package:pool/pool.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'test_helper.dart';
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
(Isolate isolate) async {
|
||||
final scriptUri =
|
||||
'file://${Directory.current.path}/runtime/observatory/tests/service/uri_mappings_lookup_test.dart';
|
||||
final unresolvedUris = <String>[
|
||||
'package:does_not_exist/does_not_exist.dart', // invalid URI -> null
|
||||
'dart:io', // dart:io -> org-dartlang-sdk:///sdk/lib/io/io.dart
|
||||
'package:pool/pool.dart', // package:pool/pool.dart -> file:///some_dir/pool/lib/pool.dart
|
||||
scriptUri, // file:///abc.dart -> file:///abc.dart
|
||||
];
|
||||
|
||||
var result = await isolate.invokeRpcNoUpgrade('lookupResolvedPackageUris', {
|
||||
'uris': unresolvedUris,
|
||||
});
|
||||
expect(result['uris'], isNotNull);
|
||||
var uris = result['uris'].cast<String?>();
|
||||
expect(uris.length, 4);
|
||||
expect(uris[0], isNull);
|
||||
expect(uris[1], 'org-dartlang-sdk:///sdk/lib/io/io.dart');
|
||||
expect(uris[2], startsWith('file:///'));
|
||||
expect(uris[2], endsWith('third_party/pkg/pool/lib/pool.dart'));
|
||||
expect(uris[3], scriptUri);
|
||||
|
||||
result = await isolate.invokeRpcNoUpgrade('lookupPackageUris', {
|
||||
'uris': [
|
||||
'does_not_exist.dart',
|
||||
...uris.sublist(1, 4),
|
||||
]
|
||||
});
|
||||
expect(result['uris'], isNotNull);
|
||||
uris = result['uris'].cast<String?>();
|
||||
expect(uris.length, 4);
|
||||
expect(uris[0], isNull);
|
||||
expect(uris[1], unresolvedUris[1]);
|
||||
expect(uris[2], unresolvedUris[2]);
|
||||
expect(uris[3], unresolvedUris[3]);
|
||||
},
|
||||
];
|
||||
|
||||
void main(args) => runIsolateTests(args, tests);
|
|
@ -12,7 +12,7 @@ var tests = <VMTest>[
|
|||
final result = await vm.invokeRpcNoUpgrade('getVersion', {});
|
||||
expect(result['type'], equals('Version'));
|
||||
expect(result['major'], equals(3));
|
||||
expect(result['minor'], equals(52));
|
||||
expect(result['minor'], equals(51));
|
||||
expect(result['_privateMajor'], equals(0));
|
||||
expect(result['_privateMinor'], equals(0));
|
||||
},
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:observatory_2/service_io.dart';
|
||||
// Already a dependency of package:test.
|
||||
import 'package:pool/pool.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'test_helper.dart';
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
(Isolate isolate) async {
|
||||
final scriptUri =
|
||||
'file://${Directory.current.path}/runtime/observatory_2/tests/service_2/uri_mappings_lookup_test.dart';
|
||||
final unresolvedUris = <String>[
|
||||
'package:does_not_exist/does_not_exist.dart', // invalid URI -> null
|
||||
'dart:io', // dart:io -> org-dartlang-sdk:///sdk/lib/io/io.dart
|
||||
'package:pool/pool.dart', // package:pool/pool.dart -> file:///some_dir/pool/lib/pool.dart
|
||||
scriptUri, // file:///abc.dart -> file:///abc.dart
|
||||
];
|
||||
|
||||
var result = await isolate.invokeRpcNoUpgrade('lookupResolvedPackageUris', {
|
||||
'uris': unresolvedUris,
|
||||
});
|
||||
expect(result['uris'], isNotNull);
|
||||
var uris = result['uris'].cast<String>();
|
||||
expect(uris.length, 4);
|
||||
expect(uris[0], isNull);
|
||||
expect(uris[1], 'org-dartlang-sdk:///sdk/lib/io/io.dart');
|
||||
expect(uris[2], startsWith('file:///'));
|
||||
expect(uris[2], endsWith('third_party/pkg/pool/lib/pool.dart'));
|
||||
expect(uris[3], scriptUri);
|
||||
|
||||
result = await isolate.invokeRpcNoUpgrade('lookupPackageUris', {
|
||||
'uris': [
|
||||
'does_not_exist.dart',
|
||||
...uris.sublist(1, 4),
|
||||
]
|
||||
});
|
||||
expect(result['uris'], isNotNull);
|
||||
uris = result['uris'].cast<String>();
|
||||
expect(uris.length, 4);
|
||||
expect(uris[0], isNull);
|
||||
expect(uris[1], unresolvedUris[1]);
|
||||
expect(uris[2], unresolvedUris[2]);
|
||||
expect(uris[3], unresolvedUris[3]);
|
||||
},
|
||||
];
|
||||
|
||||
void main(args) => runIsolateTests(args, tests);
|
|
@ -830,11 +830,6 @@ bool IsolateGroupReloadContext::Reload(bool force_reload,
|
|||
success = false;
|
||||
}
|
||||
|
||||
Array& null_array = Array::Handle(Z);
|
||||
// Invalidate the URI mapping caches.
|
||||
IG->object_store()->set_uri_to_resolved_uri_map(null_array);
|
||||
IG->object_store()->set_resolved_uri_to_uri_map(null_array);
|
||||
|
||||
// Re-queue any shutdown requests so they can inform each isolate's own thread
|
||||
// to shut down.
|
||||
if (result.IsUnwindError()) {
|
||||
|
|
|
@ -143,9 +143,6 @@ class ObjectPointerVisitor;
|
|||
RW(Library, _vmservice_library) \
|
||||
RW(GrowableObjectArray, libraries) \
|
||||
RW(Array, libraries_map) \
|
||||
RW(Array, uri_to_resolved_uri_map) \
|
||||
RW(Array, resolved_uri_to_uri_map) \
|
||||
RW(Smi, last_libraries_count) \
|
||||
RW(Array, loading_units) \
|
||||
RW(GrowableObjectArray, closure_functions) \
|
||||
RW(GrowableObjectArray, pending_classes) \
|
||||
|
|
|
@ -4948,159 +4948,6 @@ static void GetVM(Thread* thread, JSONStream* js) {
|
|||
Service::PrintJSONForVM(js, false);
|
||||
}
|
||||
|
||||
static intptr_t ParseJSONArray(Thread* thread,
|
||||
const char* str,
|
||||
const GrowableObjectArray& elements) {
|
||||
ASSERT(str != nullptr);
|
||||
ASSERT(thread != nullptr);
|
||||
Zone* zone = thread->zone();
|
||||
intptr_t n = strlen(str);
|
||||
if (n < 2) {
|
||||
return -1;
|
||||
}
|
||||
intptr_t start = 1;
|
||||
while (start < n) {
|
||||
intptr_t end = start;
|
||||
while ((str[end + 1] != ',') && (str[end + 1] != ']')) {
|
||||
end++;
|
||||
}
|
||||
if (end == start) {
|
||||
// Empty element
|
||||
break;
|
||||
}
|
||||
String& element = String::Handle(
|
||||
zone, String::FromUTF8(reinterpret_cast<const uint8_t*>(&str[start]),
|
||||
end - start + 1));
|
||||
elements.Add(element);
|
||||
start = end + 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
class UriMappingTraits {
|
||||
public:
|
||||
static const char* Name() { return "UriMappingTraits"; }
|
||||
static bool ReportStats() { return false; }
|
||||
|
||||
static bool IsMatch(const Object& a, const Object& b) {
|
||||
const String& a_str = String::Cast(a);
|
||||
const String& b_str = String::Cast(b);
|
||||
|
||||
ASSERT(a_str.HasHash() && b_str.HasHash());
|
||||
return a_str.Equals(b_str);
|
||||
}
|
||||
|
||||
static uword Hash(const Object& key) { return String::Cast(key).Hash(); }
|
||||
|
||||
static ObjectPtr NewKey(const String& str) { return str.ptr(); }
|
||||
};
|
||||
|
||||
typedef UnorderedHashMap<UriMappingTraits> UriMapping;
|
||||
|
||||
static void PopulateUriMappings(Thread* thread) {
|
||||
Zone* zone = thread->zone();
|
||||
auto object_store = thread->isolate_group()->object_store();
|
||||
UriMapping uri_to_resolved_uri(HashTables::New<UriMapping>(16, Heap::kOld));
|
||||
UriMapping resolved_uri_to_uri(HashTables::New<UriMapping>(16, Heap::kOld));
|
||||
|
||||
const auto& libs =
|
||||
GrowableObjectArray::Handle(zone, object_store->libraries());
|
||||
intptr_t num_libs = libs.Length();
|
||||
|
||||
Library& lib = Library::Handle(zone);
|
||||
Script& script = Script::Handle(zone);
|
||||
Array& scripts = Array::Handle(zone);
|
||||
String& uri = String::Handle(zone);
|
||||
String& resolved_uri = String::Handle(zone);
|
||||
|
||||
for (intptr_t i = 0; i < num_libs; ++i) {
|
||||
lib ^= libs.At(i);
|
||||
scripts ^= lib.LoadedScripts();
|
||||
intptr_t num_scripts = scripts.Length();
|
||||
for (intptr_t j = 0; j < num_scripts; ++j) {
|
||||
script ^= scripts.At(j);
|
||||
uri ^= script.url();
|
||||
resolved_uri ^= script.resolved_url();
|
||||
uri_to_resolved_uri.UpdateOrInsert(uri, resolved_uri);
|
||||
resolved_uri_to_uri.UpdateOrInsert(resolved_uri, uri);
|
||||
}
|
||||
}
|
||||
|
||||
object_store->set_uri_to_resolved_uri_map(uri_to_resolved_uri.Release());
|
||||
object_store->set_resolved_uri_to_uri_map(resolved_uri_to_uri.Release());
|
||||
Smi& count = Smi::Handle(zone, Smi::New(num_libs));
|
||||
object_store->set_last_libraries_count(count);
|
||||
}
|
||||
|
||||
static void LookupScriptUrisImpl(Thread* thread,
|
||||
JSONStream* js,
|
||||
bool lookup_resolved) {
|
||||
Zone* zone = thread->zone();
|
||||
auto object_store = thread->isolate_group()->object_store();
|
||||
|
||||
const auto& libs =
|
||||
GrowableObjectArray::Handle(zone, object_store->libraries());
|
||||
Smi& last_libraries_count =
|
||||
Smi::Handle(zone, object_store->last_libraries_count());
|
||||
if ((object_store->uri_to_resolved_uri_map() == Array::null()) ||
|
||||
(object_store->resolved_uri_to_uri_map() == Array::null()) ||
|
||||
(last_libraries_count.Value() != libs.Length())) {
|
||||
PopulateUriMappings(thread);
|
||||
}
|
||||
const char* uris_arg = js->LookupParam("uris");
|
||||
if (uris_arg == nullptr) {
|
||||
PrintMissingParamError(js, "uris");
|
||||
return;
|
||||
}
|
||||
|
||||
const GrowableObjectArray& uris =
|
||||
GrowableObjectArray::Handle(zone, GrowableObjectArray::New());
|
||||
intptr_t uris_length = ParseJSONArray(thread, uris_arg, uris);
|
||||
if (uris_length < 0) {
|
||||
PrintInvalidParamError(js, "uris");
|
||||
return;
|
||||
}
|
||||
|
||||
UriMapping map(lookup_resolved ? object_store->uri_to_resolved_uri_map()
|
||||
: object_store->resolved_uri_to_uri_map());
|
||||
JSONObject jsobj(js);
|
||||
jsobj.AddProperty("type", "UriList");
|
||||
|
||||
{
|
||||
JSONArray uris_array(&jsobj, "uris");
|
||||
String& uri = String::Handle(zone);
|
||||
String& res = String::Handle(zone);
|
||||
for (intptr_t i = 0; i < uris.Length(); ++i) {
|
||||
uri ^= uris.At(i);
|
||||
res ^= map.GetOrNull(uri);
|
||||
if (res.IsNull()) {
|
||||
uris_array.AddValueNull();
|
||||
} else {
|
||||
uris_array.AddValue(res.ToCString());
|
||||
}
|
||||
}
|
||||
}
|
||||
map.Release();
|
||||
}
|
||||
|
||||
static const MethodParameter* const lookup_resolved_package_uris_params[] = {
|
||||
ISOLATE_PARAMETER,
|
||||
nullptr,
|
||||
};
|
||||
|
||||
static void LookupResolvedPackageUris(Thread* thread, JSONStream* js) {
|
||||
LookupScriptUrisImpl(thread, js, true);
|
||||
}
|
||||
|
||||
static const MethodParameter* const lookup_package_uris_params[] = {
|
||||
ISOLATE_PARAMETER,
|
||||
nullptr,
|
||||
};
|
||||
|
||||
static void LookupPackageUris(Thread* thread, JSONStream* js) {
|
||||
LookupScriptUrisImpl(thread, js, false);
|
||||
}
|
||||
|
||||
static const char* const exception_pause_mode_names[] = {
|
||||
"All",
|
||||
"None",
|
||||
|
@ -5512,10 +5359,6 @@ static const ServiceMethodDescriptor service_methods_[] = {
|
|||
get_reachable_size_params },
|
||||
{ "_getRetainedSize", GetRetainedSize,
|
||||
get_retained_size_params },
|
||||
{ "lookupResolvedPackageUris", LookupResolvedPackageUris,
|
||||
lookup_resolved_package_uris_params },
|
||||
{ "lookupPackageUris", LookupPackageUris,
|
||||
lookup_package_uris_params },
|
||||
{ "getRetainingPath", GetRetainingPath,
|
||||
get_retaining_path_params },
|
||||
{ "getScripts", GetScripts,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
namespace dart {
|
||||
|
||||
#define SERVICE_PROTOCOL_MAJOR_VERSION 3
|
||||
#define SERVICE_PROTOCOL_MINOR_VERSION 52
|
||||
#define SERVICE_PROTOCOL_MINOR_VERSION 51
|
||||
|
||||
class Array;
|
||||
class EmbedderServiceHandler;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Dart VM Service Protocol 3.52
|
||||
# Dart VM Service Protocol 3.51
|
||||
|
||||
> Please post feedback to the [observatory-discuss group][discuss-list]
|
||||
|
||||
This document describes of _version 3.52_ of the Dart VM Service Protocol. This
|
||||
This document describes of _version 3.51_ of the Dart VM Service Protocol. This
|
||||
protocol is used to communicate with a running Dart Virtual Machine.
|
||||
|
||||
To use the Service Protocol, start the VM with the *--observe* flag.
|
||||
|
@ -62,8 +62,6 @@ The Service Protocol uses [JSON-RPC 2.0][].
|
|||
- [getVMTimelineFlags](#getvmtimelineflags)
|
||||
- [getVMTimelineMicros](#getvmtimelinemicros)
|
||||
- [invoke](#invoke)
|
||||
- [lookupResolvedPackageUris](#lookupresolvedpackageuris)
|
||||
- [lookupPackageUris](#lookuppackageuris)
|
||||
- [pause](#pause)
|
||||
- [kill](#kill)
|
||||
- [registerService](#registerService)
|
||||
|
@ -144,8 +142,7 @@ The Service Protocol uses [JSON-RPC 2.0][].
|
|||
- [Timestamp](#timestamp)
|
||||
- [TypeArguments](#typearguments)
|
||||
- [TypeParameters](#typeparameters)[
|
||||
- [UnresolvedSourceLocation](#unresolvedsourcelocation)
|
||||
- [UriList](#urilist)
|
||||
- [UresolvedSourceLocation](#unresolvedsourcelocation)
|
||||
- [Version](#version)
|
||||
- [VM](#vm)
|
||||
- [WebSocketTarget](#websockettarget)
|
||||
|
@ -1210,44 +1207,6 @@ _Collected_ [Sentinel](#sentinel) is returned.
|
|||
|
||||
See [Success](#success).
|
||||
|
||||
### lookupResolvedPackageUris
|
||||
|
||||
```
|
||||
UriList lookupResolvedPackageUris(string isolateId, string[] uris)
|
||||
```
|
||||
|
||||
The _lookupResolvedPackageUris_ RPC is used to convert a list of URIs to their
|
||||
resolved (or absolute) paths. For example, URIs passed to this RPC are mapped in
|
||||
the following ways:
|
||||
|
||||
- `dart:io` -> `org-dartlang-sdk:///sdk/lib/io/io.dart`
|
||||
- `package:test/test.dart` -> `file:///$PACKAGE_INSTALLATION_DIR/lib/test.dart`
|
||||
- `file:///foo/bar/bazz.dart` -> `file:///foo/bar/bazz.dart`
|
||||
|
||||
If a URI is not known, the corresponding entry in the [UriList] response will be
|
||||
`null`.
|
||||
|
||||
See [UriList](#urilist).
|
||||
|
||||
### lookupPackageUris
|
||||
|
||||
```
|
||||
UriList lookupPackageUris(string isolateId, string[] uris)
|
||||
```
|
||||
|
||||
The _lookupPackageUris_ RPC is used to convert a list of URIs to their
|
||||
unresolved paths. For example, URIs passed to this RPC are mapped in the
|
||||
following ways:
|
||||
|
||||
- `org-dartlang-sdk:///sdk/lib/io/io.dart` -> `dart:io`
|
||||
- `file:///$PACKAGE_INSTALLATION_DIR/lib/test.dart` -> `package:test/test.dart`
|
||||
- `file:///foo/bar/bazz.dart` -> `file:///foo/bar/bazz.dart`
|
||||
|
||||
If a URI is not known, the corresponding entry in the [UriList] response will be
|
||||
`null`.
|
||||
|
||||
See [UriList](#urilist).
|
||||
|
||||
### registerService
|
||||
|
||||
```
|
||||
|
@ -4098,15 +4057,6 @@ Either the _tokenPos_ or the _line_ field will be present.
|
|||
The _column_ field will only be present when the breakpoint was
|
||||
specified with a specific column number.
|
||||
|
||||
### UriList
|
||||
|
||||
```
|
||||
class UriList extends Response {
|
||||
// A list of URIs.
|
||||
(string|Null)[] uris;
|
||||
}
|
||||
```
|
||||
|
||||
### Version
|
||||
|
||||
```
|
||||
|
@ -4234,5 +4184,5 @@ version | comments
|
|||
3.49 | Added `CpuSamples` event kind, and `cpuSamples` property to `Event`.
|
||||
3.50 | Added `returnType`, `parameters`, and `typeParameters` to `@Instance`, and `implicit` to `@Function`. Added `Parameter` type.
|
||||
3.51 | Added optional `reportLines` parameter to `getSourceReport` RPC.
|
||||
3.52 | Added `lookupResolvedPackageUris` and `lookupPackageUris` RPCs and `UriList` type.
|
||||
|
||||
[discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observatory-discuss
|
||||
|
|
Loading…
Reference in a new issue