[VM/Service] Add isolateGroup property to Event
TEST=reload_sources_rpc_triggers_isolate_reload_event_test.dart Change-Id: I0669d09461f147226f1dd2a598896e9a6b44d9b0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308221 Commit-Queue: Derek Xu <derekx@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
version=4.8
|
||||
version=4.9
|
||||
|
||||
@@ -28,7 +28,7 @@ export 'snapshot_graph.dart'
|
||||
HeapSnapshotObjectNoData,
|
||||
HeapSnapshotObjectNullData;
|
||||
|
||||
const String vmServiceVersion = '4.8.0';
|
||||
const String vmServiceVersion = '4.9.0';
|
||||
|
||||
/// @optional
|
||||
const String optional = 'optional';
|
||||
@@ -4319,10 +4319,19 @@ class Event extends Response {
|
||||
/// What kind of event is this?
|
||||
/*EventKind*/ String? kind;
|
||||
|
||||
/// The isolate group with which this event is associated.
|
||||
///
|
||||
/// This is provided for all event kinds except for:
|
||||
/// - VMUpdate, VMFlagUpdate, TimelineStreamSubscriptionsUpdate,
|
||||
/// TimelineEvents
|
||||
@optional
|
||||
IsolateGroupRef? isolateGroup;
|
||||
|
||||
/// The isolate with which this event is associated.
|
||||
///
|
||||
/// This is provided for all event kinds except for:
|
||||
/// - VMUpdate, VMFlagUpdate
|
||||
/// - VMUpdate, VMFlagUpdate, TimelineStreamSubscriptionsUpdate,
|
||||
/// - TimelineEvents, IsolateReload
|
||||
@optional
|
||||
IsolateRef? isolate;
|
||||
|
||||
@@ -4520,6 +4529,7 @@ class Event extends Response {
|
||||
Event({
|
||||
this.kind,
|
||||
this.timestamp,
|
||||
this.isolateGroup,
|
||||
this.isolate,
|
||||
this.vm,
|
||||
this.breakpoint,
|
||||
@@ -4551,6 +4561,9 @@ class Event extends Response {
|
||||
|
||||
Event._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
|
||||
kind = json['kind'] ?? '';
|
||||
isolateGroup =
|
||||
createServiceObject(json['isolateGroup'], const ['IsolateGroupRef'])
|
||||
as IsolateGroupRef?;
|
||||
isolate = createServiceObject(json['isolate'], const ['IsolateRef'])
|
||||
as IsolateRef?;
|
||||
vm = createServiceObject(json['vm'], const ['VMRef']) as VMRef?;
|
||||
@@ -4608,6 +4621,7 @@ class Event extends Response {
|
||||
'kind': kind ?? '',
|
||||
'timestamp': timestamp ?? -1,
|
||||
});
|
||||
_setIfNotNull(json, 'isolateGroup', isolateGroup?.toJson());
|
||||
_setIfNotNull(json, 'isolate', isolate?.toJson());
|
||||
_setIfNotNull(json, 'vm', vm?.toJson());
|
||||
_setIfNotNull(json, 'breakpoint', breakpoint?.toJson());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
import 'package:vm_service/vm_service.dart';
|
||||
|
||||
import 'common/test_helper.dart';
|
||||
@@ -20,6 +21,7 @@ final tests = <IsolateTest>[
|
||||
late final StreamSubscription subscription;
|
||||
subscription = service.onIsolateEvent.listen((event) {
|
||||
if (event.kind == EventKind.kIsolateReload) {
|
||||
expect(event.isolateGroup!.id, isolateRef.isolateGroupId);
|
||||
subscription.cancel();
|
||||
service.streamCancel(EventStreams.kIsolate);
|
||||
completer.complete();
|
||||
|
||||
@@ -12,7 +12,7 @@ var tests = <VMTest>[
|
||||
final result = await vm.invokeRpcNoUpgrade('getVersion', {});
|
||||
expect(result['type'], 'Version');
|
||||
expect(result['major'], 4);
|
||||
expect(result['minor'], 8);
|
||||
expect(result['minor'], 9);
|
||||
expect(result['_privateMajor'], 0);
|
||||
expect(result['_privateMinor'], 0);
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@ var tests = <VMTest>[
|
||||
final result = await vm.invokeRpcNoUpgrade('getVersion', {});
|
||||
expect(result['type'], equals('Version'));
|
||||
expect(result['major'], equals(4));
|
||||
expect(result['minor'], equals(8));
|
||||
expect(result['minor'], equals(9));
|
||||
expect(result['_privateMajor'], equals(0));
|
||||
expect(result['_privateMinor'], equals(0));
|
||||
},
|
||||
|
||||
@@ -412,6 +412,12 @@ void JSONStream::PrintProperty(const char* name, Isolate* isolate) {
|
||||
PrintValue(isolate);
|
||||
}
|
||||
|
||||
void JSONStream::PrintProperty(const char* name, IsolateGroup* isolate_group) {
|
||||
PRIVATE_NAME_CHECK();
|
||||
PrintPropertyName(name);
|
||||
PrintValue(isolate_group);
|
||||
}
|
||||
|
||||
void JSONStream::PrintProperty(const char* name,
|
||||
const TimelineEvent* timeline_event) {
|
||||
PRIVATE_NAME_CHECK();
|
||||
|
||||
@@ -330,6 +330,7 @@ class JSONStream : ValueObject {
|
||||
void PrintProperty(const char* name, Metric* metric);
|
||||
void PrintProperty(const char* name, MessageQueue* queue);
|
||||
void PrintProperty(const char* name, Isolate* isolate);
|
||||
void PrintProperty(const char* name, IsolateGroup* isolate_group);
|
||||
void PrintProperty(const char* name, Zone* zone);
|
||||
void PrintProperty(const char* name, const TimelineEvent* timeline_event);
|
||||
void PrintProperty(const char* name,
|
||||
@@ -447,6 +448,9 @@ class JSONObject : public ValueObject {
|
||||
void AddProperty(const char* name, Isolate* isolate) const {
|
||||
stream_->PrintProperty(name, isolate);
|
||||
}
|
||||
void AddProperty(const char* name, IsolateGroup* isolate_group) const {
|
||||
stream_->PrintProperty(name, isolate_group);
|
||||
}
|
||||
void AddProperty(const char* name, Zone* zone) const {
|
||||
stream_->PrintProperty(name, zone);
|
||||
}
|
||||
|
||||
+20
-10
@@ -1243,11 +1243,12 @@ void Service::HandleEvent(ServiceEvent* event, bool enter_safepoint) {
|
||||
params.AddProperty("streamId", stream_id);
|
||||
params.AddProperty("event", event);
|
||||
}
|
||||
PostEvent(event->isolate(), stream_id, event->KindAsCString(), &js,
|
||||
enter_safepoint);
|
||||
PostEvent(event->isolate_group(), event->isolate(), stream_id,
|
||||
event->KindAsCString(), &js, enter_safepoint);
|
||||
}
|
||||
|
||||
void Service::PostEvent(Isolate* isolate,
|
||||
void Service::PostEvent(IsolateGroup* isolate_group,
|
||||
Isolate* isolate,
|
||||
const char* stream_id,
|
||||
const char* kind,
|
||||
JSONStream* event,
|
||||
@@ -1256,13 +1257,14 @@ void Service::PostEvent(Isolate* isolate,
|
||||
// Enter a safepoint so we don't block the mutator while processing
|
||||
// large events.
|
||||
TransitionToNative transition(Thread::Current());
|
||||
PostEventImpl(isolate, stream_id, kind, event);
|
||||
PostEventImpl(isolate_group, isolate, stream_id, kind, event);
|
||||
return;
|
||||
}
|
||||
PostEventImpl(isolate, stream_id, kind, event);
|
||||
PostEventImpl(isolate_group, isolate, stream_id, kind, event);
|
||||
}
|
||||
|
||||
void Service::PostEventImpl(Isolate* isolate,
|
||||
void Service::PostEventImpl(IsolateGroup* isolate_group,
|
||||
Isolate* isolate,
|
||||
const char* stream_id,
|
||||
const char* kind,
|
||||
JSONStream* event) {
|
||||
@@ -1272,12 +1274,20 @@ void Service::PostEventImpl(Isolate* isolate,
|
||||
|
||||
if (FLAG_trace_service) {
|
||||
if (isolate != nullptr) {
|
||||
ASSERT(isolate_group != nullptr);
|
||||
OS::PrintErr(
|
||||
"vm-service: Pushing ServiceEvent(isolate='%s', "
|
||||
"isolateId='" ISOLATE_SERVICE_ID_FORMAT_STRING
|
||||
"vm-service: Pushing "
|
||||
"ServiceEvent(isolateGroupId='" ISOLATE_GROUP_SERVICE_ID_FORMAT_STRING
|
||||
"', isolate='%s', isolateId='" ISOLATE_SERVICE_ID_FORMAT_STRING
|
||||
"', kind='%s') to stream %s\n",
|
||||
isolate->name(), static_cast<int64_t>(isolate->main_port()), kind,
|
||||
stream_id);
|
||||
isolate_group->id(), isolate->name(),
|
||||
static_cast<int64_t>(isolate->main_port()), kind, stream_id);
|
||||
} else if (isolate_group != nullptr) {
|
||||
OS::PrintErr(
|
||||
"vm-service: Pushing "
|
||||
"ServiceEvent(isolateGroupId='" ISOLATE_GROUP_SERVICE_ID_FORMAT_STRING
|
||||
"', kind='%s') to stream %s\n",
|
||||
isolate_group->id(), kind, stream_id);
|
||||
} else {
|
||||
OS::PrintErr(
|
||||
"vm-service: Pushing ServiceEvent(isolate='<no current isolate>', "
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
namespace dart {
|
||||
|
||||
#define SERVICE_PROTOCOL_MAJOR_VERSION 4
|
||||
#define SERVICE_PROTOCOL_MINOR_VERSION 8
|
||||
#define SERVICE_PROTOCOL_MINOR_VERSION 9
|
||||
|
||||
class Array;
|
||||
class EmbedderServiceHandler;
|
||||
@@ -241,13 +241,15 @@ class Service : public AllStatic {
|
||||
uint8_t* bytes,
|
||||
intptr_t bytes_length);
|
||||
|
||||
static void PostEvent(Isolate* isolate,
|
||||
static void PostEvent(IsolateGroup* isolate_group,
|
||||
Isolate* isolate,
|
||||
const char* stream_id,
|
||||
const char* kind,
|
||||
JSONStream* event,
|
||||
bool enter_safepoint);
|
||||
|
||||
static void PostEventImpl(Isolate* isolate,
|
||||
static void PostEventImpl(IsolateGroup* isolate_group,
|
||||
Isolate* isolate,
|
||||
const char* stream_id,
|
||||
const char* kind,
|
||||
JSONStream* event);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Dart VM Service Protocol 4.8
|
||||
# Dart VM Service Protocol 4.9
|
||||
|
||||
> Please post feedback to the [observatory-discuss group][discuss-list]
|
||||
|
||||
This document describes of _version 4.8_ of the Dart VM Service Protocol. This
|
||||
This document describes of _version 4.9_ 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.
|
||||
@@ -2322,10 +2322,17 @@ class Event extends Response {
|
||||
// What kind of event is this?
|
||||
EventKind kind;
|
||||
|
||||
// The isolate group with which this event is associated.
|
||||
//
|
||||
// This is provided for all event kinds except for:
|
||||
// VMUpdate, VMFlagUpdate, TimelineStreamSubscriptionsUpdate, TimelineEvents
|
||||
@IsolateGroup isolateGroup [optional];
|
||||
|
||||
// The isolate with which this event is associated.
|
||||
//
|
||||
// This is provided for all event kinds except for:
|
||||
// VMUpdate, VMFlagUpdate
|
||||
// VMUpdate, VMFlagUpdate, TimelineStreamSubscriptionsUpdate,
|
||||
// TimelineEvents, IsolateReload
|
||||
@Isolate isolate [optional];
|
||||
|
||||
// The vm with which this event is associated.
|
||||
@@ -4692,5 +4699,6 @@ version | comments
|
||||
4.6 | Added `getPerfettoCpuSamples` RPC. Added a deprecation notice to `InstanceKind.TypeRef`.
|
||||
4.7 | Added a deprecation notice to `Stack.awaiterFrames` field. Added a deprecation notice to `FrameKind.AsyncActivation`.
|
||||
4.8 | Added `getIsolatePauseEvent` RPC.
|
||||
4.9 | Added `isolateGroup` property to `Event`.
|
||||
|
||||
[discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observatory-discuss
|
||||
|
||||
@@ -324,11 +324,16 @@ void ServiceEvent::PrintJSONHeader(JSONObject* jsobj) const {
|
||||
jsobj->AddProperty("extensionKind",
|
||||
extension_event_.event_kind->ToCString());
|
||||
}
|
||||
if (isolate() == nullptr) {
|
||||
jsobj->AddPropertyVM("vm");
|
||||
} else {
|
||||
if (isolate_group() != nullptr) {
|
||||
jsobj->AddProperty("isolateGroup", isolate_group());
|
||||
}
|
||||
if (isolate() != nullptr) {
|
||||
ASSERT(isolate_group() != nullptr);
|
||||
jsobj->AddProperty("isolate", isolate());
|
||||
}
|
||||
if (isolate_group() == nullptr && isolate() == nullptr) {
|
||||
jsobj->AddPropertyVM("vm");
|
||||
}
|
||||
ASSERT(timestamp_ != -1);
|
||||
jsobj->AddPropertyTimeMillis("timestamp", timestamp_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user