Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: runtime/vm/service_event.cc

Issue 1978603002: Remove DebuggerEvent. Refactor remaining code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: before landing Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/service_event.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/debugger.h"
7 #include "vm/message_handler.h" 8 #include "vm/message_handler.h"
9 #include "vm/service_isolate.h"
8 10
9 namespace dart { 11 namespace dart {
10 12
11 #ifndef PRODUCT 13 #ifndef PRODUCT
12 14
13 // Translate from the legacy DebugEvent to a ServiceEvent.
14 static ServiceEvent::EventKind TranslateEventKind(
15 DebuggerEvent::EventType kind) {
16 switch (kind) {
17 case DebuggerEvent::kIsolateCreated:
18 return ServiceEvent::kIsolateStart;
19
20 case DebuggerEvent::kIsolateShutdown:
21 return ServiceEvent::kIsolateExit;
22
23 case DebuggerEvent::kBreakpointReached:
24 return ServiceEvent::kPauseBreakpoint;
25
26 case DebuggerEvent::kIsolateInterrupted:
27 return ServiceEvent::kPauseInterrupted;
28
29 case DebuggerEvent::kExceptionThrown:
30 return ServiceEvent::kPauseException;
31 default:
32 UNREACHABLE();
33 return ServiceEvent::kIllegal;
34 }
35 }
36
37
38 ServiceEvent::ServiceEvent(Isolate* isolate, EventKind event_kind) 15 ServiceEvent::ServiceEvent(Isolate* isolate, EventKind event_kind)
39 : isolate_(isolate), 16 : isolate_(isolate),
40 kind_(event_kind), 17 kind_(event_kind),
41 embedder_kind_(NULL), 18 embedder_kind_(NULL),
42 embedder_stream_id_(NULL), 19 embedder_stream_id_(NULL),
43 breakpoint_(NULL), 20 breakpoint_(NULL),
44 top_frame_(NULL), 21 top_frame_(NULL),
45 timeline_event_block_(NULL), 22 timeline_event_block_(NULL),
46 extension_rpc_(NULL), 23 extension_rpc_(NULL),
47 exception_(NULL), 24 exception_(NULL),
48 at_async_jump_(false), 25 at_async_jump_(false),
49 inspectee_(NULL), 26 inspectee_(NULL),
50 gc_stats_(NULL), 27 gc_stats_(NULL),
51 bytes_(NULL), 28 bytes_(NULL),
52 bytes_length_(0), 29 bytes_length_(0),
53 timestamp_(OS::GetCurrentTimeMillis()) { 30 timestamp_(OS::GetCurrentTimeMillis()) {
31 // We should never generate events for the vm or service isolates.
32 ASSERT(isolate_ != Dart::vm_isolate());
33 ASSERT(isolate == NULL ||
34 !ServiceIsolate::IsServiceIsolateDescendant(isolate_));
35
54 if ((event_kind == ServiceEvent::kPauseStart) && 36 if ((event_kind == ServiceEvent::kPauseStart) &&
55 !isolate->message_handler()->is_paused_on_start()) { 37 !isolate->message_handler()->is_paused_on_start()) {
56 // We will pause on start but the message handler lacks a valid 38 // We will pause on start but the message handler lacks a valid
57 // paused timestamp because we haven't paused yet. Use the current time. 39 // paused timestamp because we haven't paused yet. Use the current time.
58 timestamp_ = OS::GetCurrentTimeMillis(); 40 timestamp_ = OS::GetCurrentTimeMillis();
59 } else if ((event_kind == ServiceEvent::kPauseStart) || 41 } else if ((event_kind == ServiceEvent::kPauseStart) ||
60 (event_kind == ServiceEvent::kPauseExit)) { 42 (event_kind == ServiceEvent::kPauseExit)) {
61 timestamp_ = isolate->message_handler()->paused_timestamp(); 43 timestamp_ = isolate->message_handler()->paused_timestamp();
62 } else if (event_kind == ServiceEvent::kResume) { 44 } else if (event_kind == ServiceEvent::kResume) {
63 timestamp_ = isolate->last_resume_timestamp(); 45 timestamp_ = isolate->last_resume_timestamp();
64 } 46 }
65 } 47 }
66 48
67 49
68 ServiceEvent::ServiceEvent(const DebuggerEvent* debugger_event) 50 void ServiceEvent::UpdateTimestamp() {
69 : isolate_(debugger_event->isolate()), 51 timestamp_ = OS::GetCurrentTimeMillis();
70 kind_(TranslateEventKind(debugger_event->type())),
71 breakpoint_(NULL),
72 top_frame_(NULL),
73 timeline_event_block_(NULL),
74 extension_rpc_(NULL),
75 exception_(NULL),
76 at_async_jump_(false),
77 inspectee_(NULL),
78 gc_stats_(NULL),
79 bytes_(NULL),
80 bytes_length_(0),
81 timestamp_(OS::GetCurrentTimeMillis()) {
82 DebuggerEvent::EventType type = debugger_event->type();
83 if (type == DebuggerEvent::kBreakpointReached) {
84 set_breakpoint(debugger_event->breakpoint());
85 set_at_async_jump(debugger_event->at_async_jump());
86 }
87 if (type == DebuggerEvent::kExceptionThrown) {
88 set_exception(debugger_event->exception());
89 }
90 if (type == DebuggerEvent::kBreakpointReached ||
91 type == DebuggerEvent::kIsolateInterrupted ||
92 type == DebuggerEvent::kExceptionThrown) {
93 set_top_frame(debugger_event->top_frame());
94 }
95 if (debugger_event->timestamp() != -1) {
96 timestamp_ = debugger_event->timestamp();
97 }
98 } 52 }
99 53
100 54
101 const char* ServiceEvent::KindAsCString() const { 55 const char* ServiceEvent::KindAsCString() const {
102 switch (kind()) { 56 switch (kind()) {
103 case kVMUpdate: 57 case kVMUpdate:
104 return "VMUpdate"; 58 return "VMUpdate";
105 case kIsolateStart: 59 case kIsolateStart:
106 return "IsolateStart"; 60 return "IsolateStart";
107 case kIsolateRunnable: 61 case kIsolateRunnable:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return "Extension"; 102 return "Extension";
149 case kTimelineEvents: 103 case kTimelineEvents:
150 return "TimelineEvents"; 104 return "TimelineEvents";
151 default: 105 default:
152 UNREACHABLE(); 106 UNREACHABLE();
153 return "Unknown"; 107 return "Unknown";
154 } 108 }
155 } 109 }
156 110
157 111
158 const char* ServiceEvent::stream_id() const { 112 const StreamInfo* ServiceEvent::stream_info() const {
159 switch (kind()) { 113 switch (kind()) {
160 case kVMUpdate: 114 case kVMUpdate:
161 return Service::vm_stream.id(); 115 return &Service::vm_stream;
162 116
163 case kIsolateStart: 117 case kIsolateStart:
164 case kIsolateRunnable: 118 case kIsolateRunnable:
165 case kIsolateExit: 119 case kIsolateExit:
166 case kIsolateUpdate: 120 case kIsolateUpdate:
167 case kServiceExtensionAdded: 121 case kServiceExtensionAdded:
168 return Service::isolate_stream.id(); 122 return &Service::isolate_stream;
169 123
170 case kPauseStart: 124 case kPauseStart:
171 case kPauseExit: 125 case kPauseExit:
172 case kPauseBreakpoint: 126 case kPauseBreakpoint:
173 case kPauseInterrupted: 127 case kPauseInterrupted:
174 case kPauseException: 128 case kPauseException:
175 case kNone: 129 case kNone:
176 case kResume: 130 case kResume:
177 case kBreakpointAdded: 131 case kBreakpointAdded:
178 case kBreakpointResolved: 132 case kBreakpointResolved:
179 case kBreakpointRemoved: 133 case kBreakpointRemoved:
180 case kInspect: 134 case kInspect:
181 case kDebuggerSettingsUpdate: 135 case kDebuggerSettingsUpdate:
182 return Service::debug_stream.id(); 136 return &Service::debug_stream;
183 137
184 case kGC: 138 case kGC:
185 return Service::gc_stream.id(); 139 return &Service::gc_stream;
140
141 case kLogging:
142 return &Service::logging_stream;
143
144 case kExtension:
145 return &Service::extension_stream;
146
147 case kTimelineEvents:
148 return &Service::timeline_stream;
186 149
187 case kEmbedder: 150 case kEmbedder:
188 return embedder_stream_id_; 151 return NULL;
189
190 case kLogging:
191 return Service::logging_stream.id();
192
193 case kExtension:
194 return Service::extension_stream.id();
195
196 case kTimelineEvents:
197 return Service::timeline_stream.id();
198 152
199 default: 153 default:
200 UNREACHABLE(); 154 UNREACHABLE();
201 return NULL; 155 return NULL;
202 } 156 }
203 } 157 }
204 158
205 159
160 const char* ServiceEvent::stream_id() const {
161 const StreamInfo* stream = stream_info();
162 if (stream == NULL) {
163 ASSERT(kind() == kEmbedder);
164 return embedder_stream_id_;
165 } else {
166 return stream->id();
167 }
168 }
169
170
206 void ServiceEvent::PrintJSON(JSONStream* js) const { 171 void ServiceEvent::PrintJSON(JSONStream* js) const {
207 JSONObject jsobj(js); 172 JSONObject jsobj(js);
208 PrintJSONHeader(&jsobj); 173 PrintJSONHeader(&jsobj);
209 if (kind() == kServiceExtensionAdded) { 174 if (kind() == kServiceExtensionAdded) {
210 ASSERT(extension_rpc_ != NULL); 175 ASSERT(extension_rpc_ != NULL);
211 jsobj.AddProperty("extensionRPC", extension_rpc_->ToCString()); 176 jsobj.AddProperty("extensionRPC", extension_rpc_->ToCString());
212 } 177 }
213 if (kind() == kPauseBreakpoint) { 178 if (kind() == kPauseBreakpoint) {
214 JSONArray jsarr(&jsobj, "pauseBreakpoints"); 179 JSONArray jsarr(&jsobj, "pauseBreakpoints");
215 // TODO(rmacnak): If we are paused at more than one breakpoint, 180 // TODO(rmacnak): If we are paused at more than one breakpoint,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } else { 249 } else {
285 jsobj->AddProperty("isolate", isolate()); 250 jsobj->AddProperty("isolate", isolate());
286 } 251 }
287 ASSERT(timestamp_ != -1); 252 ASSERT(timestamp_ != -1);
288 jsobj->AddPropertyTimeMillis("timestamp", timestamp_); 253 jsobj->AddPropertyTimeMillis("timestamp", timestamp_);
289 } 254 }
290 255
291 #endif // !PRODUCT 256 #endif // !PRODUCT
292 257
293 } // namespace dart 258 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service_event.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698