OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 v8::Debug::ClientData* client_data_; // Client data passed with the request. | 559 v8::Debug::ClientData* client_data_; // Client data passed with the request. |
560 }; | 560 }; |
561 | 561 |
562 | 562 |
563 // Details of the debug event delivered to the debug event listener. | 563 // Details of the debug event delivered to the debug event listener. |
564 class EventDetailsImpl : public v8::Debug::EventDetails { | 564 class EventDetailsImpl : public v8::Debug::EventDetails { |
565 public: | 565 public: |
566 EventDetailsImpl(DebugEvent event, | 566 EventDetailsImpl(DebugEvent event, |
567 Handle<JSObject> exec_state, | 567 Handle<JSObject> exec_state, |
568 Handle<JSObject> event_data, | 568 Handle<JSObject> event_data, |
569 Handle<Object> callback_data); | 569 Handle<Object> callback_data, |
| 570 v8::Debug::ClientData* client_data); |
570 virtual DebugEvent GetEvent() const; | 571 virtual DebugEvent GetEvent() const; |
571 virtual v8::Handle<v8::Object> GetExecutionState() const; | 572 virtual v8::Handle<v8::Object> GetExecutionState() const; |
572 virtual v8::Handle<v8::Object> GetEventData() const; | 573 virtual v8::Handle<v8::Object> GetEventData() const; |
573 virtual v8::Handle<v8::Context> GetEventContext() const; | 574 virtual v8::Handle<v8::Context> GetEventContext() const; |
574 virtual v8::Handle<v8::Value> GetCallbackData() const; | 575 virtual v8::Handle<v8::Value> GetCallbackData() const; |
| 576 virtual v8::Debug::ClientData* GetClientData() const; |
575 private: | 577 private: |
576 DebugEvent event_; // Debug event causing the break. | 578 DebugEvent event_; // Debug event causing the break. |
577 Handle<JSObject> exec_state_; // Current execution state. | 579 Handle<JSObject> exec_state_; // Current execution state. |
578 Handle<JSObject> event_data_; // Data associated with the event. | 580 Handle<JSObject> event_data_; // Data associated with the event. |
579 Handle<Object> callback_data_; // User data passed with the callback when | 581 Handle<Object> callback_data_; // User data passed with the callback |
580 // it was registered. | 582 // when it was registered. |
| 583 v8::Debug::ClientData* client_data_; // Data passed to DebugBreakForCommand. |
581 }; | 584 }; |
582 | 585 |
583 | 586 |
584 // Message send by user to v8 debugger or debugger output message. | 587 // Message send by user to v8 debugger or debugger output message. |
585 // In addition to command text it may contain a pointer to some user data | 588 // In addition to command text it may contain a pointer to some user data |
586 // which are expected to be passed along with the command reponse to message | 589 // which are expected to be passed along with the command reponse to message |
587 // handler. | 590 // handler. |
588 class CommandMessage { | 591 class CommandMessage { |
589 public: | 592 public: |
590 static CommandMessage New(const Vector<uint16_t>& command, | 593 static CommandMessage New(const Vector<uint16_t>& command, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 // Invoke the message handler function. | 702 // Invoke the message handler function. |
700 static void InvokeMessageHandler(MessageImpl message); | 703 static void InvokeMessageHandler(MessageImpl message); |
701 | 704 |
702 // Add a debugger command to the command queue. | 705 // Add a debugger command to the command queue. |
703 static void ProcessCommand(Vector<const uint16_t> command, | 706 static void ProcessCommand(Vector<const uint16_t> command, |
704 v8::Debug::ClientData* client_data = NULL); | 707 v8::Debug::ClientData* client_data = NULL); |
705 | 708 |
706 // Check whether there are commands in the command queue. | 709 // Check whether there are commands in the command queue. |
707 static bool HasCommands(); | 710 static bool HasCommands(); |
708 | 711 |
| 712 // Enqueue a debugger command to the command queue for event listeners. |
| 713 static void EnqueueDebugCommand(v8::Debug::ClientData* client_data = NULL); |
| 714 |
709 static Handle<Object> Call(Handle<JSFunction> fun, | 715 static Handle<Object> Call(Handle<JSFunction> fun, |
710 Handle<Object> data, | 716 Handle<Object> data, |
711 bool* pending_exception); | 717 bool* pending_exception); |
712 | 718 |
713 // Start the debugger agent listening on the provided port. | 719 // Start the debugger agent listening on the provided port. |
714 static bool StartAgent(const char* name, int port, | 720 static bool StartAgent(const char* name, int port, |
715 bool wait_for_connection = false); | 721 bool wait_for_connection = false); |
716 | 722 |
717 // Stop the debugger agent. | 723 // Stop the debugger agent. |
718 static void StopAgent(); | 724 static void StopAgent(); |
(...skipping 27 matching lines...) Expand all Loading... |
746 static void set_compiling_natives(bool compiling_natives) { | 752 static void set_compiling_natives(bool compiling_natives) { |
747 Debugger::compiling_natives_ = compiling_natives; | 753 Debugger::compiling_natives_ = compiling_natives; |
748 } | 754 } |
749 static bool compiling_natives() { return Debugger::compiling_natives_; } | 755 static bool compiling_natives() { return Debugger::compiling_natives_; } |
750 static void set_loading_debugger(bool v) { is_loading_debugger_ = v; } | 756 static void set_loading_debugger(bool v) { is_loading_debugger_ = v; } |
751 static bool is_loading_debugger() { return Debugger::is_loading_debugger_; } | 757 static bool is_loading_debugger() { return Debugger::is_loading_debugger_; } |
752 | 758 |
753 static bool IsDebuggerActive(); | 759 static bool IsDebuggerActive(); |
754 | 760 |
755 private: | 761 private: |
| 762 static void CallEventCallback(v8::DebugEvent event, |
| 763 Handle<Object> exec_state, |
| 764 Handle<Object> event_data, |
| 765 v8::Debug::ClientData* client_data); |
| 766 static void CallCEventCallback(v8::DebugEvent event, |
| 767 Handle<Object> exec_state, |
| 768 Handle<Object> event_data, |
| 769 v8::Debug::ClientData* client_data); |
| 770 static void CallJSEventCallback(v8::DebugEvent event, |
| 771 Handle<Object> exec_state, |
| 772 Handle<Object> event_data); |
756 static void ListenersChanged(); | 773 static void ListenersChanged(); |
757 | 774 |
758 static Mutex* debugger_access_; // Mutex guarding debugger variables. | 775 static Mutex* debugger_access_; // Mutex guarding debugger variables. |
759 static Handle<Object> event_listener_; // Global handle to listener. | 776 static Handle<Object> event_listener_; // Global handle to listener. |
760 static Handle<Object> event_listener_data_; | 777 static Handle<Object> event_listener_data_; |
761 static bool compiling_natives_; // Are we compiling natives? | 778 static bool compiling_natives_; // Are we compiling natives? |
762 static bool is_loading_debugger_; // Are we loading the debugger? | 779 static bool is_loading_debugger_; // Are we loading the debugger? |
763 static bool never_unload_debugger_; // Can we unload the debugger? | 780 static bool never_unload_debugger_; // Can we unload the debugger? |
764 static v8::Debug::MessageHandler2 message_handler_; | 781 static v8::Debug::MessageHandler2 message_handler_; |
765 static bool debugger_unload_pending_; // Was message handler cleared? | 782 static bool debugger_unload_pending_; // Was message handler cleared? |
766 static v8::Debug::HostDispatchHandler host_dispatch_handler_; | 783 static v8::Debug::HostDispatchHandler host_dispatch_handler_; |
767 static Mutex* dispatch_handler_access_; // Mutex guarding dispatch handler. | 784 static Mutex* dispatch_handler_access_; // Mutex guarding dispatch handler. |
768 static v8::Debug::DebugMessageDispatchHandler debug_message_dispatch_handler_; | 785 static v8::Debug::DebugMessageDispatchHandler debug_message_dispatch_handler_; |
769 static MessageDispatchHelperThread* message_dispatch_helper_thread_; | 786 static MessageDispatchHelperThread* message_dispatch_helper_thread_; |
770 static int host_dispatch_micros_; | 787 static int host_dispatch_micros_; |
771 | 788 |
772 static DebuggerAgent* agent_; | 789 static DebuggerAgent* agent_; |
773 | 790 |
774 static const int kQueueInitialSize = 4; | 791 static const int kQueueInitialSize = 4; |
775 static LockingCommandMessageQueue command_queue_; | 792 static LockingCommandMessageQueue command_queue_; |
776 static Semaphore* command_received_; // Signaled for each command received. | 793 static Semaphore* command_received_; // Signaled for each command received. |
777 | 794 |
| 795 static LockingCommandMessageQueue event_command_queue_; |
| 796 |
778 friend class EnterDebugger; | 797 friend class EnterDebugger; |
779 }; | 798 }; |
780 | 799 |
781 | 800 |
782 // This class is used for entering the debugger. Create an instance in the stack | 801 // This class is used for entering the debugger. Create an instance in the stack |
783 // to enter the debugger. This will set the current break state, make sure the | 802 // to enter the debugger. This will set the current break state, make sure the |
784 // debugger is loaded and switch to the debugger context. If the debugger for | 803 // debugger is loaded and switch to the debugger context. If the debugger for |
785 // some reason could not be entered FailedToEnter will return true. | 804 // some reason could not be entered FailedToEnter will return true. |
786 class EnterDebugger BASE_EMBEDDED { | 805 class EnterDebugger BASE_EMBEDDED { |
787 public: | 806 public: |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 | 984 |
966 DISALLOW_COPY_AND_ASSIGN(MessageDispatchHelperThread); | 985 DISALLOW_COPY_AND_ASSIGN(MessageDispatchHelperThread); |
967 }; | 986 }; |
968 | 987 |
969 | 988 |
970 } } // namespace v8::internal | 989 } } // namespace v8::internal |
971 | 990 |
972 #endif // ENABLE_DEBUGGER_SUPPORT | 991 #endif // ENABLE_DEBUGGER_SUPPORT |
973 | 992 |
974 #endif // V8_DEBUG_H_ | 993 #endif // V8_DEBUG_H_ |
OLD | NEW |