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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 v8::Debug::ClientData* client_data = NULL); | 419 v8::Debug::ClientData* client_data = NULL); |
420 MUST_USE_RESULT MaybeHandle<Object> Call(Handle<Object> fun, | 420 MUST_USE_RESULT MaybeHandle<Object> Call(Handle<Object> fun, |
421 Handle<Object> data); | 421 Handle<Object> data); |
422 Handle<Context> GetDebugContext(); | 422 Handle<Context> GetDebugContext(); |
423 void HandleDebugBreak(); | 423 void HandleDebugBreak(); |
424 void ProcessDebugMessages(bool debug_command_only); | 424 void ProcessDebugMessages(bool debug_command_only); |
425 | 425 |
426 // Internal logic | 426 // Internal logic |
427 bool Load(); | 427 bool Load(); |
428 void Break(JavaScriptFrame* frame); | 428 void Break(JavaScriptFrame* frame); |
429 void SetAfterBreakTarget(JavaScriptFrame* frame); | |
430 | 429 |
431 // Scripts handling. | 430 // Scripts handling. |
432 Handle<FixedArray> GetLoadedScripts(); | 431 Handle<FixedArray> GetLoadedScripts(); |
433 | 432 |
434 // Break point handling. | 433 // Break point handling. |
435 bool SetBreakPoint(Handle<JSFunction> function, | 434 bool SetBreakPoint(Handle<JSFunction> function, |
436 Handle<Object> break_point_object, | 435 Handle<Object> break_point_object, |
437 int* source_position); | 436 int* source_position); |
438 bool SetBreakPointForScript(Handle<Script> script, | 437 bool SetBreakPointForScript(Handle<Script> script, |
439 Handle<Object> break_point_object, | 438 Handle<Object> break_point_object, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 Handle<SharedFunctionInfo> shared, | 486 Handle<SharedFunctionInfo> shared, |
488 BreakPositionAlignment position_aligment); | 487 BreakPositionAlignment position_aligment); |
489 | 488 |
490 // Check whether a global object is the debug global object. | 489 // Check whether a global object is the debug global object. |
491 bool IsDebugGlobal(JSGlobalObject* global); | 490 bool IsDebugGlobal(JSGlobalObject* global); |
492 | 491 |
493 // Check whether this frame is just about to return. | 492 // Check whether this frame is just about to return. |
494 bool IsBreakAtReturn(JavaScriptFrame* frame); | 493 bool IsBreakAtReturn(JavaScriptFrame* frame); |
495 | 494 |
496 // Support for LiveEdit | 495 // Support for LiveEdit |
497 void FramesHaveBeenDropped(StackFrame::Id new_break_frame_id, | 496 void UpdateBreakFrameId(); |
498 LiveEditFrameDropMode mode); | |
499 | 497 |
500 // Threading support. | 498 // Threading support. |
501 char* ArchiveDebug(char* to); | 499 char* ArchiveDebug(char* to); |
502 char* RestoreDebug(char* from); | 500 char* RestoreDebug(char* from); |
503 static int ArchiveSpacePerThread(); | 501 static int ArchiveSpacePerThread(); |
504 void FreeThreadResources() { } | 502 void FreeThreadResources() { } |
505 void Iterate(ObjectVisitor* v); | 503 void Iterate(ObjectVisitor* v); |
506 | 504 |
507 bool CheckExecutionState(int id) { | 505 bool CheckExecutionState(int id) { |
508 return CheckExecutionState() && break_id() == id; | 506 return CheckExecutionState() && break_id() == id; |
(...skipping 22 matching lines...) Expand all Loading... | |
531 inline bool is_loaded() const { return !debug_context_.is_null(); } | 529 inline bool is_loaded() const { return !debug_context_.is_null(); } |
532 inline bool in_debug_scope() const { | 530 inline bool in_debug_scope() const { |
533 return !!base::NoBarrier_Load(&thread_local_.current_debug_scope_); | 531 return !!base::NoBarrier_Load(&thread_local_.current_debug_scope_); |
534 } | 532 } |
535 void set_break_points_active(bool v) { break_points_active_ = v; } | 533 void set_break_points_active(bool v) { break_points_active_ = v; } |
536 bool break_points_active() const { return break_points_active_; } | 534 bool break_points_active() const { return break_points_active_; } |
537 | 535 |
538 StackFrame::Id break_frame_id() { return thread_local_.break_frame_id_; } | 536 StackFrame::Id break_frame_id() { return thread_local_.break_frame_id_; } |
539 int break_id() { return thread_local_.break_id_; } | 537 int break_id() { return thread_local_.break_id_; } |
540 | 538 |
541 Handle<Object> return_value() { return thread_local_.return_value_; } | 539 Object* return_value() { return thread_local_.return_value_; } |
542 void set_return_value(Handle<Object> value) { | 540 void set_return_value(Object* value) { thread_local_.return_value_ = value; } |
543 thread_local_.return_value_ = value; | |
544 } | |
545 | 541 |
546 // Support for embedding into generated code. | 542 // Support for embedding into generated code. |
547 Address is_active_address() { | 543 Address is_active_address() { |
548 return reinterpret_cast<Address>(&is_active_); | 544 return reinterpret_cast<Address>(&is_active_); |
549 } | 545 } |
550 | 546 |
551 Address hook_on_function_call_address() { | 547 Address hook_on_function_call_address() { |
552 return reinterpret_cast<Address>(&hook_on_function_call_); | 548 return reinterpret_cast<Address>(&hook_on_function_call_); |
553 } | 549 } |
554 | 550 |
555 Address after_break_target_address() { | |
556 return reinterpret_cast<Address>(&after_break_target_); | |
557 } | |
558 | |
559 Address last_step_action_address() { | 551 Address last_step_action_address() { |
560 return reinterpret_cast<Address>(&thread_local_.last_step_action_); | 552 return reinterpret_cast<Address>(&thread_local_.last_step_action_); |
561 } | 553 } |
562 | 554 |
563 Address suspended_generator_address() { | 555 Address suspended_generator_address() { |
564 return reinterpret_cast<Address>(&thread_local_.suspended_generator_); | 556 return reinterpret_cast<Address>(&thread_local_.suspended_generator_); |
565 } | 557 } |
566 | 558 |
559 Address new_fp_address() { | |
560 return reinterpret_cast<Address>(&thread_local_.new_fp_); | |
561 } | |
562 | |
563 void DropToFP(Address fp) { | |
564 // Drop to a lower a frame. | |
jgruber
2017/01/17 13:29:58
Nit: 'a lower a'.
A diagram or brief description
Yang
2017/01/18 07:49:08
Done. Added comment.
| |
565 if (fp > thread_local_.new_fp_) thread_local_.new_fp_ = fp; | |
566 } | |
567 | |
567 StepAction last_step_action() { return thread_local_.last_step_action_; } | 568 StepAction last_step_action() { return thread_local_.last_step_action_; } |
568 | 569 |
569 DebugFeatureTracker* feature_tracker() { return &feature_tracker_; } | 570 DebugFeatureTracker* feature_tracker() { return &feature_tracker_; } |
570 | 571 |
571 private: | 572 private: |
572 explicit Debug(Isolate* isolate); | 573 explicit Debug(Isolate* isolate); |
573 | 574 |
574 void UpdateState(); | 575 void UpdateState(); |
575 void UpdateHookOnFunctionCall(); | 576 void UpdateHookOnFunctionCall(); |
576 void Unload(); | 577 void Unload(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
690 // Trigger debug break events for all exceptions. | 691 // Trigger debug break events for all exceptions. |
691 bool break_on_exception_; | 692 bool break_on_exception_; |
692 // Trigger debug break events for uncaught exceptions. | 693 // Trigger debug break events for uncaught exceptions. |
693 bool break_on_uncaught_exception_; | 694 bool break_on_uncaught_exception_; |
694 // Termination exception because side effect check has failed. | 695 // Termination exception because side effect check has failed. |
695 bool side_effect_check_failed_; | 696 bool side_effect_check_failed_; |
696 | 697 |
697 // List of active debug info objects. | 698 // List of active debug info objects. |
698 DebugInfoListNode* debug_info_list_; | 699 DebugInfoListNode* debug_info_list_; |
699 | 700 |
700 // Storage location for jump when exiting debug break calls. | |
701 // Note that this address is not GC safe. It should be computed immediately | |
702 // before returning to the DebugBreakCallHelper. | |
703 Address after_break_target_; | |
704 | |
705 // Used to collect histogram data on debugger feature usage. | 701 // Used to collect histogram data on debugger feature usage. |
706 DebugFeatureTracker feature_tracker_; | 702 DebugFeatureTracker feature_tracker_; |
707 | 703 |
708 // Per-thread data. | 704 // Per-thread data. |
709 class ThreadLocal { | 705 class ThreadLocal { |
710 public: | 706 public: |
711 // Top debugger entry. | 707 // Top debugger entry. |
712 base::AtomicWord current_debug_scope_; | 708 base::AtomicWord current_debug_scope_; |
713 | 709 |
714 // Counter for generating next break id. | 710 // Counter for generating next break id. |
(...skipping 15 matching lines...) Expand all Loading... | |
730 Address last_fp_; | 726 Address last_fp_; |
731 | 727 |
732 // Frame pointer of the target frame we want to arrive at. | 728 // Frame pointer of the target frame we want to arrive at. |
733 Address target_fp_; | 729 Address target_fp_; |
734 | 730 |
735 // Stores the way how LiveEdit has patched the stack. It is used when | 731 // Stores the way how LiveEdit has patched the stack. It is used when |
736 // debugger returns control back to user script. | 732 // debugger returns control back to user script. |
737 LiveEditFrameDropMode frame_drop_mode_; | 733 LiveEditFrameDropMode frame_drop_mode_; |
738 | 734 |
739 // Value of accumulator in interpreter frames. In non-interpreter frames | 735 // Value of accumulator in interpreter frames. In non-interpreter frames |
740 // this value will be the hole. | 736 // this value will be the hole. |
jgruber
2017/01/17 13:29:58
Is the comment about the hole still valid?
Yang
2017/01/18 07:49:07
Done.
| |
741 Handle<Object> return_value_; | 737 Object* return_value_; |
742 | 738 |
739 // The suspended generator object to track when stepping. | |
743 Object* suspended_generator_; | 740 Object* suspended_generator_; |
744 | 741 |
742 // The new frame pointer to drop to when restarting a frame. | |
743 Address new_fp_; | |
jgruber
2017/01/17 13:29:58
Nit: 'new_fp_' isn't very descriptive, maybe somet
Yang
2017/01/18 07:49:08
renamed to restart_fp_
| |
744 | |
745 int async_task_count_; | 745 int async_task_count_; |
746 }; | 746 }; |
747 | 747 |
748 // Storage location for registers when handling debug break calls | 748 // Storage location for registers when handling debug break calls |
749 ThreadLocal thread_local_; | 749 ThreadLocal thread_local_; |
750 | 750 |
751 Isolate* isolate_; | 751 Isolate* isolate_; |
752 | 752 |
753 friend class Isolate; | 753 friend class Isolate; |
754 friend class DebugScope; | 754 friend class DebugScope; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
851 class DebugCodegen : public AllStatic { | 851 class DebugCodegen : public AllStatic { |
852 public: | 852 public: |
853 enum DebugBreakCallHelperMode { | 853 enum DebugBreakCallHelperMode { |
854 SAVE_RESULT_REGISTER, | 854 SAVE_RESULT_REGISTER, |
855 IGNORE_RESULT_REGISTER | 855 IGNORE_RESULT_REGISTER |
856 }; | 856 }; |
857 | 857 |
858 static void GenerateDebugBreakStub(MacroAssembler* masm, | 858 static void GenerateDebugBreakStub(MacroAssembler* masm, |
859 DebugBreakCallHelperMode mode); | 859 DebugBreakCallHelperMode mode); |
860 | 860 |
861 // FrameDropper is a code replacement for a JavaScript frame with possibly | 861 static void GenerateSlot(MacroAssembler* masm, RelocInfo::Mode mode); |
862 // several frames above. | |
863 // There is no calling conventions here, because it never actually gets | |
864 // called, it only gets returned to. | |
865 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); | |
866 | 862 |
867 | 863 static void GenerateFrameDropperTrampoline(MacroAssembler* masm); |
868 static void GenerateSlot(MacroAssembler* masm, RelocInfo::Mode mode); | |
869 | 864 |
870 static void PatchDebugBreakSlot(Isolate* isolate, Address pc, | 865 static void PatchDebugBreakSlot(Isolate* isolate, Address pc, |
871 Handle<Code> code); | 866 Handle<Code> code); |
872 static bool DebugBreakSlotIsPatched(Address pc); | 867 static bool DebugBreakSlotIsPatched(Address pc); |
873 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); | 868 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); |
874 }; | 869 }; |
875 | 870 |
876 | 871 |
877 } // namespace internal | 872 } // namespace internal |
878 } // namespace v8 | 873 } // namespace v8 |
879 | 874 |
880 #endif // V8_DEBUG_DEBUG_H_ | 875 #endif // V8_DEBUG_DEBUG_H_ |
OLD | NEW |