OLD | NEW |
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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 deopt_frame_(Array::ZoneHandle(deopt_frame.raw())), | 219 deopt_frame_(Array::ZoneHandle(deopt_frame.raw())), |
220 deopt_frame_offset_(deopt_frame_offset), | 220 deopt_frame_offset_(deopt_frame_offset), |
221 vars_initialized_(false), | 221 vars_initialized_(false), |
222 var_descriptors_(LocalVarDescriptors::ZoneHandle()), | 222 var_descriptors_(LocalVarDescriptors::ZoneHandle()), |
223 desc_indices_(8), | 223 desc_indices_(8), |
224 pc_desc_(PcDescriptors::ZoneHandle()) { | 224 pc_desc_(PcDescriptors::ZoneHandle()) { |
225 } | 225 } |
226 | 226 |
227 | 227 |
228 bool Debugger::HasEventHandler() { | 228 bool Debugger::HasEventHandler() { |
229 return (event_handler_ != NULL) || Service::NeedsEvents(); | 229 return ((event_handler_ != NULL) || |
| 230 Service::NeedsIsolateEvents() || |
| 231 Service::NeedsDebugEvents()); |
230 } | 232 } |
231 | 233 |
232 | 234 |
| 235 static bool ServiceNeedsDebuggerEvent(DebuggerEvent::EventType type) { |
| 236 switch (type) { |
| 237 case DebuggerEvent::kBreakpointResolved: |
| 238 // kBreakpointResolved events are handled differently in the vm |
| 239 // service, so suppress them here. |
| 240 return false; |
| 241 |
| 242 case DebuggerEvent::kBreakpointReached: |
| 243 case DebuggerEvent::kExceptionThrown: |
| 244 case DebuggerEvent::kIsolateInterrupted: |
| 245 return Service::NeedsDebugEvents(); |
| 246 |
| 247 case DebuggerEvent::kIsolateCreated: |
| 248 case DebuggerEvent::kIsolateShutdown: |
| 249 return Service::NeedsIsolateEvents(); |
| 250 |
| 251 default: |
| 252 UNREACHABLE(); |
| 253 return false; |
| 254 } |
| 255 } |
| 256 |
| 257 |
233 void Debugger::InvokeEventHandler(DebuggerEvent* event) { | 258 void Debugger::InvokeEventHandler(DebuggerEvent* event) { |
234 ASSERT(HasEventHandler()); | 259 ASSERT(HasEventHandler()); |
235 | 260 |
236 // Give the event to the Service first, as the debugger event handler | 261 // Give the event to the Service first, as the debugger event handler |
237 // may go into a message loop and the Service will not. | 262 // may go into a message loop and the Service will not. |
238 // | 263 // |
239 // kBreakpointResolved events are handled differently in the vm | 264 // kBreakpointResolved events are handled differently in the vm |
240 // service, so suppress them here. | 265 // service, so suppress them here. |
241 if (Service::NeedsEvents() && | 266 if (ServiceNeedsDebuggerEvent(event->type())) { |
242 (event->type() != DebuggerEvent::kBreakpointResolved)) { | |
243 ServiceEvent service_event(event); | 267 ServiceEvent service_event(event); |
244 Service::HandleEvent(&service_event); | 268 Service::HandleEvent(&service_event); |
245 } | 269 } |
246 | 270 |
247 if (FLAG_steal_breakpoints && event->IsPauseEvent()) { | 271 if (FLAG_steal_breakpoints && event->IsPauseEvent()) { |
248 // We allow the embedder's default breakpoint handler to be overridden. | 272 // We allow the embedder's default breakpoint handler to be overridden. |
249 isolate_->PauseEventHandler(); | 273 isolate_->PauseEventHandler(); |
250 } else if (event_handler_ != NULL) { | 274 } else if (event_handler_ != NULL) { |
251 (*event_handler_)(event); | 275 (*event_handler_)(event); |
252 } | 276 } |
253 | 277 |
254 if (Service::NeedsEvents() && event->IsPauseEvent()) { | 278 if (ServiceNeedsDebuggerEvent(event->type()) && event->IsPauseEvent()) { |
255 // If we were paused, notify the service that we have resumed. | 279 // If we were paused, notify the service that we have resumed. |
256 ServiceEvent service_event(event->isolate(), ServiceEvent::kResume); | 280 ServiceEvent service_event(event->isolate(), ServiceEvent::kResume); |
257 service_event.set_top_frame(event->top_frame()); | 281 service_event.set_top_frame(event->top_frame()); |
258 Service::HandleEvent(&service_event); | 282 Service::HandleEvent(&service_event); |
259 } | 283 } |
260 } | 284 } |
261 | 285 |
262 | 286 |
263 void Debugger::SignalIsolateEvent(DebuggerEvent::EventType type) { | 287 void Debugger::SignalIsolateEvent(DebuggerEvent::EventType type) { |
264 if (HasEventHandler()) { | 288 if (HasEventHandler()) { |
(...skipping 22 matching lines...) Expand all Loading... |
287 ASSERT(debugger != NULL); | 311 ASSERT(debugger != NULL); |
288 debugger->SignalIsolateEvent(DebuggerEvent::kIsolateInterrupted); | 312 debugger->SignalIsolateEvent(DebuggerEvent::kIsolateInterrupted); |
289 } | 313 } |
290 } | 314 } |
291 | 315 |
292 | 316 |
293 // The vm service handles breakpoint notifications in a different way | 317 // The vm service handles breakpoint notifications in a different way |
294 // than the regular debugger breakpoint notifications. | 318 // than the regular debugger breakpoint notifications. |
295 static void SendServiceBreakpointEvent(ServiceEvent::EventType type, | 319 static void SendServiceBreakpointEvent(ServiceEvent::EventType type, |
296 SourceBreakpoint* bpt) { | 320 SourceBreakpoint* bpt) { |
297 if (Service::NeedsEvents()) { | 321 if (Service::NeedsDebugEvents()) { |
298 ServiceEvent service_event(Isolate::Current(), type); | 322 ServiceEvent service_event(Isolate::Current(), type); |
299 service_event.set_breakpoint(bpt); | 323 service_event.set_breakpoint(bpt); |
300 Service::HandleEvent(&service_event); | 324 Service::HandleEvent(&service_event); |
301 } | 325 } |
302 } | 326 } |
303 | 327 |
304 | 328 |
305 const char* Debugger::QualifiedFunctionName(const Function& func) { | 329 const char* Debugger::QualifiedFunctionName(const Function& func) { |
306 const String& func_name = String::Handle(func.name()); | 330 const String& func_name = String::Handle(func.name()); |
307 Class& func_class = Class::Handle(func.Owner()); | 331 Class& func_class = Class::Handle(func.Owner()); |
(...skipping 2387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2695 } | 2719 } |
2696 | 2720 |
2697 | 2721 |
2698 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2722 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
2699 ASSERT(bpt->next() == NULL); | 2723 ASSERT(bpt->next() == NULL); |
2700 bpt->set_next(code_breakpoints_); | 2724 bpt->set_next(code_breakpoints_); |
2701 code_breakpoints_ = bpt; | 2725 code_breakpoints_ = bpt; |
2702 } | 2726 } |
2703 | 2727 |
2704 } // namespace dart | 2728 } // namespace dart |
OLD | NEW |