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" |
| 8 |
7 namespace dart { | 9 namespace dart { |
8 | 10 |
9 // Translate from the legacy DebugEvent to a ServiceEvent. | 11 // Translate from the legacy DebugEvent to a ServiceEvent. |
10 static ServiceEvent::EventKind TranslateEventKind( | 12 static ServiceEvent::EventKind TranslateEventKind( |
11 DebuggerEvent::EventType kind) { | 13 DebuggerEvent::EventType kind) { |
12 switch (kind) { | 14 switch (kind) { |
13 case DebuggerEvent::kIsolateCreated: | 15 case DebuggerEvent::kIsolateCreated: |
14 return ServiceEvent::kIsolateStart; | 16 return ServiceEvent::kIsolateStart; |
15 | 17 |
16 case DebuggerEvent::kIsolateShutdown: | 18 case DebuggerEvent::kIsolateShutdown: |
17 return ServiceEvent::kIsolateExit; | 19 return ServiceEvent::kIsolateExit; |
18 | 20 |
19 case DebuggerEvent::kBreakpointReached: | 21 case DebuggerEvent::kBreakpointReached: |
20 return ServiceEvent::kPauseBreakpoint; | 22 return ServiceEvent::kPauseBreakpoint; |
21 | 23 |
22 case DebuggerEvent::kIsolateInterrupted: | 24 case DebuggerEvent::kIsolateInterrupted: |
23 return ServiceEvent::kPauseInterrupted; | 25 return ServiceEvent::kPauseInterrupted; |
24 | 26 |
25 case DebuggerEvent::kExceptionThrown: | 27 case DebuggerEvent::kExceptionThrown: |
26 return ServiceEvent::kPauseException; | 28 return ServiceEvent::kPauseException; |
27 default: | 29 default: |
28 UNREACHABLE(); | 30 UNREACHABLE(); |
29 return ServiceEvent::kIllegal; | 31 return ServiceEvent::kIllegal; |
30 } | 32 } |
31 } | 33 } |
32 | 34 |
| 35 |
| 36 ServiceEvent::ServiceEvent(Isolate* isolate, EventKind event_kind) |
| 37 : isolate_(isolate), |
| 38 kind_(event_kind), |
| 39 embedder_kind_(NULL), |
| 40 embedder_stream_id_(NULL), |
| 41 breakpoint_(NULL), |
| 42 top_frame_(NULL), |
| 43 exception_(NULL), |
| 44 async_continuation_(NULL), |
| 45 at_async_jump_(false), |
| 46 inspectee_(NULL), |
| 47 gc_stats_(NULL), |
| 48 bytes_(NULL), |
| 49 bytes_length_(0), |
| 50 timestamp_(OS::GetCurrentTimeMillis()) { |
| 51 if ((event_kind == ServiceEvent::kPauseStart) || |
| 52 (event_kind == ServiceEvent::kPauseExit)) { |
| 53 timestamp_ = isolate->message_handler()->paused_timestamp(); |
| 54 } else if (event_kind == ServiceEvent::kResume) { |
| 55 timestamp_ = isolate->last_resume_timestamp(); |
| 56 } |
| 57 } |
| 58 |
| 59 |
33 ServiceEvent::ServiceEvent(const DebuggerEvent* debugger_event) | 60 ServiceEvent::ServiceEvent(const DebuggerEvent* debugger_event) |
34 : isolate_(debugger_event->isolate()), | 61 : isolate_(debugger_event->isolate()), |
35 kind_(TranslateEventKind(debugger_event->type())), | 62 kind_(TranslateEventKind(debugger_event->type())), |
36 breakpoint_(NULL), | 63 breakpoint_(NULL), |
37 top_frame_(NULL), | 64 top_frame_(NULL), |
38 exception_(NULL), | 65 exception_(NULL), |
39 async_continuation_(NULL), | 66 async_continuation_(NULL), |
40 inspectee_(NULL), | 67 inspectee_(NULL), |
41 gc_stats_(NULL), | 68 gc_stats_(NULL), |
42 bytes_(NULL), | 69 bytes_(NULL), |
43 bytes_length_(0) { | 70 bytes_length_(0), |
| 71 timestamp_(OS::GetCurrentTimeMillis()) { |
44 DebuggerEvent::EventType type = debugger_event->type(); | 72 DebuggerEvent::EventType type = debugger_event->type(); |
45 if (type == DebuggerEvent::kBreakpointReached) { | 73 if (type == DebuggerEvent::kBreakpointReached) { |
46 set_breakpoint(debugger_event->breakpoint()); | 74 set_breakpoint(debugger_event->breakpoint()); |
47 set_async_continuation(debugger_event->async_continuation()); | 75 set_async_continuation(debugger_event->async_continuation()); |
48 set_at_async_jump(debugger_event->at_async_jump()); | 76 set_at_async_jump(debugger_event->at_async_jump()); |
49 } | 77 } |
50 if (type == DebuggerEvent::kExceptionThrown) { | 78 if (type == DebuggerEvent::kExceptionThrown) { |
51 set_exception(debugger_event->exception()); | 79 set_exception(debugger_event->exception()); |
52 } | 80 } |
53 if (type == DebuggerEvent::kBreakpointReached || | 81 if (type == DebuggerEvent::kBreakpointReached || |
54 type == DebuggerEvent::kIsolateInterrupted || | 82 type == DebuggerEvent::kIsolateInterrupted || |
55 type == DebuggerEvent::kExceptionThrown) { | 83 type == DebuggerEvent::kExceptionThrown) { |
56 set_top_frame(debugger_event->top_frame()); | 84 set_top_frame(debugger_event->top_frame()); |
57 } | 85 } |
| 86 if (debugger_event->timestamp() != -1) { |
| 87 timestamp_ = debugger_event->timestamp(); |
| 88 } |
58 } | 89 } |
59 | 90 |
60 | 91 |
61 const char* ServiceEvent::KindAsCString() const { | 92 const char* ServiceEvent::KindAsCString() const { |
62 switch (kind()) { | 93 switch (kind()) { |
63 case kIsolateStart: | 94 case kIsolateStart: |
64 return "IsolateStart"; | 95 return "IsolateStart"; |
65 case kIsolateRunnable: | 96 case kIsolateRunnable: |
66 return "IsolateRunnable"; | 97 return "IsolateRunnable"; |
67 case kIsolateExit: | 98 case kIsolateExit: |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 logRecord.AddProperty("stackTrace", *(log_record_.stack_trace)); | 228 logRecord.AddProperty("stackTrace", *(log_record_.stack_trace)); |
198 } | 229 } |
199 } | 230 } |
200 | 231 |
201 | 232 |
202 void ServiceEvent::PrintJSONHeader(JSONObject* jsobj) const { | 233 void ServiceEvent::PrintJSONHeader(JSONObject* jsobj) const { |
203 ASSERT(jsobj != NULL); | 234 ASSERT(jsobj != NULL); |
204 jsobj->AddProperty("type", "Event"); | 235 jsobj->AddProperty("type", "Event"); |
205 jsobj->AddProperty("kind", KindAsCString()); | 236 jsobj->AddProperty("kind", KindAsCString()); |
206 jsobj->AddProperty("isolate", isolate()); | 237 jsobj->AddProperty("isolate", isolate()); |
| 238 ASSERT(timestamp_ != -1); |
| 239 jsobj->AddPropertyTimeMillis("timestamp", timestamp_); |
207 } | 240 } |
208 | 241 |
209 } // namespace dart | 242 } // namespace dart |
OLD | NEW |