| 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_H_ | 5 #ifndef V8_DEBUG_H_ |
| 6 #define V8_DEBUG_H_ | 6 #define V8_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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 private: | 328 private: |
| 329 Logger* logger_; | 329 Logger* logger_; |
| 330 CommandMessageQueue queue_; | 330 CommandMessageQueue queue_; |
| 331 mutable base::Mutex mutex_; | 331 mutable base::Mutex mutex_; |
| 332 DISALLOW_COPY_AND_ASSIGN(LockingCommandMessageQueue); | 332 DISALLOW_COPY_AND_ASSIGN(LockingCommandMessageQueue); |
| 333 }; | 333 }; |
| 334 | 334 |
| 335 | 335 |
| 336 class PromiseOnStack { | 336 class PromiseOnStack { |
| 337 public: | 337 public: |
| 338 PromiseOnStack(Isolate* isolate, | 338 PromiseOnStack(Isolate* isolate, PromiseOnStack* prev, |
| 339 PromiseOnStack* prev, | 339 Handle<JSObject> getter); |
| 340 Handle<JSFunction> getter); | |
| 341 ~PromiseOnStack(); | 340 ~PromiseOnStack(); |
| 342 StackHandler* handler() { return handler_; } | 341 StackHandler* handler() { return handler_; } |
| 343 Handle<JSFunction> getter() { return getter_; } | 342 Handle<JSObject> promise() { return promise_; } |
| 344 PromiseOnStack* prev() { return prev_; } | 343 PromiseOnStack* prev() { return prev_; } |
| 345 private: | 344 private: |
| 346 Isolate* isolate_; | 345 Isolate* isolate_; |
| 347 StackHandler* handler_; | 346 StackHandler* handler_; |
| 348 Handle<JSFunction> getter_; | 347 Handle<JSObject> promise_; |
| 349 PromiseOnStack* prev_; | 348 PromiseOnStack* prev_; |
| 350 }; | 349 }; |
| 351 | 350 |
| 352 | 351 |
| 353 // This class contains the debugger support. The main purpose is to handle | 352 // This class contains the debugger support. The main purpose is to handle |
| 354 // setting break points in the code. | 353 // setting break points in the code. |
| 355 // | 354 // |
| 356 // This class controls the debug info for all functions which currently have | 355 // This class controls the debug info for all functions which currently have |
| 357 // active breakpoints in them. This debug info is held in the heap root object | 356 // active breakpoints in them. This debug info is held in the heap root object |
| 358 // debug_info which is a FixedArray. Each entry in this list is of class | 357 // debug_info which is a FixedArray. Each entry in this list is of class |
| 359 // DebugInfo. | 358 // DebugInfo. |
| 360 class Debug { | 359 class Debug { |
| 361 public: | 360 public: |
| 362 // Debug event triggers. | 361 // Debug event triggers. |
| 363 void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue); | 362 void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue); |
| 364 void OnException(Handle<Object> exception, bool uncaught); | 363 |
| 364 void OnThrow(Handle<Object> exception, bool uncaught); |
| 365 void OnPromiseReject(Handle<JSObject> promise, Handle<Object> value); |
| 365 void OnCompileError(Handle<Script> script); | 366 void OnCompileError(Handle<Script> script); |
| 366 void OnBeforeCompile(Handle<Script> script); | 367 void OnBeforeCompile(Handle<Script> script); |
| 367 void OnAfterCompile(Handle<Script> script); | 368 void OnAfterCompile(Handle<Script> script); |
| 368 void OnPromiseEvent(Handle<JSObject> data); | 369 void OnPromiseEvent(Handle<JSObject> data); |
| 369 void OnAsyncTaskEvent(Handle<JSObject> data); | 370 void OnAsyncTaskEvent(Handle<JSObject> data); |
| 370 | 371 |
| 371 // API facing. | 372 // API facing. |
| 372 void SetEventListener(Handle<Object> callback, Handle<Object> data); | 373 void SetEventListener(Handle<Object> callback, Handle<Object> data); |
| 373 void SetMessageHandler(v8::Debug::MessageHandler handler); | 374 void SetMessageHandler(v8::Debug::MessageHandler handler); |
| 374 void EnqueueCommandMessage(Vector<const uint16_t> command, | 375 void EnqueueCommandMessage(Vector<const uint16_t> command, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 Handle<SharedFunctionInfo> shared, | 446 Handle<SharedFunctionInfo> shared, |
| 446 BreakPositionAlignment position_aligment); | 447 BreakPositionAlignment position_aligment); |
| 447 | 448 |
| 448 // Check whether a global object is the debug global object. | 449 // Check whether a global object is the debug global object. |
| 449 bool IsDebugGlobal(GlobalObject* global); | 450 bool IsDebugGlobal(GlobalObject* global); |
| 450 | 451 |
| 451 // Check whether this frame is just about to return. | 452 // Check whether this frame is just about to return. |
| 452 bool IsBreakAtReturn(JavaScriptFrame* frame); | 453 bool IsBreakAtReturn(JavaScriptFrame* frame); |
| 453 | 454 |
| 454 // Promise handling. | 455 // Promise handling. |
| 455 void PromiseHandlePrologue(Handle<JSFunction> promise_getter); | 456 // Push and pop a promise and the current try-catch handler. |
| 456 void PromiseHandleEpilogue(); | 457 void PushPromise(Handle<JSObject> promise); |
| 458 void PopPromise(); |
| 457 | 459 |
| 458 // Support for LiveEdit | 460 // Support for LiveEdit |
| 459 void FramesHaveBeenDropped(StackFrame::Id new_break_frame_id, | 461 void FramesHaveBeenDropped(StackFrame::Id new_break_frame_id, |
| 460 LiveEdit::FrameDropMode mode, | 462 LiveEdit::FrameDropMode mode, |
| 461 Object** restarter_frame_function_pointer); | 463 Object** restarter_frame_function_pointer); |
| 462 | 464 |
| 463 // Passed to MakeWeak. | 465 // Passed to MakeWeak. |
| 464 static void HandleWeakDebugInfo( | 466 static void HandleWeakDebugInfo( |
| 465 const v8::WeakCallbackData<v8::Value, void>& data); | 467 const v8::WeakCallbackData<v8::Value, void>& data); |
| 466 | 468 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 void UpdateState(); | 518 void UpdateState(); |
| 517 void Unload(); | 519 void Unload(); |
| 518 void SetNextBreakId() { | 520 void SetNextBreakId() { |
| 519 thread_local_.break_id_ = ++thread_local_.break_count_; | 521 thread_local_.break_id_ = ++thread_local_.break_count_; |
| 520 } | 522 } |
| 521 | 523 |
| 522 // Check whether there are commands in the command queue. | 524 // Check whether there are commands in the command queue. |
| 523 inline bool has_commands() const { return !command_queue_.IsEmpty(); } | 525 inline bool has_commands() const { return !command_queue_.IsEmpty(); } |
| 524 inline bool ignore_events() const { return is_suppressed_ || !is_active_; } | 526 inline bool ignore_events() const { return is_suppressed_ || !is_active_; } |
| 525 | 527 |
| 528 void OnException(Handle<Object> exception, bool uncaught, |
| 529 Handle<Object> promise); |
| 530 |
| 526 // Constructors for debug event objects. | 531 // Constructors for debug event objects. |
| 527 MUST_USE_RESULT MaybeHandle<Object> MakeJSObject( | 532 MUST_USE_RESULT MaybeHandle<Object> MakeJSObject( |
| 528 const char* constructor_name, | 533 const char* constructor_name, |
| 529 int argc, | 534 int argc, |
| 530 Handle<Object> argv[]); | 535 Handle<Object> argv[]); |
| 531 MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState(); | 536 MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState(); |
| 532 MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent( | 537 MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent( |
| 533 Handle<Object> break_points_hit); | 538 Handle<Object> break_points_hit); |
| 534 MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent( | 539 MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent( |
| 535 Handle<Object> exception, | 540 Handle<Object> exception, |
| 536 bool uncaught, | 541 bool uncaught, |
| 537 Handle<Object> promise); | 542 Handle<Object> promise); |
| 538 MUST_USE_RESULT MaybeHandle<Object> MakeCompileEvent( | 543 MUST_USE_RESULT MaybeHandle<Object> MakeCompileEvent( |
| 539 Handle<Script> script, v8::DebugEvent type); | 544 Handle<Script> script, v8::DebugEvent type); |
| 540 MUST_USE_RESULT MaybeHandle<Object> MakePromiseEvent( | 545 MUST_USE_RESULT MaybeHandle<Object> MakePromiseEvent( |
| 541 Handle<JSObject> promise_event); | 546 Handle<JSObject> promise_event); |
| 542 MUST_USE_RESULT MaybeHandle<Object> MakeAsyncTaskEvent( | 547 MUST_USE_RESULT MaybeHandle<Object> MakeAsyncTaskEvent( |
| 543 Handle<JSObject> task_event); | 548 Handle<JSObject> task_event); |
| 544 | 549 |
| 545 // Mirror cache handling. | 550 // Mirror cache handling. |
| 546 void ClearMirrorCache(); | 551 void ClearMirrorCache(); |
| 547 | 552 |
| 548 // Returns a promise if it does not have a reject handler. | 553 // Returns a promise if the pushed try-catch handler matches the current one. |
| 549 Handle<Object> GetPromiseForUncaughtException(); | 554 Handle<Object> GetPromiseOnStackOnThrow(); |
| 555 bool PromiseHasRejectHandler(Handle<JSObject> promise); |
| 550 | 556 |
| 551 void CallEventCallback(v8::DebugEvent event, | 557 void CallEventCallback(v8::DebugEvent event, |
| 552 Handle<Object> exec_state, | 558 Handle<Object> exec_state, |
| 553 Handle<Object> event_data, | 559 Handle<Object> event_data, |
| 554 v8::Debug::ClientData* client_data); | 560 v8::Debug::ClientData* client_data); |
| 555 void ProcessDebugEvent(v8::DebugEvent event, | 561 void ProcessDebugEvent(v8::DebugEvent event, |
| 556 Handle<JSObject> event_data, | 562 Handle<JSObject> event_data, |
| 557 bool auto_continue); | 563 bool auto_continue); |
| 558 void NotifyMessageHandler(v8::DebugEvent event, | 564 void NotifyMessageHandler(v8::DebugEvent event, |
| 559 Handle<JSObject> exec_state, | 565 Handle<JSObject> exec_state, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 // several frames above. | 767 // several frames above. |
| 762 // There is no calling conventions here, because it never actually gets | 768 // There is no calling conventions here, because it never actually gets |
| 763 // called, it only gets returned to. | 769 // called, it only gets returned to. |
| 764 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); | 770 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); |
| 765 }; | 771 }; |
| 766 | 772 |
| 767 | 773 |
| 768 } } // namespace v8::internal | 774 } } // namespace v8::internal |
| 769 | 775 |
| 770 #endif // V8_DEBUG_H_ | 776 #endif // V8_DEBUG_H_ |
| OLD | NEW |