| 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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 Debugger::Debugger() | 772 Debugger::Debugger() |
| 773 : isolate_(NULL), | 773 : isolate_(NULL), |
| 774 isolate_id_(ILLEGAL_ISOLATE_ID), | 774 isolate_id_(ILLEGAL_ISOLATE_ID), |
| 775 initialized_(false), | 775 initialized_(false), |
| 776 next_id_(1), | 776 next_id_(1), |
| 777 stack_trace_(NULL), | 777 stack_trace_(NULL), |
| 778 obj_cache_(NULL), | 778 obj_cache_(NULL), |
| 779 src_breakpoints_(NULL), | 779 src_breakpoints_(NULL), |
| 780 code_breakpoints_(NULL), | 780 code_breakpoints_(NULL), |
| 781 resume_action_(kContinue), | 781 resume_action_(kContinue), |
| 782 last_bpt_line_(-1), | |
| 783 ignore_breakpoints_(false), | 782 ignore_breakpoints_(false), |
| 784 exc_pause_info_(kNoPauseOnExceptions) { | 783 exc_pause_info_(kNoPauseOnExceptions) { |
| 785 } | 784 } |
| 786 | 785 |
| 787 | 786 |
| 788 Debugger::~Debugger() { | 787 Debugger::~Debugger() { |
| 789 PortMap::ClosePort(isolate_id_); | 788 PortMap::ClosePort(isolate_id_); |
| 790 isolate_id_ = ILLEGAL_ISOLATE_ID; | 789 isolate_id_ = ILLEGAL_ISOLATE_ID; |
| 791 ASSERT(src_breakpoints_ == NULL); | 790 ASSERT(src_breakpoints_ == NULL); |
| 792 ASSERT(code_breakpoints_ == NULL); | 791 ASSERT(code_breakpoints_ == NULL); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 if (ignore_breakpoints_ || | 1016 if (ignore_breakpoints_ || |
| 1018 (stack_trace_ != NULL) || | 1017 (stack_trace_ != NULL) || |
| 1019 (event_handler_ == NULL) || | 1018 (event_handler_ == NULL) || |
| 1020 (exc_pause_info_ == kNoPauseOnExceptions)) { | 1019 (exc_pause_info_ == kNoPauseOnExceptions)) { |
| 1021 return; | 1020 return; |
| 1022 } | 1021 } |
| 1023 DebuggerStackTrace* stack_trace = CollectStackTrace(); | 1022 DebuggerStackTrace* stack_trace = CollectStackTrace(); |
| 1024 if (!ShouldPauseOnException(stack_trace, exc)) { | 1023 if (!ShouldPauseOnException(stack_trace, exc)) { |
| 1025 return; | 1024 return; |
| 1026 } | 1025 } |
| 1027 // No single-stepping possible after this pause event. | |
| 1028 last_bpt_line_ = -1; | |
| 1029 ASSERT(stack_trace_ == NULL); | 1026 ASSERT(stack_trace_ == NULL); |
| 1030 stack_trace_ = stack_trace; | 1027 stack_trace_ = stack_trace; |
| 1031 ASSERT(obj_cache_ == NULL); | 1028 ASSERT(obj_cache_ == NULL); |
| 1032 obj_cache_ = new RemoteObjectCache(64); | 1029 obj_cache_ = new RemoteObjectCache(64); |
| 1033 DebuggerEvent event; | 1030 DebuggerEvent event; |
| 1034 event.type = kExceptionThrown; | 1031 event.type = kExceptionThrown; |
| 1035 event.exception = &exc; | 1032 event.exception = &exc; |
| 1036 ASSERT(event_handler_ != NULL); | 1033 ASSERT(event_handler_ != NULL); |
| 1037 (*event_handler_)(&event); | 1034 (*event_handler_)(&event); |
| 1038 stack_trace_ = NULL; | 1035 stack_trace_ = NULL; |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 if (FLAG_verbose_debug) { | 1522 if (FLAG_verbose_debug) { |
| 1526 OS::Print(">>> hit %s breakpoint at %s:%"Pd" " | 1523 OS::Print(">>> hit %s breakpoint at %s:%"Pd" " |
| 1527 "(token %"Pd") (address %#"Px")\n", | 1524 "(token %"Pd") (address %#"Px")\n", |
| 1528 bpt->IsInternal() ? "internal" : "user", | 1525 bpt->IsInternal() ? "internal" : "user", |
| 1529 String::Handle(bpt->SourceUrl()).ToCString(), | 1526 String::Handle(bpt->SourceUrl()).ToCString(), |
| 1530 bpt->LineNumber(), | 1527 bpt->LineNumber(), |
| 1531 bpt->token_pos(), | 1528 bpt->token_pos(), |
| 1532 top_frame->pc()); | 1529 top_frame->pc()); |
| 1533 } | 1530 } |
| 1534 | 1531 |
| 1535 if (!bpt->IsInternal()) { | 1532 resume_action_ = kContinue; |
| 1536 // This is a user-defined breakpoint so we call the breakpoint | 1533 if (event_handler_ != NULL) { |
| 1537 // callback even if it is on the same line as the previous breakpoint. | 1534 ASSERT(stack_trace_ == NULL); |
| 1538 last_bpt_line_ = -1; | 1535 ASSERT(obj_cache_ == NULL); |
| 1539 } | 1536 obj_cache_ = new RemoteObjectCache(64); |
| 1540 | 1537 stack_trace_ = stack_trace; |
| 1541 bool notify_frontend = | 1538 DebuggerEvent event; |
| 1542 (last_bpt_line_ < 0) || (last_bpt_line_ != bpt->LineNumber()); | 1539 event.type = kBreakpointReached; |
| 1543 | 1540 ASSERT(stack_trace->Length() > 0); |
| 1544 if (notify_frontend) { | 1541 event.top_frame = stack_trace->ActivationFrameAt(0); |
| 1545 resume_action_ = kContinue; | 1542 (*event_handler_)(&event); |
| 1546 if (event_handler_ != NULL) { | 1543 stack_trace_ = NULL; |
| 1547 ASSERT(stack_trace_ == NULL); | 1544 obj_cache_ = NULL; // Remote object cache is zone allocated. |
| 1548 ASSERT(obj_cache_ == NULL); | |
| 1549 obj_cache_ = new RemoteObjectCache(64); | |
| 1550 stack_trace_ = stack_trace; | |
| 1551 DebuggerEvent event; | |
| 1552 event.type = kBreakpointReached; | |
| 1553 ASSERT(stack_trace->Length() > 0); | |
| 1554 event.top_frame = stack_trace->ActivationFrameAt(0); | |
| 1555 (*event_handler_)(&event); | |
| 1556 stack_trace_ = NULL; | |
| 1557 obj_cache_ = NULL; // Remote object cache is zone allocated. | |
| 1558 last_bpt_line_ = bpt->LineNumber(); | |
| 1559 } | |
| 1560 } | 1545 } |
| 1561 | 1546 |
| 1562 Function& currently_instrumented_func = Function::Handle(); | 1547 Function& currently_instrumented_func = Function::Handle(); |
| 1563 if (bpt->IsInternal()) { | 1548 if (bpt->IsInternal()) { |
| 1564 currently_instrumented_func = bpt->function(); | 1549 currently_instrumented_func = bpt->function(); |
| 1565 } | 1550 } |
| 1566 Function& func_to_instrument = Function::Handle(); | 1551 Function& func_to_instrument = Function::Handle(); |
| 1567 if (resume_action_ == kContinue) { | 1552 if (resume_action_ == kContinue) { |
| 1568 // Nothing to do here, any potential instrumentation will be removed | 1553 // Nothing to do here, any potential instrumentation will be removed |
| 1569 // below. | 1554 // below. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 ASSERT(resume_action_ == kStepOut); | 1634 ASSERT(resume_action_ == kStepOut); |
| 1650 // Set stepping breakpoints in the caller. | 1635 // Set stepping breakpoints in the caller. |
| 1651 if (stack_trace->Length() > 1) { | 1636 if (stack_trace->Length() > 1) { |
| 1652 ActivationFrame* caller_frame = stack_trace->ActivationFrameAt(1); | 1637 ActivationFrame* caller_frame = stack_trace->ActivationFrameAt(1); |
| 1653 func_to_instrument = caller_frame->function().raw(); | 1638 func_to_instrument = caller_frame->function().raw(); |
| 1654 } | 1639 } |
| 1655 } | 1640 } |
| 1656 | 1641 |
| 1657 if (func_to_instrument.IsNull() || | 1642 if (func_to_instrument.IsNull() || |
| 1658 (func_to_instrument.raw() != currently_instrumented_func.raw())) { | 1643 (func_to_instrument.raw() != currently_instrumented_func.raw())) { |
| 1659 last_bpt_line_ = -1; | |
| 1660 RemoveInternalBreakpoints(); // *bpt is now invalid. | 1644 RemoveInternalBreakpoints(); // *bpt is now invalid. |
| 1661 if (!func_to_instrument.IsNull()) { | 1645 if (!func_to_instrument.IsNull()) { |
| 1662 InstrumentForStepping(func_to_instrument); | 1646 InstrumentForStepping(func_to_instrument); |
| 1663 } | 1647 } |
| 1664 } | 1648 } |
| 1665 } | 1649 } |
| 1666 | 1650 |
| 1667 | 1651 |
| 1668 void Debugger::Initialize(Isolate* isolate) { | 1652 void Debugger::Initialize(Isolate* isolate) { |
| 1669 if (initialized_) { | 1653 if (initialized_) { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1841 } | 1825 } |
| 1842 | 1826 |
| 1843 | 1827 |
| 1844 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1828 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 1845 ASSERT(bpt->next() == NULL); | 1829 ASSERT(bpt->next() == NULL); |
| 1846 bpt->set_next(code_breakpoints_); | 1830 bpt->set_next(code_breakpoints_); |
| 1847 code_breakpoints_ = bpt; | 1831 code_breakpoints_ = bpt; |
| 1848 } | 1832 } |
| 1849 | 1833 |
| 1850 } // namespace dart | 1834 } // namespace dart |
| OLD | NEW |