OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/service_event.h" | 5 #include "vm/service_event.h" |
6 | 6 |
7 #include "vm/message_handler.h" | 7 #include "vm/message_handler.h" |
8 | 8 |
9 namespace dart { | 9 namespace dart { |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 } | 35 } |
36 | 36 |
37 | 37 |
38 ServiceEvent::ServiceEvent(Isolate* isolate, EventKind event_kind) | 38 ServiceEvent::ServiceEvent(Isolate* isolate, EventKind event_kind) |
39 : isolate_(isolate), | 39 : isolate_(isolate), |
40 kind_(event_kind), | 40 kind_(event_kind), |
41 embedder_kind_(NULL), | 41 embedder_kind_(NULL), |
42 embedder_stream_id_(NULL), | 42 embedder_stream_id_(NULL), |
43 breakpoint_(NULL), | 43 breakpoint_(NULL), |
44 top_frame_(NULL), | 44 top_frame_(NULL), |
| 45 timeline_event_block_(NULL), |
45 extension_rpc_(NULL), | 46 extension_rpc_(NULL), |
46 exception_(NULL), | 47 exception_(NULL), |
47 at_async_jump_(false), | 48 at_async_jump_(false), |
48 inspectee_(NULL), | 49 inspectee_(NULL), |
49 gc_stats_(NULL), | 50 gc_stats_(NULL), |
50 bytes_(NULL), | 51 bytes_(NULL), |
51 bytes_length_(0), | 52 bytes_length_(0), |
52 timestamp_(OS::GetCurrentTimeMillis()) { | 53 timestamp_(OS::GetCurrentTimeMillis()) { |
53 if ((event_kind == ServiceEvent::kPauseStart) || | 54 if ((event_kind == ServiceEvent::kPauseStart) || |
54 (event_kind == ServiceEvent::kPauseExit)) { | 55 (event_kind == ServiceEvent::kPauseExit)) { |
55 timestamp_ = isolate->message_handler()->paused_timestamp(); | 56 timestamp_ = isolate->message_handler()->paused_timestamp(); |
56 } else if (event_kind == ServiceEvent::kResume) { | 57 } else if (event_kind == ServiceEvent::kResume) { |
57 timestamp_ = isolate->last_resume_timestamp(); | 58 timestamp_ = isolate->last_resume_timestamp(); |
58 } | 59 } |
59 } | 60 } |
60 | 61 |
61 | 62 |
62 ServiceEvent::ServiceEvent(const DebuggerEvent* debugger_event) | 63 ServiceEvent::ServiceEvent(const DebuggerEvent* debugger_event) |
63 : isolate_(debugger_event->isolate()), | 64 : isolate_(debugger_event->isolate()), |
64 kind_(TranslateEventKind(debugger_event->type())), | 65 kind_(TranslateEventKind(debugger_event->type())), |
65 breakpoint_(NULL), | 66 breakpoint_(NULL), |
66 top_frame_(NULL), | 67 top_frame_(NULL), |
| 68 timeline_event_block_(NULL), |
67 extension_rpc_(NULL), | 69 extension_rpc_(NULL), |
68 exception_(NULL), | 70 exception_(NULL), |
69 at_async_jump_(false), | 71 at_async_jump_(false), |
70 inspectee_(NULL), | 72 inspectee_(NULL), |
71 gc_stats_(NULL), | 73 gc_stats_(NULL), |
72 bytes_(NULL), | 74 bytes_(NULL), |
73 bytes_length_(0), | 75 bytes_length_(0), |
74 timestamp_(OS::GetCurrentTimeMillis()) { | 76 timestamp_(OS::GetCurrentTimeMillis()) { |
75 DebuggerEvent::EventType type = debugger_event->type(); | 77 DebuggerEvent::EventType type = debugger_event->type(); |
76 if (type == DebuggerEvent::kBreakpointReached) { | 78 if (type == DebuggerEvent::kBreakpointReached) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 case kEmbedder: | 134 case kEmbedder: |
133 return embedder_kind(); | 135 return embedder_kind(); |
134 case kLogging: | 136 case kLogging: |
135 return "_Logging"; | 137 return "_Logging"; |
136 case kDebuggerSettingsUpdate: | 138 case kDebuggerSettingsUpdate: |
137 return "_DebuggerSettingsUpdate"; | 139 return "_DebuggerSettingsUpdate"; |
138 case kIllegal: | 140 case kIllegal: |
139 return "Illegal"; | 141 return "Illegal"; |
140 case kExtension: | 142 case kExtension: |
141 return "Extension"; | 143 return "Extension"; |
| 144 case kTimelineEvents: |
| 145 return "TimelineEvents"; |
142 default: | 146 default: |
143 UNREACHABLE(); | 147 UNREACHABLE(); |
144 return "Unknown"; | 148 return "Unknown"; |
145 } | 149 } |
146 } | 150 } |
147 | 151 |
148 | 152 |
149 const char* ServiceEvent::stream_id() const { | 153 const char* ServiceEvent::stream_id() const { |
150 switch (kind()) { | 154 switch (kind()) { |
151 case kVMUpdate: | 155 case kVMUpdate: |
(...skipping 25 matching lines...) Expand all Loading... |
177 | 181 |
178 case kEmbedder: | 182 case kEmbedder: |
179 return embedder_stream_id_; | 183 return embedder_stream_id_; |
180 | 184 |
181 case kLogging: | 185 case kLogging: |
182 return Service::logging_stream.id(); | 186 return Service::logging_stream.id(); |
183 | 187 |
184 case kExtension: | 188 case kExtension: |
185 return Service::extension_stream.id(); | 189 return Service::extension_stream.id(); |
186 | 190 |
| 191 case kTimelineEvents: |
| 192 return Service::timeline_stream.id(); |
| 193 |
187 default: | 194 default: |
188 UNREACHABLE(); | 195 UNREACHABLE(); |
189 return NULL; | 196 return NULL; |
190 } | 197 } |
191 } | 198 } |
192 | 199 |
193 | 200 |
194 void ServiceEvent::PrintJSON(JSONStream* js) const { | 201 void ServiceEvent::PrintJSON(JSONStream* js) const { |
195 JSONObject jsobj(js); | 202 JSONObject jsobj(js); |
196 PrintJSONHeader(&jsobj); | 203 PrintJSONHeader(&jsobj); |
197 if (kind() == kServiceExtensionAdded) { | 204 if (kind() == kServiceExtensionAdded) { |
198 ASSERT(extension_rpc_ != NULL); | 205 ASSERT(extension_rpc_ != NULL); |
199 jsobj.AddProperty("extensionRPC", extension_rpc_->ToCString()); | 206 jsobj.AddProperty("extensionRPC", extension_rpc_->ToCString()); |
200 } | 207 } |
201 if (kind() == kPauseBreakpoint) { | 208 if (kind() == kPauseBreakpoint) { |
202 JSONArray jsarr(&jsobj, "pauseBreakpoints"); | 209 JSONArray jsarr(&jsobj, "pauseBreakpoints"); |
203 // TODO(rmacnak): If we are paused at more than one breakpoint, | 210 // TODO(rmacnak): If we are paused at more than one breakpoint, |
204 // provide it here. | 211 // provide it here. |
205 if (breakpoint() != NULL) { | 212 if (breakpoint() != NULL) { |
206 jsarr.AddValue(breakpoint()); | 213 jsarr.AddValue(breakpoint()); |
207 } | 214 } |
208 } else { | 215 } else { |
209 if (breakpoint() != NULL) { | 216 if (breakpoint() != NULL) { |
210 jsobj.AddProperty("breakpoint", breakpoint()); | 217 jsobj.AddProperty("breakpoint", breakpoint()); |
211 } | 218 } |
212 } | 219 } |
| 220 if (kind() == kTimelineEvents) { |
| 221 jsobj.AddProperty("timelineEvents", timeline_event_block_); |
| 222 } |
213 if (kind() == kDebuggerSettingsUpdate) { | 223 if (kind() == kDebuggerSettingsUpdate) { |
214 JSONObject jssettings(&jsobj, "_debuggerSettings"); | 224 JSONObject jssettings(&jsobj, "_debuggerSettings"); |
215 isolate()->debugger()->PrintSettingsToJSONObject(&jssettings); | 225 isolate()->debugger()->PrintSettingsToJSONObject(&jssettings); |
216 } | 226 } |
217 if ((top_frame() != NULL) && Isolate::Current()->compilation_allowed()) { | 227 if ((top_frame() != NULL) && Isolate::Current()->compilation_allowed()) { |
218 JSONObject jsFrame(&jsobj, "topFrame"); | 228 JSONObject jsFrame(&jsobj, "topFrame"); |
219 top_frame()->PrintToJSONObject(&jsFrame); | 229 top_frame()->PrintToJSONObject(&jsFrame); |
220 intptr_t index = 0; // Avoid ambiguity in call to AddProperty. | 230 intptr_t index = 0; // Avoid ambiguity in call to AddProperty. |
221 jsFrame.AddProperty("index", index); | 231 jsFrame.AddProperty("index", index); |
222 } | 232 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 267 |
258 void ServiceEvent::PrintJSONHeader(JSONObject* jsobj) const { | 268 void ServiceEvent::PrintJSONHeader(JSONObject* jsobj) const { |
259 ASSERT(jsobj != NULL); | 269 ASSERT(jsobj != NULL); |
260 jsobj->AddProperty("type", "Event"); | 270 jsobj->AddProperty("type", "Event"); |
261 jsobj->AddProperty("kind", KindAsCString()); | 271 jsobj->AddProperty("kind", KindAsCString()); |
262 if (kind() == kExtension) { | 272 if (kind() == kExtension) { |
263 ASSERT(extension_event_.event_kind != NULL); | 273 ASSERT(extension_event_.event_kind != NULL); |
264 jsobj->AddProperty("extensionKind", | 274 jsobj->AddProperty("extensionKind", |
265 extension_event_.event_kind->ToCString()); | 275 extension_event_.event_kind->ToCString()); |
266 } | 276 } |
267 if (kind() == kVMUpdate) { | 277 if (isolate() == NULL) { |
268 jsobj->AddPropertyVM("vm"); | 278 jsobj->AddPropertyVM("vm"); |
269 } else { | 279 } else { |
270 jsobj->AddProperty("isolate", isolate()); | 280 jsobj->AddProperty("isolate", isolate()); |
271 } | 281 } |
272 ASSERT(timestamp_ != -1); | 282 ASSERT(timestamp_ != -1); |
273 jsobj->AddPropertyTimeMillis("timestamp", timestamp_); | 283 jsobj->AddPropertyTimeMillis("timestamp", timestamp_); |
274 } | 284 } |
275 | 285 |
276 #endif // !PRODUCT | 286 #endif // !PRODUCT |
277 | 287 |
278 } // namespace dart | 288 } // namespace dart |
OLD | NEW |