Chromium Code Reviews| 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 #ifndef V8_DEBUG_DEBUG_H_ | 5 #ifndef V8_DEBUG_DEBUG_H_ |
| 6 #define V8_DEBUG_DEBUG_H_ | 6 #define V8_DEBUG_DEBUG_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 void Iterate(ObjectVisitor* v); | 511 void Iterate(ObjectVisitor* v); |
| 512 | 512 |
| 513 bool CheckExecutionState(int id) { | 513 bool CheckExecutionState(int id) { |
| 514 return CheckExecutionState() && break_id() == id; | 514 return CheckExecutionState() && break_id() == id; |
| 515 } | 515 } |
| 516 | 516 |
| 517 bool CheckExecutionState() { | 517 bool CheckExecutionState() { |
| 518 return is_active() && !debug_context().is_null() && break_id() != 0; | 518 return is_active() && !debug_context().is_null() && break_id() != 0; |
| 519 } | 519 } |
| 520 | 520 |
| 521 bool PerformReadOnlyCheck(Handle<JSFunction> function); | |
| 522 | |
| 521 // Flags and states. | 523 // Flags and states. |
| 522 DebugScope* debugger_entry() { | 524 DebugScope* debugger_entry() { |
| 523 return reinterpret_cast<DebugScope*>( | 525 return reinterpret_cast<DebugScope*>( |
| 524 base::NoBarrier_Load(&thread_local_.current_debug_scope_)); | 526 base::NoBarrier_Load(&thread_local_.current_debug_scope_)); |
| 525 } | 527 } |
| 526 inline Handle<Context> debug_context() { return debug_context_; } | 528 inline Handle<Context> debug_context() { return debug_context_; } |
| 527 | 529 |
| 528 void set_live_edit_enabled(bool v) { live_edit_enabled_ = v; } | 530 void set_live_edit_enabled(bool v) { live_edit_enabled_ = v; } |
| 529 bool live_edit_enabled() const { | 531 bool live_edit_enabled() const { |
| 530 return FLAG_enable_liveedit && live_edit_enabled_; | 532 return FLAG_enable_liveedit && live_edit_enabled_; |
| 531 } | 533 } |
| 532 | 534 |
| 533 inline bool is_active() const { return is_active_; } | 535 inline bool is_active() const { return is_active_; } |
| 534 inline bool is_loaded() const { return !debug_context_.is_null(); } | 536 inline bool is_loaded() const { return !debug_context_.is_null(); } |
| 535 inline bool in_debug_scope() const { | 537 inline bool in_debug_scope() const { |
| 536 return !!base::NoBarrier_Load(&thread_local_.current_debug_scope_); | 538 return !!base::NoBarrier_Load(&thread_local_.current_debug_scope_); |
| 537 } | 539 } |
| 538 void set_break_points_active(bool v) { break_points_active_ = v; } | 540 void set_break_points_active(bool v) { break_points_active_ = v; } |
| 539 bool break_points_active() const { return break_points_active_; } | 541 bool break_points_active() const { return break_points_active_; } |
| 542 bool needs_readonly_check() const { return needs_readonly_check_; } | |
| 540 | 543 |
| 541 StackFrame::Id break_frame_id() { return thread_local_.break_frame_id_; } | 544 StackFrame::Id break_frame_id() { return thread_local_.break_frame_id_; } |
| 542 int break_id() { return thread_local_.break_id_; } | 545 int break_id() { return thread_local_.break_id_; } |
| 543 | 546 |
| 544 Handle<Object> return_value() { return thread_local_.return_value_; } | 547 Handle<Object> return_value() { return thread_local_.return_value_; } |
| 545 void set_return_value(Handle<Object> value) { | 548 void set_return_value(Handle<Object> value) { |
| 546 thread_local_.return_value_ = value; | 549 thread_local_.return_value_ = value; |
| 547 } | 550 } |
| 548 | 551 |
| 549 // Support for embedding into generated code. | 552 // Support for embedding into generated code. |
| 550 Address is_active_address() { | 553 Address is_active_address() { |
| 551 return reinterpret_cast<Address>(&is_active_); | 554 return reinterpret_cast<Address>(&is_active_); |
| 552 } | 555 } |
| 553 | 556 |
| 557 Address hook_on_function_call_address() { | |
| 558 return reinterpret_cast<Address>(&hook_on_function_call_); | |
| 559 } | |
| 560 | |
| 554 Address after_break_target_address() { | 561 Address after_break_target_address() { |
| 555 return reinterpret_cast<Address>(&after_break_target_); | 562 return reinterpret_cast<Address>(&after_break_target_); |
| 556 } | 563 } |
| 557 | 564 |
| 558 Address last_step_action_address() { | 565 Address last_step_action_address() { |
| 559 return reinterpret_cast<Address>(&thread_local_.last_step_action_); | 566 return reinterpret_cast<Address>(&thread_local_.last_step_action_); |
| 560 } | 567 } |
| 561 | 568 |
| 562 Address suspended_generator_address() { | 569 Address suspended_generator_address() { |
| 563 return reinterpret_cast<Address>(&thread_local_.suspended_generator_); | 570 return reinterpret_cast<Address>(&thread_local_.suspended_generator_); |
| 564 } | 571 } |
| 565 | 572 |
| 566 StepAction last_step_action() { return thread_local_.last_step_action_; } | 573 StepAction last_step_action() { return thread_local_.last_step_action_; } |
| 567 | 574 |
| 568 DebugFeatureTracker* feature_tracker() { return &feature_tracker_; } | 575 DebugFeatureTracker* feature_tracker() { return &feature_tracker_; } |
| 569 | 576 |
| 570 private: | 577 private: |
| 571 explicit Debug(Isolate* isolate); | 578 explicit Debug(Isolate* isolate); |
| 572 | 579 |
| 573 void UpdateState(); | 580 void UpdateState(); |
| 581 void UpdateHookOnFunctionCall(); | |
| 574 void Unload(); | 582 void Unload(); |
| 575 void SetNextBreakId() { | 583 void SetNextBreakId() { |
| 576 thread_local_.break_id_ = ++thread_local_.break_count_; | 584 thread_local_.break_id_ = ++thread_local_.break_count_; |
| 577 } | 585 } |
| 578 | 586 |
| 579 // Check whether there are commands in the command queue. | 587 // Check whether there are commands in the command queue. |
| 580 inline bool has_commands() const { return !command_queue_.IsEmpty(); } | 588 inline bool has_commands() const { return !command_queue_.IsEmpty(); } |
| 581 inline bool ignore_events() const { return is_suppressed_ || !is_active_; } | 589 inline bool ignore_events() const { return is_suppressed_ || !is_active_; } |
| 582 inline bool break_disabled() const { | 590 inline bool break_disabled() const { |
| 583 return break_disabled_ || in_debug_event_listener_; | 591 return break_disabled_ || in_debug_event_listener_; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 Handle<Object> event_listener_; | 668 Handle<Object> event_listener_; |
| 661 Handle<Object> event_listener_data_; | 669 Handle<Object> event_listener_data_; |
| 662 | 670 |
| 663 v8::Debug::MessageHandler message_handler_; | 671 v8::Debug::MessageHandler message_handler_; |
| 664 | 672 |
| 665 static const int kQueueInitialSize = 4; | 673 static const int kQueueInitialSize = 4; |
| 666 base::Semaphore command_received_; // Signaled for each command received. | 674 base::Semaphore command_received_; // Signaled for each command received. |
| 667 LockingCommandMessageQueue command_queue_; | 675 LockingCommandMessageQueue command_queue_; |
| 668 | 676 |
| 669 bool is_active_; | 677 bool is_active_; |
| 678 bool hook_on_function_call_; | |
|
jgruber
2017/01/10 12:46:37
A brief comment about what each of these new varia
Yang
2017/01/10 14:14:06
Done.
| |
| 670 bool is_suppressed_; | 679 bool is_suppressed_; |
| 671 bool live_edit_enabled_; | 680 bool live_edit_enabled_; |
| 672 bool break_disabled_; | 681 bool break_disabled_; |
| 673 bool break_points_active_; | 682 bool break_points_active_; |
| 674 bool in_debug_event_listener_; | 683 bool in_debug_event_listener_; |
| 675 bool break_on_exception_; | 684 bool break_on_exception_; |
| 676 bool break_on_uncaught_exception_; | 685 bool break_on_uncaught_exception_; |
| 686 bool needs_readonly_check_; | |
| 687 bool readonly_check_failed_; | |
| 677 | 688 |
| 678 DebugInfoListNode* debug_info_list_; // List of active debug info objects. | 689 DebugInfoListNode* debug_info_list_; // List of active debug info objects. |
| 679 | 690 |
| 680 // Storage location for jump when exiting debug break calls. | 691 // Storage location for jump when exiting debug break calls. |
| 681 // Note that this address is not GC safe. It should be computed immediately | 692 // Note that this address is not GC safe. It should be computed immediately |
| 682 // before returning to the DebugBreakCallHelper. | 693 // before returning to the DebugBreakCallHelper. |
| 683 Address after_break_target_; | 694 Address after_break_target_; |
| 684 | 695 |
| 685 // Used to collect histogram data on debugger feature usage. | 696 // Used to collect histogram data on debugger feature usage. |
| 686 DebugFeatureTracker feature_tracker_; | 697 DebugFeatureTracker feature_tracker_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 726 // Storage location for registers when handling debug break calls | 737 // Storage location for registers when handling debug break calls |
| 727 ThreadLocal thread_local_; | 738 ThreadLocal thread_local_; |
| 728 | 739 |
| 729 Isolate* isolate_; | 740 Isolate* isolate_; |
| 730 | 741 |
| 731 friend class Isolate; | 742 friend class Isolate; |
| 732 friend class DebugScope; | 743 friend class DebugScope; |
| 733 friend class DisableBreak; | 744 friend class DisableBreak; |
| 734 friend class LiveEdit; | 745 friend class LiveEdit; |
| 735 friend class SuppressDebug; | 746 friend class SuppressDebug; |
| 747 friend class ReadOnlyEvaluate; | |
| 736 | 748 |
| 737 friend Handle<FixedArray> GetDebuggedFunctions(); // In test-debug.cc | 749 friend Handle<FixedArray> GetDebuggedFunctions(); // In test-debug.cc |
| 738 friend void CheckDebuggerUnloaded(bool check_functions); // In test-debug.cc | 750 friend void CheckDebuggerUnloaded(bool check_functions); // In test-debug.cc |
| 739 | 751 |
| 740 DISALLOW_COPY_AND_ASSIGN(Debug); | 752 DISALLOW_COPY_AND_ASSIGN(Debug); |
| 741 }; | 753 }; |
| 742 | 754 |
| 743 | 755 |
| 744 // This scope is used to load and enter the debug context and create a new | 756 // This scope is used to load and enter the debug context and create a new |
| 745 // break state. Leaving the scope will restore the previous state. | 757 // break state. Leaving the scope will restore the previous state. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 799 debug_->is_suppressed_ = true; | 811 debug_->is_suppressed_ = true; |
| 800 } | 812 } |
| 801 ~SuppressDebug() { debug_->is_suppressed_ = old_state_; } | 813 ~SuppressDebug() { debug_->is_suppressed_ = old_state_; } |
| 802 | 814 |
| 803 private: | 815 private: |
| 804 Debug* debug_; | 816 Debug* debug_; |
| 805 bool old_state_; | 817 bool old_state_; |
| 806 DISALLOW_COPY_AND_ASSIGN(SuppressDebug); | 818 DISALLOW_COPY_AND_ASSIGN(SuppressDebug); |
| 807 }; | 819 }; |
| 808 | 820 |
| 821 class ReadOnlyEvaluate { | |
|
jgruber
2017/01/10 12:46:37
Maybe ReadOnlyEvaluateScope?
Yang
2017/01/10 14:14:06
Done.
| |
| 822 public: | |
| 823 ReadOnlyEvaluate(Debug* debug, bool readonly) | |
| 824 : debug_(debug), old_state_(debug->needs_readonly_check_) { | |
| 825 debug_->needs_readonly_check_ |= readonly; | |
| 826 debug_->UpdateHookOnFunctionCall(); | |
| 827 debug_->readonly_check_failed_ = false; | |
| 828 } | |
| 829 ~ReadOnlyEvaluate(); | |
| 830 | |
| 831 private: | |
| 832 Debug* debug_; | |
| 833 bool old_state_; | |
|
jgruber
2017/01/10 12:46:37
Maybe old_needs_readonly_check_?
| |
| 834 DISALLOW_COPY_AND_ASSIGN(ReadOnlyEvaluate); | |
| 835 }; | |
| 809 | 836 |
| 810 // Code generator routines. | 837 // Code generator routines. |
| 811 class DebugCodegen : public AllStatic { | 838 class DebugCodegen : public AllStatic { |
| 812 public: | 839 public: |
| 813 enum DebugBreakCallHelperMode { | 840 enum DebugBreakCallHelperMode { |
| 814 SAVE_RESULT_REGISTER, | 841 SAVE_RESULT_REGISTER, |
| 815 IGNORE_RESULT_REGISTER | 842 IGNORE_RESULT_REGISTER |
| 816 }; | 843 }; |
| 817 | 844 |
| 818 static void GenerateDebugBreakStub(MacroAssembler* masm, | 845 static void GenerateDebugBreakStub(MacroAssembler* masm, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 831 Handle<Code> code); | 858 Handle<Code> code); |
| 832 static bool DebugBreakSlotIsPatched(Address pc); | 859 static bool DebugBreakSlotIsPatched(Address pc); |
| 833 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); | 860 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); |
| 834 }; | 861 }; |
| 835 | 862 |
| 836 | 863 |
| 837 } // namespace internal | 864 } // namespace internal |
| 838 } // namespace v8 | 865 } // namespace v8 |
| 839 | 866 |
| 840 #endif // V8_DEBUG_DEBUG_H_ | 867 #endif // V8_DEBUG_DEBUG_H_ |
| OLD | NEW |