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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 isolate_->PauseEventHandler(); | 323 isolate_->PauseEventHandler(); |
324 } else if (event_handler_ != NULL) { | 324 } else if (event_handler_ != NULL) { |
325 (*event_handler_)(event); | 325 (*event_handler_)(event); |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 if (ServiceNeedsDebuggerEvent(event->type()) && event->IsPauseEvent()) { | 329 if (ServiceNeedsDebuggerEvent(event->type()) && event->IsPauseEvent()) { |
330 // If we were paused, notify the service that we have resumed. | 330 // If we were paused, notify the service that we have resumed. |
331 const Error& error = | 331 const Error& error = |
332 Error::Handle(Thread::Current()->sticky_error()); | 332 Error::Handle(Thread::Current()->sticky_error()); |
333 ASSERT(error.IsNull() || error.IsUnwindError()); | 333 ASSERT(error.IsNull() || |
| 334 error.IsUnwindError() || |
| 335 error.IsUnhandledException()); |
334 | 336 |
335 // Only send a resume event when the isolate is not unwinding. | 337 // Only send a resume event when the isolate is not unwinding. |
336 if (!error.IsUnwindError()) { | 338 if (!error.IsUnwindError()) { |
337 ServiceEvent service_event(event->isolate(), ServiceEvent::kResume); | 339 ServiceEvent service_event(event->isolate(), ServiceEvent::kResume); |
338 service_event.set_top_frame(event->top_frame()); | 340 service_event.set_top_frame(event->top_frame()); |
339 Service::HandleEvent(&service_event); | 341 Service::HandleEvent(&service_event); |
340 } | 342 } |
341 } | 343 } |
342 } | 344 } |
343 | 345 |
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 exc_pause_info_ = pause_info; | 1631 exc_pause_info_ = pause_info; |
1630 } | 1632 } |
1631 | 1633 |
1632 | 1634 |
1633 Dart_ExceptionPauseInfo Debugger::GetExceptionPauseInfo() const { | 1635 Dart_ExceptionPauseInfo Debugger::GetExceptionPauseInfo() const { |
1634 return exc_pause_info_; | 1636 return exc_pause_info_; |
1635 } | 1637 } |
1636 | 1638 |
1637 | 1639 |
1638 bool Debugger::ShouldPauseOnException(DebuggerStackTrace* stack_trace, | 1640 bool Debugger::ShouldPauseOnException(DebuggerStackTrace* stack_trace, |
1639 const Instance& exc) { | 1641 const Instance& exception) { |
1640 if (exc_pause_info_ == kNoPauseOnExceptions) { | 1642 if (exc_pause_info_ == kNoPauseOnExceptions) { |
1641 return false; | 1643 return false; |
1642 } | 1644 } |
1643 if (exc_pause_info_ == kPauseOnAllExceptions) { | 1645 if (exc_pause_info_ == kPauseOnAllExceptions) { |
1644 return true; | 1646 return true; |
1645 } | 1647 } |
1646 ASSERT(exc_pause_info_ == kPauseOnUnhandledExceptions); | 1648 ASSERT(exc_pause_info_ == kPauseOnUnhandledExceptions); |
1647 ActivationFrame* handler_frame = stack_trace->GetHandlerFrame(exc); | 1649 ActivationFrame* handler_frame = stack_trace->GetHandlerFrame(exception); |
1648 if (handler_frame == NULL) { | 1650 if (handler_frame == NULL) { |
1649 // Did not find an exception handler that catches this exception. | 1651 // Did not find an exception handler that catches this exception. |
1650 // Note that this check is not precise, since we can't check | 1652 // Note that this check is not precise, since we can't check |
1651 // uninstantiated types, i.e. types containing type parameters. | 1653 // uninstantiated types, i.e. types containing type parameters. |
1652 // Thus, we may report an exception as unhandled when in fact | 1654 // Thus, we may report an exception as unhandled when in fact |
1653 // it will be caught once we unwind the stack. | 1655 // it will be caught once we unwind the stack. |
1654 return true; | 1656 return true; |
1655 } | 1657 } |
1656 return false; | 1658 return false; |
1657 } | 1659 } |
1658 | 1660 |
1659 | 1661 |
1660 void Debugger::SignalExceptionThrown(const Instance& exc) { | 1662 void Debugger::SignalExceptionThrown(const Instance& exc) { |
1661 // We ignore this exception event when the VM is executing code invoked | 1663 // We ignore this exception event when the VM is executing code invoked |
1662 // by the debugger to evaluate variables values, when we see a nested | 1664 // by the debugger to evaluate variables values, when we see a nested |
1663 // breakpoint or exception event, or if the debugger is not | 1665 // breakpoint or exception event, or if the debugger is not |
1664 // interested in exception events. | 1666 // interested in exception events. |
1665 if (ignore_breakpoints_ || | 1667 if (ignore_breakpoints_ || |
1666 IsPaused() || | 1668 IsPaused() || |
1667 (exc_pause_info_ == kNoPauseOnExceptions)) { | 1669 (exc_pause_info_ == kNoPauseOnExceptions)) { |
1668 return; | 1670 return; |
1669 } | 1671 } |
1670 DebuggerStackTrace* stack_trace = CollectStackTrace(); | 1672 DebuggerStackTrace* stack_trace = CollectStackTrace(); |
1671 if (!ShouldPauseOnException(stack_trace, exc)) { | 1673 if (!ShouldPauseOnException(stack_trace, exc)) { |
1672 return; | 1674 return; |
1673 } | 1675 } |
1674 DebuggerEvent event(isolate_, DebuggerEvent::kExceptionThrown); | 1676 DebuggerEvent event(isolate_, DebuggerEvent::kExceptionThrown); |
1675 event.set_exception(&exc); | 1677 event.set_exception(&exc); |
1676 ASSERT(stack_trace->Length() > 0); | 1678 if (stack_trace->Length() > 0) { |
1677 event.set_top_frame(stack_trace->FrameAt(0)); | 1679 event.set_top_frame(stack_trace->FrameAt(0)); |
| 1680 } |
1678 ASSERT(stack_trace_ == NULL); | 1681 ASSERT(stack_trace_ == NULL); |
1679 stack_trace_ = stack_trace; | 1682 stack_trace_ = stack_trace; |
1680 Pause(&event); | 1683 Pause(&event); |
1681 stack_trace_ = NULL; | 1684 stack_trace_ = NULL; |
1682 } | 1685 } |
1683 | 1686 |
1684 | 1687 |
1685 static TokenPosition LastTokenOnLine(const TokenStream& tokens, | 1688 static TokenPosition LastTokenOnLine(const TokenStream& tokens, |
1686 TokenPosition pos) { | 1689 TokenPosition pos) { |
1687 TokenStream::Iterator iter(tokens, | 1690 TokenStream::Iterator iter(tokens, |
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3342 | 3345 |
3343 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 3346 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
3344 ASSERT(bpt->next() == NULL); | 3347 ASSERT(bpt->next() == NULL); |
3345 bpt->set_next(code_breakpoints_); | 3348 bpt->set_next(code_breakpoints_); |
3346 code_breakpoints_ = bpt; | 3349 code_breakpoints_ = bpt; |
3347 } | 3350 } |
3348 | 3351 |
3349 #endif // !PRODUCT | 3352 #endif // !PRODUCT |
3350 | 3353 |
3351 } // namespace dart | 3354 } // namespace dart |
OLD | NEW |