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

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

Issue 1166433008: 2nd attempt at adding streamListen/streamCancel to the service protocol. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix context objects Created 5 years, 6 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/observatory/tests/service/contexts_test.dart ('k') | runtime/vm/heap.cc » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/debugger.h" 5 #include "vm/debugger.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 deopt_frame_(Array::ZoneHandle(deopt_frame.raw())), 228 deopt_frame_(Array::ZoneHandle(deopt_frame.raw())),
229 deopt_frame_offset_(deopt_frame_offset), 229 deopt_frame_offset_(deopt_frame_offset),
230 vars_initialized_(false), 230 vars_initialized_(false),
231 var_descriptors_(LocalVarDescriptors::ZoneHandle()), 231 var_descriptors_(LocalVarDescriptors::ZoneHandle()),
232 desc_indices_(8), 232 desc_indices_(8),
233 pc_desc_(PcDescriptors::ZoneHandle()) { 233 pc_desc_(PcDescriptors::ZoneHandle()) {
234 } 234 }
235 235
236 236
237 bool Debugger::HasEventHandler() { 237 bool Debugger::HasEventHandler() {
238 return (event_handler_ != NULL) || Service::NeedsEvents(); 238 return ((event_handler_ != NULL) ||
239 Service::NeedsIsolateEvents() ||
240 Service::NeedsDebugEvents());
239 } 241 }
240 242
241 243
244 static bool ServiceNeedsDebuggerEvent(DebuggerEvent::EventType type) {
245 switch (type) {
246 case DebuggerEvent::kBreakpointResolved:
247 // kBreakpointResolved events are handled differently in the vm
248 // service, so suppress them here.
249 return false;
250
251 case DebuggerEvent::kBreakpointReached:
252 case DebuggerEvent::kExceptionThrown:
253 case DebuggerEvent::kIsolateInterrupted:
254 return Service::NeedsDebugEvents();
255
256 case DebuggerEvent::kIsolateCreated:
257 case DebuggerEvent::kIsolateShutdown:
258 return Service::NeedsIsolateEvents();
259
260 default:
261 UNREACHABLE();
262 return false;
263 }
264 }
265
266
242 void Debugger::InvokeEventHandler(DebuggerEvent* event) { 267 void Debugger::InvokeEventHandler(DebuggerEvent* event) {
243 ASSERT(HasEventHandler()); 268 ASSERT(HasEventHandler());
244 269
245 // Give the event to the Service first, as the debugger event handler 270 // Give the event to the Service first, as the debugger event handler
246 // may go into a message loop and the Service will not. 271 // may go into a message loop and the Service will not.
247 // 272 //
248 // kBreakpointResolved events are handled differently in the vm 273 // kBreakpointResolved events are handled differently in the vm
249 // service, so suppress them here. 274 // service, so suppress them here.
250 if (Service::NeedsEvents() && 275 if (ServiceNeedsDebuggerEvent(event->type())) {
251 (event->type() != DebuggerEvent::kBreakpointResolved)) {
252 ServiceEvent service_event(event); 276 ServiceEvent service_event(event);
253 Service::HandleEvent(&service_event); 277 Service::HandleEvent(&service_event);
254 } 278 }
255 279
256 if (FLAG_steal_breakpoints && event->IsPauseEvent()) { 280 if (FLAG_steal_breakpoints && event->IsPauseEvent()) {
257 // We allow the embedder's default breakpoint handler to be overridden. 281 // We allow the embedder's default breakpoint handler to be overridden.
258 isolate_->PauseEventHandler(); 282 isolate_->PauseEventHandler();
259 } else if (event_handler_ != NULL) { 283 } else if (event_handler_ != NULL) {
260 (*event_handler_)(event); 284 (*event_handler_)(event);
261 } 285 }
262 286
263 if (Service::NeedsEvents() && event->IsPauseEvent()) { 287 if (ServiceNeedsDebuggerEvent(event->type()) && event->IsPauseEvent()) {
264 // If we were paused, notify the service that we have resumed. 288 // If we were paused, notify the service that we have resumed.
265 ServiceEvent service_event(event->isolate(), ServiceEvent::kResume); 289 ServiceEvent service_event(event->isolate(), ServiceEvent::kResume);
266 service_event.set_top_frame(event->top_frame()); 290 service_event.set_top_frame(event->top_frame());
267 Service::HandleEvent(&service_event); 291 Service::HandleEvent(&service_event);
268 } 292 }
269 } 293 }
270 294
271 295
272 void Debugger::SignalIsolateEvent(DebuggerEvent::EventType type) { 296 void Debugger::SignalIsolateEvent(DebuggerEvent::EventType type) {
273 if (HasEventHandler()) { 297 if (HasEventHandler()) {
(...skipping 22 matching lines...) Expand all
296 ASSERT(debugger != NULL); 320 ASSERT(debugger != NULL);
297 debugger->SignalIsolateEvent(DebuggerEvent::kIsolateInterrupted); 321 debugger->SignalIsolateEvent(DebuggerEvent::kIsolateInterrupted);
298 } 322 }
299 } 323 }
300 324
301 325
302 // The vm service handles breakpoint notifications in a different way 326 // The vm service handles breakpoint notifications in a different way
303 // than the regular debugger breakpoint notifications. 327 // than the regular debugger breakpoint notifications.
304 static void SendServiceBreakpointEvent(ServiceEvent::EventType type, 328 static void SendServiceBreakpointEvent(ServiceEvent::EventType type,
305 Breakpoint* bpt) { 329 Breakpoint* bpt) {
306 if (Service::NeedsEvents()) { 330 if (Service::NeedsDebugEvents()) {
307 ServiceEvent service_event(Isolate::Current(), type); 331 ServiceEvent service_event(Isolate::Current(), type);
308 service_event.set_breakpoint(bpt); 332 service_event.set_breakpoint(bpt);
309 Service::HandleEvent(&service_event); 333 Service::HandleEvent(&service_event);
310 } 334 }
311 } 335 }
312 336
313 337
314 void BreakpointLocation::AddBreakpoint(Breakpoint* bpt, Debugger* dbg) { 338 void BreakpointLocation::AddBreakpoint(Breakpoint* bpt, Debugger* dbg) {
315 bpt->set_next(breakpoints()); 339 bpt->set_next(breakpoints());
316 set_breakpoints(bpt); 340 set_breakpoints(bpt);
(...skipping 2611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 } 2952 }
2929 2953
2930 2954
2931 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 2955 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
2932 ASSERT(bpt->next() == NULL); 2956 ASSERT(bpt->next() == NULL);
2933 bpt->set_next(code_breakpoints_); 2957 bpt->set_next(code_breakpoints_);
2934 code_breakpoints_ = bpt; 2958 code_breakpoints_ = bpt;
2935 } 2959 }
2936 2960
2937 } // namespace dart 2961 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/contexts_test.dart ('k') | runtime/vm/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698