Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
service_event.h
Go to the documentation of this file.
1// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_SERVICE_EVENT_H_
6#define RUNTIME_VM_SERVICE_EVENT_H_
7
8#include "vm/globals.h"
9#include "vm/heap/heap.h"
10#include "vm/profiler_service.h"
11
12namespace dart {
13
14class ActivationFrame;
15class Breakpoint;
16class Instance;
17class Isolate;
18class IsolateGroup;
19class Object;
20class StreamInfo;
21class String;
22class TimelineEventBlock;
23
25 public:
26 enum EventKind {
27 kVMUpdate, // VM identity information has changed
28 kVMFlagUpdate, // VM flags updated
29
30 kIsolateStart, // New isolate has started
31 kIsolateRunnable, // Isolate is ready to run
32 kIsolateExit, // Isolate has exited
33 kIsolateUpdate, // Isolate identity information has changed
34 kIsolateReload, // Result of a reload request
35 kServiceExtensionAdded, // A service extension was registered
36
37 kPauseStart, // --pause-isolates-on-start
38 kPauseExit, // --pause-isolates-on-exit
42 kPausePostRequest, // isolate is paused after a service request.
43 kNone, // isolate has not been made runnable yet.
51
53
55
57
59
61 // Sent when SetVMTimelineFlags is called.
63
65
67
69 };
70
71 struct LogRecord {
73 int64_t timestamp;
74 intptr_t level;
75 const String* name;
77 const Instance* zone;
78 const Object* error;
80 };
81
85 };
86
87 explicit ServiceEvent(EventKind event_kind);
90
91 Isolate* isolate() const { return isolate_; }
92 IsolateGroup* isolate_group() const { return isolate_group_; }
93
94 // Used by the C embedding api.
95 Dart_Port isolate_id() const { return isolate_->main_port(); }
96
97 EventKind kind() const { return kind_; }
98
99 bool IsPause() const {
100 switch (kind()) {
101 case kPauseStart:
102 case kPauseExit:
103 case kPauseBreakpoint:
105 case kPauseException:
107 return true;
108 default:
109 return false;
110 }
111 }
112
113 const char* flag_name() const { return flag_name_; }
114 void set_flag_name(const char* flag) { flag_name_ = flag; }
115
116 const char* flag_new_value() const { return flag_new_value_; }
117 void set_flag_new_value(const char* value) { flag_new_value_ = value; }
118
119 const char* previous_tag() const { return previous_tag_; }
120 void set_previous_tag(const char* previous_tag) {
121 previous_tag_ = previous_tag;
122 }
123
124 const char* updated_tag() const { return updated_tag_; }
125 void set_updated_tag(const char* updated_tag) { updated_tag_ = updated_tag; }
126
127 const char* embedder_kind() const { return embedder_kind_; }
128
129 const char* KindAsCString() const;
130
132 embedder_kind_ = embedder_kind;
133 }
134
135 const StreamInfo* stream_info() const;
136 const char* stream_id() const;
137
139 embedder_stream_id_ = stream_id;
140 }
141
142 Breakpoint* breakpoint() const { return breakpoint_; }
147 breakpoint_ = bpt;
148 }
149
150 ActivationFrame* top_frame() const { return top_frame_; }
154 kind() == kResume);
155 top_frame_ = frame;
156 }
157
158 const String* extension_rpc() const { return extension_rpc_; }
160 extension_rpc_ = extension_rpc;
161 }
162
163 const Object* exception() const { return exception_; }
165 ASSERT(kind_ == kPauseException);
166 exception_ = exception;
167 }
168
169 const Error* reload_error() const {
170 ASSERT(kind_ == kIsolateReload);
171 return reload_error_;
172 }
174 ASSERT(kind_ == kIsolateReload);
175 reload_error_ = error;
176 }
177
178 bool at_async_jump() const { return at_async_jump_; }
179 void set_at_async_jump(bool value) { at_async_jump_ = value; }
180
181 const Object* inspectee() const { return inspectee_; }
183 ASSERT(kind_ == kInspect);
184 inspectee_ = inspectee;
185 }
186
187 const Heap::GCStats* gc_stats() const { return gc_stats_; }
188
189 void set_gc_stats(const Heap::GCStats* gc_stats) { gc_stats_ = gc_stats; }
190
191 const uint8_t* bytes() const { return bytes_; }
192
193 intptr_t bytes_length() const { return bytes_length_; }
194
195 void set_bytes(const uint8_t* bytes, intptr_t bytes_length) {
196 bytes_ = bytes;
197 bytes_length_ = bytes_length;
198 }
199
200 void set_log_record(const LogRecord& log_record) { log_record_ = log_record; }
201
202 void set_extension_event(const ExtensionEvent& extension_event) {
203 extension_event_ = extension_event;
204 }
205
206 void UpdateTimestamp();
207
208 int64_t timestamp() const { return timestamp_; }
209
210 const TimelineEventBlock* timeline_event_block() const {
211 return timeline_event_block_;
212 }
213
214 void set_timeline_event_block(const TimelineEventBlock* block) {
216 timeline_event_block_ = block;
217 }
218
219 Profile* cpu_profile() const { return cpu_profile_; }
220 void set_cpu_profile(Profile* profile) { cpu_profile_ = profile; }
221
222 void PrintJSON(JSONStream* js) const;
223
224 void PrintJSONHeader(JSONObject* jsobj) const;
225
226 private:
229 EventKind event_kind);
230
231 Isolate* isolate_;
232 IsolateGroup* isolate_group_;
233 EventKind kind_;
234 const char* flag_name_;
235 const char* flag_new_value_;
236 const char* previous_tag_;
237 const char* updated_tag_;
238 const char* embedder_kind_;
239 const char* embedder_stream_id_;
240 Breakpoint* breakpoint_;
241 ActivationFrame* top_frame_;
242 const TimelineEventBlock* timeline_event_block_;
243 const String* extension_rpc_;
244 const Object* exception_;
245 const Error* reload_error_;
246 const String* spawn_token_;
247 const String* spawn_error_;
248 bool at_async_jump_;
249 const Object* inspectee_;
250 const Heap::GCStats* gc_stats_;
251 const uint8_t* bytes_;
252 intptr_t bytes_length_;
253 LogRecord log_record_;
254 ExtensionEvent extension_event_;
255 Profile* cpu_profile_;
256 int64_t timestamp_;
257};
258
259} // namespace dart
260
261#endif // RUNTIME_VM_SERVICE_EVENT_H_
Dart_Port main_port() const
Definition isolate.h:1001
Profile * cpu_profile() const
const StreamInfo * stream_info() const
void set_embedder_stream_id(const char *stream_id)
Breakpoint * breakpoint() const
const char * KindAsCString() const
void set_top_frame(ActivationFrame *frame)
void set_previous_tag(const char *previous_tag)
const char * previous_tag() const
void set_inspectee(const Object *inspectee)
intptr_t bytes_length() const
int64_t timestamp() const
const char * stream_id() const
void set_reload_error(const Error *error)
bool at_async_jump() const
const Object * exception() const
void set_exception(const Object *exception)
const uint8_t * bytes() const
Isolate * isolate() const
void set_gc_stats(const Heap::GCStats *gc_stats)
IsolateGroup * isolate_group() const
const char * updated_tag() const
void set_timeline_event_block(const TimelineEventBlock *block)
Dart_Port isolate_id() const
void set_extension_rpc(const String *extension_rpc)
void set_flag_new_value(const char *value)
ActivationFrame * top_frame() const
void set_flag_name(const char *flag)
void set_bytes(const uint8_t *bytes, intptr_t bytes_length)
const String * extension_rpc() const
bool IsPause() const
void set_at_async_jump(bool value)
const Object * inspectee() const
void set_log_record(const LogRecord &log_record)
const char * flag_new_value() const
void set_updated_tag(const char *updated_tag)
const char * flag_name() const
void set_extension_event(const ExtensionEvent &extension_event)
void set_cpu_profile(Profile *profile)
void PrintJSONHeader(JSONObject *jsobj) const
void set_breakpoint(Breakpoint *bpt)
void set_embedder_kind(const char *embedder_kind)
void PrintJSON(JSONStream *js) const
const char * embedder_kind() const
EventKind kind() const
const Heap::GCStats * gc_stats() const
const Error * reload_error() const
const TimelineEventBlock * timeline_event_block() const
int64_t Dart_Port
Definition dart_api.h:1524
#define ASSERT(E)
double frame
Definition examples.cpp:31
FlutterSemanticsFlag flag
const uint8_t uint32_t uint32_t GError ** error
uint8_t value