mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[ VM / Service ] Added VMFlagUpdated event to VM stream
Fixes https://github.com/dart-lang/sdk/issues/37557 Change-Id: I129c60a4ac8f42e2f338e6bd15f7fa6fcfe7f54a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109721 Commit-Queue: Ben Konyi <bkonyi@google.com> Reviewed-by: Siva Annamalai <asiva@google.com>
This commit is contained in:
parent
b41b868797
commit
babefb8c01
|
@ -2087,6 +2087,7 @@ Level _findLogLevel(int value) {
|
|||
class ServiceEvent extends ServiceObject {
|
||||
/// The possible 'kind' values.
|
||||
static const kVMUpdate = 'VMUpdate';
|
||||
static const kVMFlagUpdate = 'VMFlagUpdate';
|
||||
static const kIsolateStart = 'IsolateStart';
|
||||
static const kIsolateRunnable = 'IsolateRunnable';
|
||||
static const kIsolateExit = 'IsolateExit';
|
||||
|
@ -2123,6 +2124,8 @@ class ServiceEvent extends ServiceObject {
|
|||
|
||||
String kind;
|
||||
DateTime timestamp;
|
||||
String flag;
|
||||
String newValue;
|
||||
List<M.Breakpoint> pauseBreakpoints;
|
||||
Breakpoint breakpoint;
|
||||
Frame topFrame;
|
||||
|
@ -2253,6 +2256,12 @@ class ServiceEvent extends ServiceObject {
|
|||
if (map['alias'] != null) {
|
||||
alias = map['alias'];
|
||||
}
|
||||
if (map['flag'] != null) {
|
||||
flag = map['flag'];
|
||||
}
|
||||
if (map['new_value'] != null) {
|
||||
newValue = map['new_value'];
|
||||
}
|
||||
}
|
||||
|
||||
String toString() {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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:async';
|
||||
|
||||
import 'package:observatory/service_io.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
|
@ -74,12 +76,25 @@ var tests = <VMTest>[
|
|||
final kProfilePeriod = 'profile_period';
|
||||
final kValue = 100;
|
||||
expect(await getFlagValue(vm, kProfilePeriod), '1000');
|
||||
var params = {
|
||||
final params = {
|
||||
'name': '$kProfilePeriod',
|
||||
'value': '$kValue',
|
||||
};
|
||||
var result = await vm.invokeRpcNoUpgrade('setFlag', params);
|
||||
final completer = Completer();
|
||||
final stream = await vm.getEventStream(VM.kVMStream);
|
||||
var subscription;
|
||||
subscription = stream.listen((ServiceEvent event) {
|
||||
if (event.kind == ServiceEvent.kVMFlagUpdate) {
|
||||
expect(event.owner.type, 'VM');
|
||||
expect(event.flag, kProfilePeriod);
|
||||
expect(event.newValue, kValue.toString());
|
||||
subscription.cancel();
|
||||
completer.complete();
|
||||
}
|
||||
});
|
||||
final result = await vm.invokeRpcNoUpgrade('setFlag', params);
|
||||
expect(result['type'], equals('Success'));
|
||||
await completer.future;
|
||||
expect(await getFlagValue(vm, kProfilePeriod), kValue.toString());
|
||||
}
|
||||
];
|
||||
|
|
|
@ -12,7 +12,7 @@ var tests = <VMTest>[
|
|||
var result = await vm.invokeRpcNoUpgrade('getVersion', {});
|
||||
expect(result['type'], equals('Version'));
|
||||
expect(result['major'], equals(3));
|
||||
expect(result['minor'], equals(22));
|
||||
expect(result['minor'], equals(23));
|
||||
expect(result['_privateMajor'], equals(0));
|
||||
expect(result['_privateMinor'], equals(0));
|
||||
},
|
||||
|
|
|
@ -4708,6 +4708,12 @@ static bool SetFlag(Thread* thread, JSONStream* js) {
|
|||
// to notify the ThreadInterrupter to pick up the change.
|
||||
Profiler::UpdateSamplePeriod();
|
||||
}
|
||||
if (Service::vm_stream.enabled()) {
|
||||
ServiceEvent event(NULL, ServiceEvent::kVMFlagUpdate);
|
||||
event.set_flag_name(flag_name);
|
||||
event.set_flag_new_value(flag_value);
|
||||
Service::HandleEvent(&event);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
JSONObject jsobj(js);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
namespace dart {
|
||||
|
||||
#define SERVICE_PROTOCOL_MAJOR_VERSION 3
|
||||
#define SERVICE_PROTOCOL_MINOR_VERSION 22
|
||||
#define SERVICE_PROTOCOL_MINOR_VERSION 23
|
||||
|
||||
class Array;
|
||||
class EmbedderServiceHandler;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Dart VM Service Protocol 3.22
|
||||
# Dart VM Service Protocol 3.23
|
||||
|
||||
> Please post feedback to the [observatory-discuss group][discuss-list]
|
||||
|
||||
This document describes of _version 3.22_ of the Dart VM Service Protocol. This
|
||||
This document describes of _version 3.23_ 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.
|
||||
|
@ -1080,7 +1080,7 @@ The _streamId_ parameter may have the following published values:
|
|||
|
||||
streamId | event types provided
|
||||
-------- | -----------
|
||||
VM | VMUpdate
|
||||
VM | VMUpdate, VMFlagUpdate
|
||||
Isolate | IsolateStart, IsolateRunnable, IsolateExit, IsolateUpdate, IsolateReload, ServiceExtensionAdded
|
||||
Debug | PauseStart, PauseExit, PauseBreakpoint, PauseInterrupted, PauseException, PausePostRequest, Resume, BreakpointAdded, BreakpointResolved, BreakpointRemoved, Inspect, None
|
||||
GC | GC
|
||||
|
@ -1513,13 +1513,13 @@ class Event extends Response {
|
|||
// The isolate with which this event is associated.
|
||||
//
|
||||
// This is provided for all event kinds except for:
|
||||
// VMUpdate
|
||||
// VMUpdate, VMFlagUpdate
|
||||
@Isolate isolate [optional];
|
||||
|
||||
// The vm with which this event is associated.
|
||||
//
|
||||
// This is provided for the event kind:
|
||||
// VMUpdate
|
||||
// VMUpdate, VMFlagUpdate
|
||||
@VM vm [optional];
|
||||
|
||||
// The timestamp (in milliseconds since the epoch) associated with this event.
|
||||
|
@ -1635,6 +1635,18 @@ class Event extends Response {
|
|||
// This is provided for the event kinds:
|
||||
// ServiceRegistered
|
||||
String alias [optional];
|
||||
|
||||
// The name of the changed flag.
|
||||
//
|
||||
// This is provided for the event kinds:
|
||||
// VMFlagUpdate
|
||||
String flag [optional];
|
||||
|
||||
// The new value of the changed flag.
|
||||
//
|
||||
// This is provided for the event kinds:
|
||||
// VMFlagUpdate
|
||||
String newValue [optional];
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -1652,6 +1664,9 @@ enum EventKind {
|
|||
// to notify of changes to the VM debugging name via setVMName.
|
||||
VMUpdate,
|
||||
|
||||
// Notification that a VM flag has been changed via the service protocol.
|
||||
VMFlagUpdate,
|
||||
|
||||
// Notification that a new isolate has started.
|
||||
IsolateStart,
|
||||
|
||||
|
@ -3127,5 +3142,6 @@ version | comments
|
|||
3.20 | Add 'getInstances' RPC and 'InstanceSet' object.
|
||||
3.21 | Add 'getVMTimelineMicros' RPC and 'Timestamp' object.
|
||||
3.22 | Add `registerService` RPC, `Service` stream, and `ServiceRegistered` and `ServiceUnregistered` event kinds.
|
||||
3.23 | Add `VMFlagUpdate` event kind to the `VM` stream.
|
||||
|
||||
[discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observatory-discuss
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Dart VM Service Protocol 3.23-dev
|
||||
# Dart VM Service Protocol 3.24-dev
|
||||
|
||||
> Please post feedback to the [observatory-discuss group][discuss-list]
|
||||
|
||||
This document describes of _version 3.23-dev_ of the Dart VM Service Protocol. This
|
||||
This document describes of _version 3.24-dev_ 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.
|
||||
|
@ -1080,7 +1080,7 @@ The _streamId_ parameter may have the following published values:
|
|||
|
||||
streamId | event types provided
|
||||
-------- | -----------
|
||||
VM | VMUpdate
|
||||
VM | VMUpdate, VMFlagUpdate
|
||||
Isolate | IsolateStart, IsolateRunnable, IsolateExit, IsolateUpdate, IsolateReload, ServiceExtensionAdded
|
||||
Debug | PauseStart, PauseExit, PauseBreakpoint, PauseInterrupted, PauseException, PausePostRequest, Resume, BreakpointAdded, BreakpointResolved, BreakpointRemoved, Inspect, None
|
||||
GC | GC
|
||||
|
@ -1513,13 +1513,13 @@ class Event extends Response {
|
|||
// The isolate with which this event is associated.
|
||||
//
|
||||
// This is provided for all event kinds except for:
|
||||
// VMUpdate
|
||||
// VMUpdate, VMFlagUpdate
|
||||
@Isolate isolate [optional];
|
||||
|
||||
// The vm with which this event is associated.
|
||||
//
|
||||
// This is provided for the event kind:
|
||||
// VMUpdate
|
||||
// VMUpdate, VMFlagUpdate
|
||||
@VM vm [optional];
|
||||
|
||||
// The timestamp (in milliseconds since the epoch) associated with this event.
|
||||
|
@ -1635,6 +1635,18 @@ class Event extends Response {
|
|||
// This is provided for the event kinds:
|
||||
// ServiceRegistered
|
||||
String alias [optional];
|
||||
|
||||
// The name of the changed flag.
|
||||
//
|
||||
// This is provided for the event kinds:
|
||||
// VMFlagUpdate
|
||||
String flag [optional];
|
||||
|
||||
// The new value of the changed flag.
|
||||
//
|
||||
// This is provided for the event kinds:
|
||||
// VMFlagUpdate
|
||||
String newValue [optional];
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -1652,6 +1664,9 @@ enum EventKind {
|
|||
// to notify of changes to the VM debugging name via setVMName.
|
||||
VMUpdate,
|
||||
|
||||
// Notification that a VM flag has been changed via the service protocol.
|
||||
VMFlagUpdate,
|
||||
|
||||
// Notification that a new isolate has started.
|
||||
IsolateStart,
|
||||
|
||||
|
@ -3127,5 +3142,6 @@ version | comments
|
|||
3.20 | Add 'getInstances' RPC and 'InstanceSet' object.
|
||||
3.21 | Add 'getVMTimelineMicros' RPC and 'Timestamp' object.
|
||||
3.22 | Add `registerService` RPC, `Service` stream, and `ServiceRegistered` and `ServiceUnregistered` event kinds.
|
||||
3.23 | Add `VMFlagUpdate` event kind to the `VM` stream.
|
||||
|
||||
[discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observatory-discuss
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace dart {
|
|||
ServiceEvent::ServiceEvent(Isolate* isolate, EventKind event_kind)
|
||||
: isolate_(isolate),
|
||||
kind_(event_kind),
|
||||
flag_name_(NULL),
|
||||
flag_new_value_(NULL),
|
||||
embedder_kind_(NULL),
|
||||
embedder_stream_id_(NULL),
|
||||
breakpoint_(NULL),
|
||||
|
@ -52,6 +54,8 @@ const char* ServiceEvent::KindAsCString() const {
|
|||
switch (kind()) {
|
||||
case kVMUpdate:
|
||||
return "VMUpdate";
|
||||
case kVMFlagUpdate:
|
||||
return "VMFlagUpdate";
|
||||
case kIsolateStart:
|
||||
return "IsolateStart";
|
||||
case kIsolateRunnable:
|
||||
|
@ -113,6 +117,7 @@ const char* ServiceEvent::KindAsCString() const {
|
|||
const StreamInfo* ServiceEvent::stream_info() const {
|
||||
switch (kind()) {
|
||||
case kVMUpdate:
|
||||
case kVMFlagUpdate:
|
||||
return &Service::vm_stream;
|
||||
|
||||
case kIsolateStart:
|
||||
|
@ -173,6 +178,10 @@ const char* ServiceEvent::stream_id() const {
|
|||
void ServiceEvent::PrintJSON(JSONStream* js) const {
|
||||
JSONObject jsobj(js);
|
||||
PrintJSONHeader(&jsobj);
|
||||
if (kind() == kVMFlagUpdate) {
|
||||
jsobj.AddProperty("flag", flag_name());
|
||||
jsobj.AddProperty("new_value", flag_new_value());
|
||||
}
|
||||
if (kind() == kIsolateReload) {
|
||||
if (reload_error_ == NULL) {
|
||||
jsobj.AddProperty("status", "success");
|
||||
|
|
|
@ -22,7 +22,8 @@ class TimelineEventBlock;
|
|||
class ServiceEvent {
|
||||
public:
|
||||
enum EventKind {
|
||||
kVMUpdate, // VM identity information has changed
|
||||
kVMUpdate, // VM identity information has changed
|
||||
kVMFlagUpdate, // VM flags updated
|
||||
|
||||
kIsolateStart, // New isolate has started
|
||||
kIsolateRunnable, // Isolate is ready to run
|
||||
|
@ -98,6 +99,12 @@ class ServiceEvent {
|
|||
}
|
||||
}
|
||||
|
||||
const char* flag_name() const { return flag_name_; }
|
||||
void set_flag_name(const char* flag) { flag_name_ = flag; }
|
||||
|
||||
const char* flag_new_value() const { return flag_new_value_; }
|
||||
void set_flag_new_value(const char* value) { flag_new_value_ = value; }
|
||||
|
||||
const char* embedder_kind() const { return embedder_kind_; }
|
||||
|
||||
const char* KindAsCString() const;
|
||||
|
@ -214,6 +221,8 @@ class ServiceEvent {
|
|||
private:
|
||||
Isolate* isolate_;
|
||||
EventKind kind_;
|
||||
const char* flag_name_;
|
||||
const char* flag_new_value_;
|
||||
const char* embedder_kind_;
|
||||
const char* embedder_stream_id_;
|
||||
Breakpoint* breakpoint_;
|
||||
|
|
Loading…
Reference in a new issue