| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 DEBUGGER_STATEMENT, | 68 DEBUGGER_STATEMENT, |
| 69 DEBUG_BREAK_SLOT, | 69 DEBUG_BREAK_SLOT, |
| 70 DEBUG_BREAK_SLOT_AT_CALL, | 70 DEBUG_BREAK_SLOT_AT_CALL, |
| 71 DEBUG_BREAK_SLOT_AT_RETURN, | 71 DEBUG_BREAK_SLOT_AT_RETURN, |
| 72 DEBUG_BREAK_SLOT_AT_TAIL_CALL, | 72 DEBUG_BREAK_SLOT_AT_TAIL_CALL, |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 const int kDebugPromiseNoID = 0; | 75 const int kDebugPromiseNoID = 0; |
| 76 const int kDebugPromiseFirstID = 1; | 76 const int kDebugPromiseFirstID = 1; |
| 77 | 77 |
| 78 enum PromiseDebugActionName { | |
| 79 kDebugNotActive, | |
| 80 kDebugAsyncFunction, | |
| 81 kDebugPromiseResolve, | |
| 82 kDebugPromiseReject, | |
| 83 kDebugPromiseResolveThenableJob, | |
| 84 kDebugPromiseCollected, | |
| 85 }; | |
| 86 | |
| 87 class BreakLocation { | 78 class BreakLocation { |
| 88 public: | 79 public: |
| 89 static BreakLocation FromFrame(StandardFrame* frame); | 80 static BreakLocation FromFrame(StandardFrame* frame); |
| 90 | 81 |
| 91 static void AllAtCurrentStatement(Handle<DebugInfo> debug_info, | 82 static void AllAtCurrentStatement(Handle<DebugInfo> debug_info, |
| 92 JavaScriptFrame* frame, | 83 JavaScriptFrame* frame, |
| 93 List<BreakLocation>* result_out); | 84 List<BreakLocation>* result_out); |
| 94 | 85 |
| 95 inline bool IsReturn() const { return type_ == DEBUG_BREAK_SLOT_AT_RETURN; } | 86 inline bool IsReturn() const { return type_ == DEBUG_BREAK_SLOT_AT_RETURN; } |
| 96 inline bool IsCall() const { return type_ == DEBUG_BREAK_SLOT_AT_CALL; } | 87 inline bool IsCall() const { return type_ == DEBUG_BREAK_SLOT_AT_CALL; } |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 // DebugInfo. | 403 // DebugInfo. |
| 413 class Debug { | 404 class Debug { |
| 414 public: | 405 public: |
| 415 // Debug event triggers. | 406 // Debug event triggers. |
| 416 void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue); | 407 void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue); |
| 417 | 408 |
| 418 void OnThrow(Handle<Object> exception); | 409 void OnThrow(Handle<Object> exception); |
| 419 void OnPromiseReject(Handle<Object> promise, Handle<Object> value); | 410 void OnPromiseReject(Handle<Object> promise, Handle<Object> value); |
| 420 void OnCompileError(Handle<Script> script); | 411 void OnCompileError(Handle<Script> script); |
| 421 void OnAfterCompile(Handle<Script> script); | 412 void OnAfterCompile(Handle<Script> script); |
| 422 void OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id, | 413 void OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id); |
| 423 PromiseDebugActionName name); | |
| 424 | 414 |
| 425 // API facing. | 415 // API facing. |
| 426 void SetEventListener(Handle<Object> callback, Handle<Object> data); | 416 void SetEventListener(Handle<Object> callback, Handle<Object> data); |
| 427 void SetMessageHandler(v8::Debug::MessageHandler handler); | 417 void SetMessageHandler(v8::Debug::MessageHandler handler); |
| 428 void EnqueueCommandMessage(Vector<const uint16_t> command, | 418 void EnqueueCommandMessage(Vector<const uint16_t> command, |
| 429 v8::Debug::ClientData* client_data = NULL); | 419 v8::Debug::ClientData* client_data = NULL); |
| 430 MUST_USE_RESULT MaybeHandle<Object> Call(Handle<Object> fun, | 420 MUST_USE_RESULT MaybeHandle<Object> Call(Handle<Object> fun, |
| 431 Handle<Object> data); | 421 Handle<Object> data); |
| 432 Handle<Context> GetDebugContext(); | 422 Handle<Context> GetDebugContext(); |
| 433 void HandleDebugBreak(); | 423 void HandleDebugBreak(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 void ClearStepOut(); | 459 void ClearStepOut(); |
| 470 | 460 |
| 471 bool PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared); | 461 bool PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared); |
| 472 bool GetPossibleBreakpoints(Handle<Script> script, int start_position, | 462 bool GetPossibleBreakpoints(Handle<Script> script, int start_position, |
| 473 int end_position, std::set<int>* positions); | 463 int end_position, std::set<int>* positions); |
| 474 | 464 |
| 475 void RecordGenerator(Handle<JSGeneratorObject> generator_object); | 465 void RecordGenerator(Handle<JSGeneratorObject> generator_object); |
| 476 | 466 |
| 477 int NextAsyncTaskId(Handle<JSObject> promise); | 467 int NextAsyncTaskId(Handle<JSObject> promise); |
| 478 | 468 |
| 469 void SetAsyncTaskListener(debug::AsyncTaskListener listener, void* data); |
| 470 |
| 479 // Returns whether the operation succeeded. Compilation can only be triggered | 471 // Returns whether the operation succeeded. Compilation can only be triggered |
| 480 // if a valid closure is passed as the second argument, otherwise the shared | 472 // if a valid closure is passed as the second argument, otherwise the shared |
| 481 // function needs to be compiled already. | 473 // function needs to be compiled already. |
| 482 bool EnsureDebugInfo(Handle<SharedFunctionInfo> shared, | 474 bool EnsureDebugInfo(Handle<SharedFunctionInfo> shared, |
| 483 Handle<JSFunction> function); | 475 Handle<JSFunction> function); |
| 484 void CreateDebugInfo(Handle<SharedFunctionInfo> shared); | 476 void CreateDebugInfo(Handle<SharedFunctionInfo> shared); |
| 485 static Handle<DebugInfo> GetDebugInfo(Handle<SharedFunctionInfo> shared); | 477 static Handle<DebugInfo> GetDebugInfo(Handle<SharedFunctionInfo> shared); |
| 486 | 478 |
| 487 template <typename C> | 479 template <typename C> |
| 488 bool CompileToRevealInnerFunctions(C* compilable); | 480 bool CompileToRevealInnerFunctions(C* compilable); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState(); | 599 MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState(); |
| 608 MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent( | 600 MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent( |
| 609 Handle<Object> break_points_hit); | 601 Handle<Object> break_points_hit); |
| 610 MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent( | 602 MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent( |
| 611 Handle<Object> exception, | 603 Handle<Object> exception, |
| 612 bool uncaught, | 604 bool uncaught, |
| 613 Handle<Object> promise); | 605 Handle<Object> promise); |
| 614 MUST_USE_RESULT MaybeHandle<Object> MakeCompileEvent( | 606 MUST_USE_RESULT MaybeHandle<Object> MakeCompileEvent( |
| 615 Handle<Script> script, v8::DebugEvent type); | 607 Handle<Script> script, v8::DebugEvent type); |
| 616 MUST_USE_RESULT MaybeHandle<Object> MakeAsyncTaskEvent(Handle<Smi> type, | 608 MUST_USE_RESULT MaybeHandle<Object> MakeAsyncTaskEvent(Handle<Smi> type, |
| 617 Handle<Smi> id, | 609 Handle<Smi> id); |
| 618 Handle<Smi> name); | |
| 619 | 610 |
| 620 // Mirror cache handling. | 611 // Mirror cache handling. |
| 621 void ClearMirrorCache(); | 612 void ClearMirrorCache(); |
| 622 | 613 |
| 623 void CallEventCallback(v8::DebugEvent event, | 614 void CallEventCallback(v8::DebugEvent event, |
| 624 Handle<Object> exec_state, | 615 Handle<Object> exec_state, |
| 625 Handle<Object> event_data, | 616 Handle<Object> event_data, |
| 626 v8::Debug::ClientData* client_data); | 617 v8::Debug::ClientData* client_data); |
| 627 void ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script); | 618 void ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script); |
| 628 void ProcessDebugEvent(v8::DebugEvent event, Handle<JSObject> event_data, | 619 void ProcessDebugEvent(v8::DebugEvent event, Handle<JSObject> event_data, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 | 656 |
| 666 void PrintBreakLocation(); | 657 void PrintBreakLocation(); |
| 667 | 658 |
| 668 // Global handles. | 659 // Global handles. |
| 669 Handle<Context> debug_context_; | 660 Handle<Context> debug_context_; |
| 670 Handle<Object> event_listener_; | 661 Handle<Object> event_listener_; |
| 671 Handle<Object> event_listener_data_; | 662 Handle<Object> event_listener_data_; |
| 672 | 663 |
| 673 v8::Debug::MessageHandler message_handler_; | 664 v8::Debug::MessageHandler message_handler_; |
| 674 | 665 |
| 666 debug::AsyncTaskListener async_task_listener_ = nullptr; |
| 667 void* async_task_listener_data_ = nullptr; |
| 668 |
| 675 static const int kQueueInitialSize = 4; | 669 static const int kQueueInitialSize = 4; |
| 676 base::Semaphore command_received_; // Signaled for each command received. | 670 base::Semaphore command_received_; // Signaled for each command received. |
| 677 LockingCommandMessageQueue command_queue_; | 671 LockingCommandMessageQueue command_queue_; |
| 678 | 672 |
| 679 // Debugger is active, i.e. there is a debug event listener attached. | 673 // Debugger is active, i.e. there is a debug event listener attached. |
| 680 bool is_active_; | 674 bool is_active_; |
| 681 // Debugger needs to be notified on every new function call. | 675 // Debugger needs to be notified on every new function call. |
| 682 // Used for stepping and read-only checks | 676 // Used for stepping and read-only checks |
| 683 bool hook_on_function_call_; | 677 bool hook_on_function_call_; |
| 684 // Suppress debug events. | 678 // Suppress debug events. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 Handle<Code> code); | 869 Handle<Code> code); |
| 876 static bool DebugBreakSlotIsPatched(Address pc); | 870 static bool DebugBreakSlotIsPatched(Address pc); |
| 877 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); | 871 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); |
| 878 }; | 872 }; |
| 879 | 873 |
| 880 | 874 |
| 881 } // namespace internal | 875 } // namespace internal |
| 882 } // namespace v8 | 876 } // namespace v8 |
| 883 | 877 |
| 884 #endif // V8_DEBUG_DEBUG_H_ | 878 #endif // V8_DEBUG_DEBUG_H_ |
| OLD | NEW |