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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 303 |
304 if (FLAG_steal_breakpoints && event->IsPauseEvent()) { | 304 if (FLAG_steal_breakpoints && event->IsPauseEvent()) { |
305 // We allow the embedder's default breakpoint handler to be overridden. | 305 // We allow the embedder's default breakpoint handler to be overridden. |
306 isolate_->PauseEventHandler(); | 306 isolate_->PauseEventHandler(); |
307 } else if (event_handler_ != NULL) { | 307 } else if (event_handler_ != NULL) { |
308 (*event_handler_)(event); | 308 (*event_handler_)(event); |
309 } | 309 } |
310 | 310 |
311 if (ServiceNeedsDebuggerEvent(event->type()) && event->IsPauseEvent()) { | 311 if (ServiceNeedsDebuggerEvent(event->type()) && event->IsPauseEvent()) { |
312 // If we were paused, notify the service that we have resumed. | 312 // If we were paused, notify the service that we have resumed. |
313 ServiceEvent service_event(event->isolate(), ServiceEvent::kResume); | 313 const Error& error = |
314 service_event.set_top_frame(event->top_frame()); | 314 Error::Handle(isolate_, isolate_->object_store()->sticky_error()); |
315 Service::HandleEvent(&service_event); | 315 ASSERT(error.IsNull() || error.IsUnwindError()); |
| 316 |
| 317 // Only send a resume event when the isolate is not unwinding. |
| 318 if (!error.IsUnwindError()) { |
| 319 ServiceEvent service_event(event->isolate(), ServiceEvent::kResume); |
| 320 service_event.set_top_frame(event->top_frame()); |
| 321 Service::HandleEvent(&service_event); |
| 322 } |
316 } | 323 } |
317 } | 324 } |
318 | 325 |
319 | 326 |
320 void Debugger::SignalIsolateEvent(DebuggerEvent::EventType type) { | 327 void Debugger::SignalIsolateEvent(DebuggerEvent::EventType type) { |
321 if (HasEventHandler()) { | 328 if (HasEventHandler()) { |
322 DebuggerEvent event(isolate_, type); | 329 DebuggerEvent event(isolate_, type); |
323 ASSERT(event.isolate_id() != ILLEGAL_ISOLATE_ID); | 330 ASSERT(event.isolate_id() != ILLEGAL_ISOLATE_ID); |
324 if (type == DebuggerEvent::kIsolateInterrupted) { | 331 if (type == DebuggerEvent::kIsolateInterrupted) { |
325 DebuggerStackTrace* trace = CollectStackTrace(); | 332 DebuggerStackTrace* trace = CollectStackTrace(); |
(...skipping 17 matching lines...) Expand all Loading... |
343 if (HasEventHandler()) { | 350 if (HasEventHandler()) { |
344 SignalIsolateEvent(DebuggerEvent::kIsolateInterrupted); | 351 SignalIsolateEvent(DebuggerEvent::kIsolateInterrupted); |
345 } | 352 } |
346 Dart_IsolateInterruptCallback callback = isolate_->InterruptCallback(); | 353 Dart_IsolateInterruptCallback callback = isolate_->InterruptCallback(); |
347 if (callback != NULL) { | 354 if (callback != NULL) { |
348 if (!(*callback)()) { | 355 if (!(*callback)()) { |
349 if (FLAG_trace_isolates) { | 356 if (FLAG_trace_isolates) { |
350 OS::Print("[!] Embedder api: terminating isolate:\n" | 357 OS::Print("[!] Embedder api: terminating isolate:\n" |
351 "\tisolate: %s\n", isolate_->name()); | 358 "\tisolate: %s\n", isolate_->name()); |
352 } | 359 } |
353 // TODO(turnidge): We should give the message handler a way to | |
354 // detect when an isolate is unwinding. | |
355 isolate_->message_handler()->set_pause_on_exit(false); | |
356 const String& msg = | 360 const String& msg = |
357 String::Handle(String::New("isolate terminated by embedder")); | 361 String::Handle(String::New("isolate terminated by embedder")); |
358 return UnwindError::New(msg); | 362 return UnwindError::New(msg); |
359 } | 363 } |
360 } | 364 } |
361 | 365 |
362 // If any error occurred while in the debug message loop, return it here. | 366 // If any error occurred while in the debug message loop, return it here. |
363 const Error& error = | 367 const Error& error = |
364 Error::Handle(isolate_, isolate_->object_store()->sticky_error()); | 368 Error::Handle(isolate_, isolate_->object_store()->sticky_error()); |
| 369 ASSERT(error.IsNull() || error.IsUnwindError()); |
365 isolate_->object_store()->clear_sticky_error(); | 370 isolate_->object_store()->clear_sticky_error(); |
366 return error.raw(); | 371 return error.raw(); |
367 } | 372 } |
368 | 373 |
369 | 374 |
370 // The vm service handles breakpoint notifications in a different way | 375 // The vm service handles breakpoint notifications in a different way |
371 // than the regular debugger breakpoint notifications. | 376 // than the regular debugger breakpoint notifications. |
372 static void SendServiceBreakpointEvent(ServiceEvent::EventKind kind, | 377 static void SendServiceBreakpointEvent(ServiceEvent::EventKind kind, |
373 Breakpoint* bpt) { | 378 Breakpoint* bpt) { |
374 if (Service::debug_stream.enabled()) { | 379 if (Service::debug_stream.enabled()) { |
(...skipping 2846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3221 } | 3226 } |
3222 | 3227 |
3223 | 3228 |
3224 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 3229 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
3225 ASSERT(bpt->next() == NULL); | 3230 ASSERT(bpt->next() == NULL); |
3226 bpt->set_next(code_breakpoints_); | 3231 bpt->set_next(code_breakpoints_); |
3227 code_breakpoints_ = bpt; | 3232 code_breakpoints_ = bpt; |
3228 } | 3233 } |
3229 | 3234 |
3230 } // namespace dart | 3235 } // namespace dart |
OLD | NEW |