Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: src/debug.h

Issue 292713002: Revert "Simplify debugger state." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/d8.cc ('k') | src/debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_H_ 5 #ifndef V8_DEBUG_H_
6 #define V8_DEBUG_H_ 6 #define V8_DEBUG_H_
7 7
8 #include "allocation.h" 8 #include "allocation.h"
9 #include "arguments.h" 9 #include "arguments.h"
10 #include "assembler.h" 10 #include "assembler.h"
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 // A number of words that should be reserved on stack for the LiveEdit use. 483 // A number of words that should be reserved on stack for the LiveEdit use.
484 // Normally equals 1. Stored on stack in form of Smi. 484 // Normally equals 1. Stored on stack in form of Smi.
485 static const int kInitialSize; 485 static const int kInitialSize;
486 // A value that padding words are filled with (in form of Smi). Going 486 // A value that padding words are filled with (in form of Smi). Going
487 // bottom-top, the first word not having this value is a counter word. 487 // bottom-top, the first word not having this value is a counter word.
488 static const int kPaddingValue; 488 static const int kPaddingValue;
489 }; 489 };
490 490
491 private: 491 private:
492 explicit Debug(Isolate* isolate); 492 explicit Debug(Isolate* isolate);
493 ~Debug();
493 494
494 static bool CompileDebuggerScript(Isolate* isolate, int index); 495 static bool CompileDebuggerScript(Isolate* isolate, int index);
495 void ClearOneShot(); 496 void ClearOneShot();
496 void ActivateStepIn(StackFrame* frame); 497 void ActivateStepIn(StackFrame* frame);
497 void ClearStepIn(); 498 void ClearStepIn();
498 void ActivateStepOut(StackFrame* frame); 499 void ActivateStepOut(StackFrame* frame);
499 void ClearStepNext(); 500 void ClearStepNext();
500 // Returns whether the compile succeeded. 501 // Returns whether the compile succeeded.
501 void RemoveDebugInfo(Handle<DebugInfo> debug_info); 502 void RemoveDebugInfo(Handle<DebugInfo> debug_info);
502 void SetAfterBreakTarget(JavaScriptFrame* frame); 503 void SetAfterBreakTarget(JavaScriptFrame* frame);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 private: 736 private:
736 Logger* logger_; 737 Logger* logger_;
737 CommandMessageQueue queue_; 738 CommandMessageQueue queue_;
738 mutable Mutex mutex_; 739 mutable Mutex mutex_;
739 DISALLOW_COPY_AND_ASSIGN(LockingCommandMessageQueue); 740 DISALLOW_COPY_AND_ASSIGN(LockingCommandMessageQueue);
740 }; 741 };
741 742
742 743
743 class Debugger { 744 class Debugger {
744 public: 745 public:
746 ~Debugger();
747
748 void DebugRequest(const uint16_t* json_request, int length);
749
750 MUST_USE_RESULT MaybeHandle<Object> MakeJSObject(
751 Vector<const char> constructor_name,
752 int argc,
753 Handle<Object> argv[]);
754 MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState();
755 MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent(
756 Handle<Object> break_points_hit);
757 MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent(
758 Handle<Object> exception,
759 bool uncaught,
760 Handle<Object> promise);
761 MUST_USE_RESULT MaybeHandle<Object> MakeCompileEvent(
762 Handle<Script> script, bool before);
763 MUST_USE_RESULT MaybeHandle<Object> MakeScriptCollectedEvent(int id);
764
745 void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue); 765 void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue);
746 void OnException(Handle<Object> exception, bool uncaught); 766 void OnException(Handle<Object> exception, bool uncaught);
747 void OnBeforeCompile(Handle<Script> script); 767 void OnBeforeCompile(Handle<Script> script);
748 768
749 enum AfterCompileFlags { 769 enum AfterCompileFlags {
750 NO_AFTER_COMPILE_FLAGS, 770 NO_AFTER_COMPILE_FLAGS,
751 SEND_WHEN_DEBUGGING 771 SEND_WHEN_DEBUGGING
752 }; 772 };
753 void OnAfterCompile(Handle<Script> script, 773 void OnAfterCompile(Handle<Script> script,
754 AfterCompileFlags after_compile_flags); 774 AfterCompileFlags after_compile_flags);
755 void OnScriptCollected(int id); 775 void OnScriptCollected(int id);
756 776 void ProcessDebugEvent(v8::DebugEvent event,
777 Handle<JSObject> event_data,
778 bool auto_continue);
779 void NotifyMessageHandler(v8::DebugEvent event,
780 Handle<JSObject> exec_state,
781 Handle<JSObject> event_data,
782 bool auto_continue);
757 void SetEventListener(Handle<Object> callback, Handle<Object> data); 783 void SetEventListener(Handle<Object> callback, Handle<Object> data);
758 void SetMessageHandler(v8::Debug::MessageHandler handler); 784 void SetMessageHandler(v8::Debug::MessageHandler handler);
759 785
760 // Add a debugger command to the command queue. 786 // Add a debugger command to the command queue.
761 void EnqueueCommandMessage(Vector<const uint16_t> command, 787 void EnqueueCommandMessage(Vector<const uint16_t> command,
762 v8::Debug::ClientData* client_data = NULL); 788 v8::Debug::ClientData* client_data = NULL);
763 789
764 // Check whether there are commands in the command queue. 790 // Check whether there are commands in the command queue.
765 bool HasCommands(); 791 bool HasCommands();
766 792
767 // Enqueue a debugger command to the command queue for event listeners. 793 // Enqueue a debugger command to the command queue for event listeners.
768 void EnqueueDebugCommand(v8::Debug::ClientData* client_data = NULL); 794 void EnqueueDebugCommand(v8::Debug::ClientData* client_data = NULL);
769 795
770 MUST_USE_RESULT MaybeHandle<Object> Call(Handle<JSFunction> fun, 796 MUST_USE_RESULT MaybeHandle<Object> Call(Handle<JSFunction> fun,
771 Handle<Object> data); 797 Handle<Object> data);
772 798
773 Handle<Context> GetDebugContext(); 799 Handle<Context> GetDebugContext();
774 800
801 // Unload the debugger if possible. Only called when no debugger is currently
802 // active.
803 void UnloadDebugger();
804 friend void ForceUnloadDebugger(); // In test-debug.cc
805
806 inline bool EventActive() {
807 LockGuard<RecursiveMutex> lock_guard(&debugger_access_);
808
809 // Check whether the message handler was been cleared.
810 // TODO(yangguo): handle loading and unloading of the debugger differently.
811 if (debugger_unload_pending_) {
812 if (isolate_->debug()->debugger_entry() == NULL) {
813 UnloadDebugger();
814 }
815 }
816
817 // Currently argument event is not used.
818 return !ignore_debugger_ && is_active_;
819 }
820
775 bool ignore_debugger() const { return ignore_debugger_; } 821 bool ignore_debugger() const { return ignore_debugger_; }
776 void set_live_edit_enabled(bool v) { live_edit_enabled_ = v; } 822 void set_live_edit_enabled(bool v) { live_edit_enabled_ = v; }
777 bool live_edit_enabled() const { 823 bool live_edit_enabled() const {
778 return FLAG_enable_liveedit && live_edit_enabled_ ; 824 return FLAG_enable_liveedit && live_edit_enabled_ ;
779 } 825 }
780 826
781 bool is_active() { return is_active_; } 827 bool is_active() {
828 LockGuard<RecursiveMutex> lock_guard(&debugger_access_);
829 return is_active_;
830 }
782 831
783 class IgnoreScope { 832 class IgnoreScope {
784 public: 833 public:
785 explicit IgnoreScope(Debugger* debugger) 834 explicit IgnoreScope(Debugger* debugger)
786 : debugger_(debugger), 835 : debugger_(debugger),
787 old_state_(debugger_->ignore_debugger_) { 836 old_state_(debugger_->ignore_debugger_) {
788 debugger_->ignore_debugger_ = true; 837 debugger_->ignore_debugger_ = true;
789 } 838 }
790 839
791 ~IgnoreScope() { 840 ~IgnoreScope() {
792 debugger_->ignore_debugger_ = old_state_; 841 debugger_->ignore_debugger_ = old_state_;
793 } 842 }
794 843
795 private: 844 private:
796 Debugger* debugger_; 845 Debugger* debugger_;
797 bool old_state_; 846 bool old_state_;
798 DISALLOW_COPY_AND_ASSIGN(IgnoreScope); 847 DISALLOW_COPY_AND_ASSIGN(IgnoreScope);
799 }; 848 };
800 849
801 private: 850 private:
802 explicit Debugger(Isolate* isolate); 851 explicit Debugger(Isolate* isolate);
803 ~Debugger();
804
805 MUST_USE_RESULT MaybeHandle<Object> MakeJSObject(
806 Vector<const char> constructor_name,
807 int argc,
808 Handle<Object> argv[]);
809 MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState();
810 MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent(
811 Handle<Object> break_points_hit);
812 MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent(
813 Handle<Object> exception,
814 bool uncaught,
815 Handle<Object> promise);
816 MUST_USE_RESULT MaybeHandle<Object> MakeCompileEvent(
817 Handle<Script> script, bool before);
818 MUST_USE_RESULT MaybeHandle<Object> MakeScriptCollectedEvent(int id);
819 852
820 void CallEventCallback(v8::DebugEvent event, 853 void CallEventCallback(v8::DebugEvent event,
821 Handle<Object> exec_state, 854 Handle<Object> exec_state,
822 Handle<Object> event_data, 855 Handle<Object> event_data,
823 v8::Debug::ClientData* client_data); 856 v8::Debug::ClientData* client_data);
824 void CallCEventCallback(v8::DebugEvent event, 857 void CallCEventCallback(v8::DebugEvent event,
825 Handle<Object> exec_state, 858 Handle<Object> exec_state,
826 Handle<Object> event_data, 859 Handle<Object> event_data,
827 v8::Debug::ClientData* client_data); 860 v8::Debug::ClientData* client_data);
828 void CallJSEventCallback(v8::DebugEvent event, 861 void CallJSEventCallback(v8::DebugEvent event,
829 Handle<Object> exec_state, 862 Handle<Object> exec_state,
830 Handle<Object> event_data); 863 Handle<Object> event_data);
831 void UpdateState(); 864 void ListenersChanged();
832
833 void ProcessDebugEvent(v8::DebugEvent event,
834 Handle<JSObject> event_data,
835 bool auto_continue);
836 void NotifyMessageHandler(v8::DebugEvent event,
837 Handle<JSObject> exec_state,
838 Handle<JSObject> event_data,
839 bool auto_continue);
840 865
841 // Invoke the message handler function. 866 // Invoke the message handler function.
842 void InvokeMessageHandler(MessageImpl message); 867 void InvokeMessageHandler(MessageImpl message);
843 868
844 inline bool EventActive() { 869 RecursiveMutex debugger_access_; // Mutex guarding debugger variables.
845 // Check whether the message handler was been cleared.
846 // TODO(yangguo): handle loading and unloading of the debugger differently.
847 // Currently argument event is not used.
848 return !ignore_debugger_ && is_active_;
849 }
850
851 Handle<Object> event_listener_; // Global handle to listener. 870 Handle<Object> event_listener_; // Global handle to listener.
852 Handle<Object> event_listener_data_; 871 Handle<Object> event_listener_data_;
853 bool is_active_; 872 bool is_active_;
854 bool ignore_debugger_; // Are we temporarily ignoring the debugger? 873 bool ignore_debugger_; // Are we temporarily ignoring the debugger?
855 bool live_edit_enabled_; // Enable LiveEdit. 874 bool live_edit_enabled_; // Enable LiveEdit.
875 bool never_unload_debugger_; // Can we unload the debugger?
856 v8::Debug::MessageHandler message_handler_; 876 v8::Debug::MessageHandler message_handler_;
857 bool debugger_unload_pending_; // Was message handler cleared? 877 bool debugger_unload_pending_; // Was message handler cleared?
858 878
859 static const int kQueueInitialSize = 4; 879 static const int kQueueInitialSize = 4;
860 LockingCommandMessageQueue command_queue_; 880 LockingCommandMessageQueue command_queue_;
861 Semaphore command_received_; // Signaled for each command received. 881 Semaphore command_received_; // Signaled for each command received.
862 LockingCommandMessageQueue event_command_queue_; 882 LockingCommandMessageQueue event_command_queue_;
863 883
864 Isolate* isolate_; 884 Isolate* isolate_;
865 885
(...skipping 18 matching lines...) Expand all
884 904
885 // Check whether there are any JavaScript frames on the stack. 905 // Check whether there are any JavaScript frames on the stack.
886 inline bool HasJavaScriptFrames() { return has_js_frames_; } 906 inline bool HasJavaScriptFrames() { return has_js_frames_; }
887 907
888 // Get the active context from before entering the debugger. 908 // Get the active context from before entering the debugger.
889 inline Handle<Context> GetContext() { return save_.context(); } 909 inline Handle<Context> GetContext() { return save_.context(); }
890 910
891 private: 911 private:
892 Isolate* isolate_; 912 Isolate* isolate_;
893 EnterDebugger* prev_; // Previous debugger entry if entered recursively. 913 EnterDebugger* prev_; // Previous debugger entry if entered recursively.
894 bool has_js_frames_; // Were there any JavaScript frames? 914 JavaScriptFrameIterator it_;
915 const bool has_js_frames_; // Were there any JavaScript frames?
895 StackFrame::Id break_frame_id_; // Previous break frame id. 916 StackFrame::Id break_frame_id_; // Previous break frame id.
896 int break_id_; // Previous break id. 917 int break_id_; // Previous break id.
897 bool load_failed_; // Did the debugger fail to load? 918 bool load_failed_; // Did the debugger fail to load?
898 SaveContext save_; // Saves previous context. 919 SaveContext save_; // Saves previous context.
899 }; 920 };
900 921
901 922
902 // Stack allocated class for disabling break. 923 // Stack allocated class for disabling break.
903 class DisableBreak BASE_EMBEDDED { 924 class DisableBreak BASE_EMBEDDED {
904 public: 925 public:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 } 968 }
948 } 969 }
949 970
950 private: 971 private:
951 Debug::AddressId id_; 972 Debug::AddressId id_;
952 }; 973 };
953 974
954 } } // namespace v8::internal 975 } } // namespace v8::internal
955 976
956 #endif // V8_DEBUG_H_ 977 #endif // V8_DEBUG_H_
OLDNEW
« no previous file with comments | « src/d8.cc ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698