| 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // API facing. | 304 // API facing. |
| 305 void SetEventListener(Handle<Object> callback, Handle<Object> data); | 305 void SetEventListener(Handle<Object> callback, Handle<Object> data); |
| 306 MUST_USE_RESULT MaybeHandle<Object> Call(Handle<Object> fun, | 306 MUST_USE_RESULT MaybeHandle<Object> Call(Handle<Object> fun, |
| 307 Handle<Object> data); | 307 Handle<Object> data); |
| 308 Handle<Context> GetDebugContext(); | 308 Handle<Context> GetDebugContext(); |
| 309 void HandleDebugBreak(); | 309 void HandleDebugBreak(); |
| 310 | 310 |
| 311 // Internal logic | 311 // Internal logic |
| 312 bool Load(); | 312 bool Load(); |
| 313 void Break(JavaScriptFrame* frame); | 313 void Break(JavaScriptFrame* frame); |
| 314 void SetAfterBreakTarget(JavaScriptFrame* frame); | |
| 315 | 314 |
| 316 // Scripts handling. | 315 // Scripts handling. |
| 317 Handle<FixedArray> GetLoadedScripts(); | 316 Handle<FixedArray> GetLoadedScripts(); |
| 318 | 317 |
| 319 // Break point handling. | 318 // Break point handling. |
| 320 bool SetBreakPoint(Handle<JSFunction> function, | 319 bool SetBreakPoint(Handle<JSFunction> function, |
| 321 Handle<Object> break_point_object, | 320 Handle<Object> break_point_object, |
| 322 int* source_position); | 321 int* source_position); |
| 323 bool SetBreakPointForScript(Handle<Script> script, | 322 bool SetBreakPointForScript(Handle<Script> script, |
| 324 Handle<Object> break_point_object, | 323 Handle<Object> break_point_object, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 Handle<SharedFunctionInfo> shared, | 376 Handle<SharedFunctionInfo> shared, |
| 378 BreakPositionAlignment position_aligment); | 377 BreakPositionAlignment position_aligment); |
| 379 | 378 |
| 380 // Check whether a global object is the debug global object. | 379 // Check whether a global object is the debug global object. |
| 381 bool IsDebugGlobal(JSGlobalObject* global); | 380 bool IsDebugGlobal(JSGlobalObject* global); |
| 382 | 381 |
| 383 // Check whether this frame is just about to return. | 382 // Check whether this frame is just about to return. |
| 384 bool IsBreakAtReturn(JavaScriptFrame* frame); | 383 bool IsBreakAtReturn(JavaScriptFrame* frame); |
| 385 | 384 |
| 386 // Support for LiveEdit | 385 // Support for LiveEdit |
| 387 void FramesHaveBeenDropped(StackFrame::Id new_break_frame_id, | 386 void ScheduleFrameRestart(StackFrame* frame); |
| 388 LiveEditFrameDropMode mode); | |
| 389 | 387 |
| 390 bool IsFrameBlackboxed(JavaScriptFrame* frame); | 388 bool IsFrameBlackboxed(JavaScriptFrame* frame); |
| 391 | 389 |
| 392 // Threading support. | 390 // Threading support. |
| 393 char* ArchiveDebug(char* to); | 391 char* ArchiveDebug(char* to); |
| 394 char* RestoreDebug(char* from); | 392 char* RestoreDebug(char* from); |
| 395 static int ArchiveSpacePerThread(); | 393 static int ArchiveSpacePerThread(); |
| 396 void FreeThreadResources() { } | 394 void FreeThreadResources() { } |
| 397 void Iterate(ObjectVisitor* v); | 395 void Iterate(ObjectVisitor* v); |
| 398 | 396 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 423 inline bool is_loaded() const { return !debug_context_.is_null(); } | 421 inline bool is_loaded() const { return !debug_context_.is_null(); } |
| 424 inline bool in_debug_scope() const { | 422 inline bool in_debug_scope() const { |
| 425 return !!base::NoBarrier_Load(&thread_local_.current_debug_scope_); | 423 return !!base::NoBarrier_Load(&thread_local_.current_debug_scope_); |
| 426 } | 424 } |
| 427 void set_break_points_active(bool v) { break_points_active_ = v; } | 425 void set_break_points_active(bool v) { break_points_active_ = v; } |
| 428 bool break_points_active() const { return break_points_active_; } | 426 bool break_points_active() const { return break_points_active_; } |
| 429 | 427 |
| 430 StackFrame::Id break_frame_id() { return thread_local_.break_frame_id_; } | 428 StackFrame::Id break_frame_id() { return thread_local_.break_frame_id_; } |
| 431 int break_id() { return thread_local_.break_id_; } | 429 int break_id() { return thread_local_.break_id_; } |
| 432 | 430 |
| 433 Handle<Object> return_value() { return thread_local_.return_value_; } | 431 Object* return_value() { return thread_local_.return_value_; } |
| 434 void set_return_value(Handle<Object> value) { | 432 void set_return_value(Object* value) { thread_local_.return_value_ = value; } |
| 435 thread_local_.return_value_ = value; | |
| 436 } | |
| 437 | 433 |
| 438 // Support for embedding into generated code. | 434 // Support for embedding into generated code. |
| 439 Address is_active_address() { | 435 Address is_active_address() { |
| 440 return reinterpret_cast<Address>(&is_active_); | 436 return reinterpret_cast<Address>(&is_active_); |
| 441 } | 437 } |
| 442 | 438 |
| 443 Address hook_on_function_call_address() { | 439 Address hook_on_function_call_address() { |
| 444 return reinterpret_cast<Address>(&hook_on_function_call_); | 440 return reinterpret_cast<Address>(&hook_on_function_call_); |
| 445 } | 441 } |
| 446 | 442 |
| 447 Address after_break_target_address() { | |
| 448 return reinterpret_cast<Address>(&after_break_target_); | |
| 449 } | |
| 450 | |
| 451 Address last_step_action_address() { | 443 Address last_step_action_address() { |
| 452 return reinterpret_cast<Address>(&thread_local_.last_step_action_); | 444 return reinterpret_cast<Address>(&thread_local_.last_step_action_); |
| 453 } | 445 } |
| 454 | 446 |
| 455 Address suspended_generator_address() { | 447 Address suspended_generator_address() { |
| 456 return reinterpret_cast<Address>(&thread_local_.suspended_generator_); | 448 return reinterpret_cast<Address>(&thread_local_.suspended_generator_); |
| 457 } | 449 } |
| 458 | 450 |
| 451 Address restart_fp_address() { |
| 452 return reinterpret_cast<Address>(&thread_local_.restart_fp_); |
| 453 } |
| 454 |
| 459 StepAction last_step_action() { return thread_local_.last_step_action_; } | 455 StepAction last_step_action() { return thread_local_.last_step_action_; } |
| 460 | 456 |
| 461 DebugFeatureTracker* feature_tracker() { return &feature_tracker_; } | 457 DebugFeatureTracker* feature_tracker() { return &feature_tracker_; } |
| 462 | 458 |
| 463 private: | 459 private: |
| 464 explicit Debug(Isolate* isolate); | 460 explicit Debug(Isolate* isolate); |
| 465 | 461 |
| 466 void UpdateState(); | 462 void UpdateState(); |
| 467 void UpdateHookOnFunctionCall(); | 463 void UpdateHookOnFunctionCall(); |
| 468 void Unload(); | 464 void Unload(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 // Trigger debug break events for all exceptions. | 575 // Trigger debug break events for all exceptions. |
| 580 bool break_on_exception_; | 576 bool break_on_exception_; |
| 581 // Trigger debug break events for uncaught exceptions. | 577 // Trigger debug break events for uncaught exceptions. |
| 582 bool break_on_uncaught_exception_; | 578 bool break_on_uncaught_exception_; |
| 583 // Termination exception because side effect check has failed. | 579 // Termination exception because side effect check has failed. |
| 584 bool side_effect_check_failed_; | 580 bool side_effect_check_failed_; |
| 585 | 581 |
| 586 // List of active debug info objects. | 582 // List of active debug info objects. |
| 587 DebugInfoListNode* debug_info_list_; | 583 DebugInfoListNode* debug_info_list_; |
| 588 | 584 |
| 589 // Storage location for jump when exiting debug break calls. | |
| 590 // Note that this address is not GC safe. It should be computed immediately | |
| 591 // before returning to the DebugBreakCallHelper. | |
| 592 Address after_break_target_; | |
| 593 | |
| 594 // Used to collect histogram data on debugger feature usage. | 585 // Used to collect histogram data on debugger feature usage. |
| 595 DebugFeatureTracker feature_tracker_; | 586 DebugFeatureTracker feature_tracker_; |
| 596 | 587 |
| 597 // Per-thread data. | 588 // Per-thread data. |
| 598 class ThreadLocal { | 589 class ThreadLocal { |
| 599 public: | 590 public: |
| 600 // Top debugger entry. | 591 // Top debugger entry. |
| 601 base::AtomicWord current_debug_scope_; | 592 base::AtomicWord current_debug_scope_; |
| 602 | 593 |
| 603 // Counter for generating next break id. | 594 // Counter for generating next break id. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 614 | 605 |
| 615 // Source statement position from last step next action. | 606 // Source statement position from last step next action. |
| 616 int last_statement_position_; | 607 int last_statement_position_; |
| 617 | 608 |
| 618 // Frame pointer from last step next or step frame action. | 609 // Frame pointer from last step next or step frame action. |
| 619 Address last_fp_; | 610 Address last_fp_; |
| 620 | 611 |
| 621 // Frame pointer of the target frame we want to arrive at. | 612 // Frame pointer of the target frame we want to arrive at. |
| 622 Address target_fp_; | 613 Address target_fp_; |
| 623 | 614 |
| 624 // Stores the way how LiveEdit has patched the stack. It is used when | 615 // Value of the accumulator at the point of entering the debugger. |
| 625 // debugger returns control back to user script. | 616 Object* return_value_; |
| 626 LiveEditFrameDropMode frame_drop_mode_; | |
| 627 | 617 |
| 628 // Value of accumulator in interpreter frames. In non-interpreter frames | 618 // The suspended generator object to track when stepping. |
| 629 // this value will be the hole. | 619 Object* suspended_generator_; |
| 630 Handle<Object> return_value_; | |
| 631 | 620 |
| 632 Object* suspended_generator_; | 621 // The new frame pointer to drop to when restarting a frame. |
| 622 Address restart_fp_; |
| 633 | 623 |
| 634 int async_task_count_; | 624 int async_task_count_; |
| 635 }; | 625 }; |
| 636 | 626 |
| 637 // Storage location for registers when handling debug break calls | 627 // Storage location for registers when handling debug break calls |
| 638 ThreadLocal thread_local_; | 628 ThreadLocal thread_local_; |
| 639 | 629 |
| 640 Isolate* isolate_; | 630 Isolate* isolate_; |
| 641 | 631 |
| 642 friend class Isolate; | 632 friend class Isolate; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 class DebugCodegen : public AllStatic { | 730 class DebugCodegen : public AllStatic { |
| 741 public: | 731 public: |
| 742 enum DebugBreakCallHelperMode { | 732 enum DebugBreakCallHelperMode { |
| 743 SAVE_RESULT_REGISTER, | 733 SAVE_RESULT_REGISTER, |
| 744 IGNORE_RESULT_REGISTER | 734 IGNORE_RESULT_REGISTER |
| 745 }; | 735 }; |
| 746 | 736 |
| 747 static void GenerateDebugBreakStub(MacroAssembler* masm, | 737 static void GenerateDebugBreakStub(MacroAssembler* masm, |
| 748 DebugBreakCallHelperMode mode); | 738 DebugBreakCallHelperMode mode); |
| 749 | 739 |
| 750 // FrameDropper is a code replacement for a JavaScript frame with possibly | 740 static void GenerateSlot(MacroAssembler* masm, RelocInfo::Mode mode); |
| 751 // several frames above. | |
| 752 // There is no calling conventions here, because it never actually gets | |
| 753 // called, it only gets returned to. | |
| 754 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); | |
| 755 | 741 |
| 742 // Builtin to drop frames to restart function. |
| 743 static void GenerateFrameDropperTrampoline(MacroAssembler* masm); |
| 756 | 744 |
| 757 static void GenerateSlot(MacroAssembler* masm, RelocInfo::Mode mode); | 745 // Builtin to atomically (wrt deopts) handle debugger statement and |
| 746 // drop frames to restart function if necessary. |
| 747 static void GenerateHandleDebuggerStatement(MacroAssembler* masm); |
| 758 | 748 |
| 759 static void PatchDebugBreakSlot(Isolate* isolate, Address pc, | 749 static void PatchDebugBreakSlot(Isolate* isolate, Address pc, |
| 760 Handle<Code> code); | 750 Handle<Code> code); |
| 761 static bool DebugBreakSlotIsPatched(Address pc); | 751 static bool DebugBreakSlotIsPatched(Address pc); |
| 762 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); | 752 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); |
| 763 }; | 753 }; |
| 764 | 754 |
| 765 | 755 |
| 766 } // namespace internal | 756 } // namespace internal |
| 767 } // namespace v8 | 757 } // namespace v8 |
| 768 | 758 |
| 769 #endif // V8_DEBUG_DEBUG_H_ | 759 #endif // V8_DEBUG_DEBUG_H_ |
| OLD | NEW |