| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/debug/debug.h" | 5 #include "src/debug/debug.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 481 |
| 482 | 482 |
| 483 void Debug::Unload() { | 483 void Debug::Unload() { |
| 484 ClearAllBreakPoints(); | 484 ClearAllBreakPoints(); |
| 485 ClearStepping(); | 485 ClearStepping(); |
| 486 RemoveDebugDelegate(); | 486 RemoveDebugDelegate(); |
| 487 | 487 |
| 488 // Return debugger is not loaded. | 488 // Return debugger is not loaded. |
| 489 if (!is_loaded()) return; | 489 if (!is_loaded()) return; |
| 490 | 490 |
| 491 if (FLAG_block_coverage) RemoveAllCoverageInfos(); |
| 492 |
| 491 // Clear debugger context global handle. | 493 // Clear debugger context global handle. |
| 492 GlobalHandles::Destroy(Handle<Object>::cast(debug_context_).location()); | 494 GlobalHandles::Destroy(Handle<Object>::cast(debug_context_).location()); |
| 493 debug_context_ = Handle<Context>(); | 495 debug_context_ = Handle<Context>(); |
| 494 } | 496 } |
| 495 | 497 |
| 496 void Debug::Break(JavaScriptFrame* frame) { | 498 void Debug::Break(JavaScriptFrame* frame) { |
| 497 // Initialize LiveEdit. | 499 // Initialize LiveEdit. |
| 498 LiveEdit::InitializeThreadLocal(this); | 500 LiveEdit::InitializeThreadLocal(this); |
| 499 | 501 |
| 500 // Just continue if breaks are disabled or debugger cannot be loaded. | 502 // Just continue if breaks are disabled or debugger cannot be loaded. |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 } else { | 816 } else { |
| 815 ApplyBreakPoints(debug_info); | 817 ApplyBreakPoints(debug_info); |
| 816 } | 818 } |
| 817 return; | 819 return; |
| 818 } | 820 } |
| 819 } | 821 } |
| 820 } | 822 } |
| 821 | 823 |
| 822 // Clear out all the debug break code. | 824 // Clear out all the debug break code. |
| 823 void Debug::ClearAllBreakPoints() { | 825 void Debug::ClearAllBreakPoints() { |
| 824 DebugInfoListNode* prev = nullptr; | 826 ClearAllDebugInfos([=](Handle<DebugInfo> info) { |
| 825 DebugInfoListNode* current = debug_info_list_; | 827 ClearBreakPoints(info); |
| 826 while (current != nullptr) { | 828 return info->ClearBreakInfo(); |
| 827 DebugInfoListNode* next = current->next(); | 829 }); |
| 828 Handle<DebugInfo> debug_info = current->debug_info(); | |
| 829 ClearBreakPoints(debug_info); | |
| 830 if (debug_info->ClearBreakInfo()) { | |
| 831 FreeDebugInfoListNode(prev, current); | |
| 832 current = next; | |
| 833 } else { | |
| 834 prev = current; | |
| 835 current = next; | |
| 836 } | |
| 837 } | |
| 838 } | 830 } |
| 839 | 831 |
| 840 void Debug::FloodWithOneShot(Handle<SharedFunctionInfo> shared, | 832 void Debug::FloodWithOneShot(Handle<SharedFunctionInfo> shared, |
| 841 bool returns_only) { | 833 bool returns_only) { |
| 842 if (IsBlackboxed(shared)) return; | 834 if (IsBlackboxed(shared)) return; |
| 843 // Make sure the function is compiled and has set up the debug info. | 835 // Make sure the function is compiled and has set up the debug info. |
| 844 if (!EnsureBreakInfo(shared)) return; | 836 if (!EnsureBreakInfo(shared)) return; |
| 845 Handle<DebugInfo> debug_info(shared->GetDebugInfo()); | 837 Handle<DebugInfo> debug_info(shared->GetDebugInfo()); |
| 846 // Flood the function with break points. | 838 // Flood the function with break points. |
| 847 if (debug_info->HasDebugCode()) { | 839 if (debug_info->HasDebugCode()) { |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 | 1603 |
| 1612 // Create debug info and add it to the list. | 1604 // Create debug info and add it to the list. |
| 1613 Handle<DebugInfo> debug_info = isolate_->factory()->NewDebugInfo(shared); | 1605 Handle<DebugInfo> debug_info = isolate_->factory()->NewDebugInfo(shared); |
| 1614 DebugInfoListNode* node = new DebugInfoListNode(*debug_info); | 1606 DebugInfoListNode* node = new DebugInfoListNode(*debug_info); |
| 1615 node->set_next(debug_info_list_); | 1607 node->set_next(debug_info_list_); |
| 1616 debug_info_list_ = node; | 1608 debug_info_list_ = node; |
| 1617 | 1609 |
| 1618 return debug_info; | 1610 return debug_info; |
| 1619 } | 1611 } |
| 1620 | 1612 |
| 1613 void Debug::InstallCoverageInfo(Handle<SharedFunctionInfo> shared, |
| 1614 Handle<CoverageInfo> coverage_info) { |
| 1615 DCHECK(FLAG_block_coverage); |
| 1616 DCHECK(!coverage_info.is_null()); |
| 1617 |
| 1618 Handle<DebugInfo> debug_info = GetOrCreateDebugInfo(shared); |
| 1619 |
| 1620 DCHECK(!debug_info->HasCoverageInfo()); |
| 1621 |
| 1622 debug_info->set_flags(debug_info->flags() | DebugInfo::kHasCoverageInfo); |
| 1623 debug_info->set_coverage_info(*coverage_info); |
| 1624 } |
| 1625 |
| 1626 void Debug::RemoveAllCoverageInfos() { |
| 1627 DCHECK(FLAG_block_coverage); |
| 1628 ClearAllDebugInfos( |
| 1629 [=](Handle<DebugInfo> info) { return info->ClearCoverageInfo(); }); |
| 1630 } |
| 1631 |
| 1621 void Debug::FindDebugInfo(Handle<DebugInfo> debug_info, | 1632 void Debug::FindDebugInfo(Handle<DebugInfo> debug_info, |
| 1622 DebugInfoListNode** prev, DebugInfoListNode** curr) { | 1633 DebugInfoListNode** prev, DebugInfoListNode** curr) { |
| 1623 HandleScope scope(isolate_); | 1634 HandleScope scope(isolate_); |
| 1624 *prev = nullptr; | 1635 *prev = nullptr; |
| 1625 *curr = debug_info_list_; | 1636 *curr = debug_info_list_; |
| 1626 while (*curr != nullptr) { | 1637 while (*curr != nullptr) { |
| 1627 if ((*curr)->debug_info().is_identical_to(debug_info)) return; | 1638 if ((*curr)->debug_info().is_identical_to(debug_info)) return; |
| 1628 *prev = *curr; | 1639 *prev = *curr; |
| 1629 *curr = (*curr)->next(); | 1640 *curr = (*curr)->next(); |
| 1630 } | 1641 } |
| 1631 | 1642 |
| 1632 UNREACHABLE(); | 1643 UNREACHABLE(); |
| 1633 } | 1644 } |
| 1634 | 1645 |
| 1646 void Debug::ClearAllDebugInfos(DebugInfoClearFunction clear_function) { |
| 1647 DebugInfoListNode* prev = nullptr; |
| 1648 DebugInfoListNode* current = debug_info_list_; |
| 1649 while (current != nullptr) { |
| 1650 DebugInfoListNode* next = current->next(); |
| 1651 Handle<DebugInfo> debug_info = current->debug_info(); |
| 1652 if (clear_function(debug_info)) { |
| 1653 FreeDebugInfoListNode(prev, current); |
| 1654 current = next; |
| 1655 } else { |
| 1656 prev = current; |
| 1657 current = next; |
| 1658 } |
| 1659 } |
| 1660 } |
| 1661 |
| 1635 void Debug::RemoveBreakInfoAndMaybeFree(Handle<DebugInfo> debug_info) { | 1662 void Debug::RemoveBreakInfoAndMaybeFree(Handle<DebugInfo> debug_info) { |
| 1636 bool should_unlink = debug_info->ClearBreakInfo(); | 1663 bool should_unlink = debug_info->ClearBreakInfo(); |
| 1637 if (should_unlink) { | 1664 if (should_unlink) { |
| 1638 DebugInfoListNode* prev; | 1665 DebugInfoListNode* prev; |
| 1639 DebugInfoListNode* node; | 1666 DebugInfoListNode* node; |
| 1640 FindDebugInfo(debug_info, &prev, &node); | 1667 FindDebugInfo(debug_info, &prev, &node); |
| 1641 FreeDebugInfoListNode(prev, node); | 1668 FreeDebugInfoListNode(prev, node); |
| 1642 } | 1669 } |
| 1643 } | 1670 } |
| 1644 | 1671 |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2501 isolate_->Throw(*isolate_->factory()->NewEvalError( | 2528 isolate_->Throw(*isolate_->factory()->NewEvalError( |
| 2502 MessageTemplate::kNoSideEffectDebugEvaluate)); | 2529 MessageTemplate::kNoSideEffectDebugEvaluate)); |
| 2503 } | 2530 } |
| 2504 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_); | 2531 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_); |
| 2505 isolate_->debug()->UpdateHookOnFunctionCall(); | 2532 isolate_->debug()->UpdateHookOnFunctionCall(); |
| 2506 isolate_->debug()->side_effect_check_failed_ = false; | 2533 isolate_->debug()->side_effect_check_failed_ = false; |
| 2507 } | 2534 } |
| 2508 | 2535 |
| 2509 } // namespace internal | 2536 } // namespace internal |
| 2510 } // namespace v8 | 2537 } // namespace v8 |
| OLD | NEW |