Chromium Code Reviews| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 LastStepAction = StepIn | 43 LastStepAction = StepIn |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // Type of exception break. NOTE: These values are in macros.py as well. | 46 // Type of exception break. NOTE: These values are in macros.py as well. |
| 47 enum ExceptionBreakType { | 47 enum ExceptionBreakType { |
| 48 BreakException = 0, | 48 BreakException = 0, |
| 49 BreakUncaughtException = 1 | 49 BreakUncaughtException = 1 |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 | 52 |
| 53 // Type of exception break. | |
| 54 enum BreakLocatorType { ALL_BREAK_LOCATIONS, CALLS_AND_RETURNS }; | |
| 55 | |
| 56 | |
| 57 // The different types of breakpoint position alignments. | 53 // The different types of breakpoint position alignments. |
| 58 // Must match Debug.BreakPositionAlignment in debug.js | 54 // Must match Debug.BreakPositionAlignment in debug.js |
| 59 enum BreakPositionAlignment { | 55 enum BreakPositionAlignment { |
| 60 STATEMENT_ALIGNED = 0, | 56 STATEMENT_ALIGNED = 0, |
| 61 BREAK_POSITION_ALIGNED = 1 | 57 BREAK_POSITION_ALIGNED = 1 |
| 62 }; | 58 }; |
| 63 | 59 |
| 64 enum DebugBreakType { | 60 enum DebugBreakType { |
| 65 NOT_DEBUG_BREAK, | 61 NOT_DEBUG_BREAK, |
| 66 DEBUGGER_STATEMENT, | 62 DEBUGGER_STATEMENT, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 DebugBreakType type_; | 111 DebugBreakType type_; |
| 116 int position_; | 112 int position_; |
| 117 | 113 |
| 118 friend class CodeBreakIterator; | 114 friend class CodeBreakIterator; |
| 119 friend class BytecodeArrayBreakIterator; | 115 friend class BytecodeArrayBreakIterator; |
| 120 }; | 116 }; |
| 121 | 117 |
| 122 class BreakIterator { | 118 class BreakIterator { |
| 123 public: | 119 public: |
| 124 static std::unique_ptr<BreakIterator> GetIterator( | 120 static std::unique_ptr<BreakIterator> GetIterator( |
| 125 Handle<DebugInfo> debug_info, Handle<AbstractCode> abstract_code, | 121 Handle<DebugInfo> debug_info, Handle<AbstractCode> abstract_code); |
| 126 BreakLocatorType type = ALL_BREAK_LOCATIONS); | |
| 127 | 122 |
| 128 virtual ~BreakIterator() {} | 123 virtual ~BreakIterator() {} |
| 129 | 124 |
| 130 virtual BreakLocation GetBreakLocation() = 0; | 125 virtual BreakLocation GetBreakLocation() = 0; |
| 131 virtual bool Done() const = 0; | 126 virtual bool Done() const = 0; |
| 132 virtual void Next() = 0; | 127 virtual void Next() = 0; |
| 133 | 128 |
| 134 void SkipTo(int count) { | 129 void SkipTo(int count) { |
| 135 while (count-- > 0) Next(); | 130 while (count-- > 0) Next(); |
| 136 } | 131 } |
| 137 | 132 |
| 138 virtual int code_offset() = 0; | 133 virtual int code_offset() = 0; |
| 139 int break_index() const { return break_index_; } | 134 int break_index() const { return break_index_; } |
| 140 inline int position() const { return position_; } | 135 inline int position() const { return position_; } |
| 141 inline int statement_position() const { return statement_position_; } | 136 inline int statement_position() const { return statement_position_; } |
| 142 | 137 |
| 143 virtual bool IsDebugBreak() = 0; | 138 virtual bool IsDebugBreak() = 0; |
| 144 virtual void ClearDebugBreak() = 0; | 139 virtual void ClearDebugBreak() = 0; |
| 145 virtual void SetDebugBreak() = 0; | 140 virtual void SetDebugBreak() = 0; |
| 146 | 141 |
| 147 protected: | 142 protected: |
| 148 explicit BreakIterator(Handle<DebugInfo> debug_info, | 143 explicit BreakIterator(Handle<DebugInfo> debug_info); |
| 149 BreakLocatorType break_locator_type); | |
| 150 | 144 |
| 151 int BreakIndexFromPosition(int position, BreakPositionAlignment alignment); | 145 int BreakIndexFromPosition(int position, BreakPositionAlignment alignment); |
| 152 | 146 |
| 153 Isolate* isolate() { return debug_info_->GetIsolate(); } | 147 Isolate* isolate() { return debug_info_->GetIsolate(); } |
| 154 | 148 |
| 155 Handle<DebugInfo> debug_info_; | 149 Handle<DebugInfo> debug_info_; |
| 156 int break_index_; | 150 int break_index_; |
| 157 int position_; | 151 int position_; |
| 158 int statement_position_; | 152 int statement_position_; |
| 159 BreakLocatorType break_locator_type_; | |
| 160 | 153 |
| 161 private: | 154 private: |
| 162 DisallowHeapAllocation no_gc_; | 155 DisallowHeapAllocation no_gc_; |
| 163 DISALLOW_COPY_AND_ASSIGN(BreakIterator); | 156 DISALLOW_COPY_AND_ASSIGN(BreakIterator); |
| 164 }; | 157 }; |
| 165 | 158 |
| 166 class CodeBreakIterator : public BreakIterator { | 159 class CodeBreakIterator : public BreakIterator { |
| 167 public: | 160 public: |
| 168 CodeBreakIterator(Handle<DebugInfo> debug_info, BreakLocatorType type); | 161 explicit CodeBreakIterator(Handle<DebugInfo> debug_info); |
| 169 ~CodeBreakIterator() override {} | 162 ~CodeBreakIterator() override {} |
| 170 | 163 |
| 171 BreakLocation GetBreakLocation() override; | 164 BreakLocation GetBreakLocation() override; |
| 172 bool Done() const override { return reloc_iterator_.done(); } | 165 bool Done() const override { return reloc_iterator_.done(); } |
| 173 void Next() override; | 166 void Next() override; |
| 174 | 167 |
| 175 bool IsDebugBreak() override; | 168 bool IsDebugBreak() override; |
| 176 void ClearDebugBreak() override; | 169 void ClearDebugBreak() override; |
| 177 void SetDebugBreak() override; | 170 void SetDebugBreak() override; |
| 178 | 171 |
| 179 void SkipToPosition(int position, BreakPositionAlignment alignment); | 172 void SkipToPosition(int position, BreakPositionAlignment alignment); |
| 180 | 173 |
| 181 int code_offset() override { | 174 int code_offset() override { |
| 182 return static_cast<int>(rinfo()->pc() - | 175 return static_cast<int>(rinfo()->pc() - |
| 183 debug_info_->DebugCode()->instruction_start()); | 176 debug_info_->DebugCode()->instruction_start()); |
| 184 } | 177 } |
| 185 | 178 |
| 186 private: | 179 private: |
| 187 int GetModeMask(BreakLocatorType type); | 180 int GetModeMask(); |
| 188 DebugBreakType GetDebugBreakType(); | 181 DebugBreakType GetDebugBreakType(); |
| 189 | 182 |
| 190 RelocInfo::Mode rmode() { return reloc_iterator_.rinfo()->rmode(); } | 183 RelocInfo::Mode rmode() { return reloc_iterator_.rinfo()->rmode(); } |
| 191 RelocInfo* rinfo() { return reloc_iterator_.rinfo(); } | 184 RelocInfo* rinfo() { return reloc_iterator_.rinfo(); } |
| 192 | 185 |
| 193 RelocIterator reloc_iterator_; | 186 RelocIterator reloc_iterator_; |
| 194 SourcePositionTableIterator source_position_iterator_; | 187 SourcePositionTableIterator source_position_iterator_; |
| 195 DISALLOW_COPY_AND_ASSIGN(CodeBreakIterator); | 188 DISALLOW_COPY_AND_ASSIGN(CodeBreakIterator); |
| 196 }; | 189 }; |
| 197 | 190 |
| 198 class BytecodeArrayBreakIterator : public BreakIterator { | 191 class BytecodeArrayBreakIterator : public BreakIterator { |
| 199 public: | 192 public: |
| 200 BytecodeArrayBreakIterator(Handle<DebugInfo> debug_info, | 193 explicit BytecodeArrayBreakIterator(Handle<DebugInfo> debug_info); |
| 201 BreakLocatorType type); | |
| 202 ~BytecodeArrayBreakIterator() override {} | 194 ~BytecodeArrayBreakIterator() override {} |
| 203 | 195 |
| 204 BreakLocation GetBreakLocation() override; | 196 BreakLocation GetBreakLocation() override; |
| 205 bool Done() const override { return source_position_iterator_.done(); } | 197 bool Done() const override { return source_position_iterator_.done(); } |
| 206 void Next() override; | 198 void Next() override; |
| 207 | 199 |
| 208 bool IsDebugBreak() override; | 200 bool IsDebugBreak() override; |
| 209 void ClearDebugBreak() override; | 201 void ClearDebugBreak() override; |
| 210 void SetDebugBreak() override; | 202 void SetDebugBreak() override; |
| 211 | 203 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 void RunPromiseHook(PromiseHookType type, Handle<JSPromise> promise, | 344 void RunPromiseHook(PromiseHookType type, Handle<JSPromise> promise, |
| 353 Handle<Object> parent); | 345 Handle<Object> parent); |
| 354 | 346 |
| 355 int NextAsyncTaskId(Handle<JSObject> promise); | 347 int NextAsyncTaskId(Handle<JSObject> promise); |
| 356 | 348 |
| 357 bool IsBlackboxed(Handle<SharedFunctionInfo> shared); | 349 bool IsBlackboxed(Handle<SharedFunctionInfo> shared); |
| 358 | 350 |
| 359 void SetDebugDelegate(debug::DebugDelegate* delegate); | 351 void SetDebugDelegate(debug::DebugDelegate* delegate); |
| 360 | 352 |
| 361 // Returns whether the operation succeeded. Compilation can only be triggered | 353 // Returns whether the operation succeeded. Compilation can only be triggered |
| 362 // if a valid closure is passed as the second argument, otherwise the shared | 354 // if a valid closure is passed as the second argument, otherwise the shared |
|
jgruber
2017/01/30 15:42:17
Comment seems outdated.
| |
| 363 // function needs to be compiled already. | 355 // function needs to be compiled already. |
| 364 bool EnsureDebugInfo(Handle<SharedFunctionInfo> shared, | 356 bool EnsureDebugInfo(Handle<SharedFunctionInfo> shared); |
| 365 Handle<JSFunction> function); | |
| 366 void CreateDebugInfo(Handle<SharedFunctionInfo> shared); | 357 void CreateDebugInfo(Handle<SharedFunctionInfo> shared); |
| 367 static Handle<DebugInfo> GetDebugInfo(Handle<SharedFunctionInfo> shared); | 358 static Handle<DebugInfo> GetDebugInfo(Handle<SharedFunctionInfo> shared); |
| 368 | 359 |
| 369 template <typename C> | 360 template <typename C> |
| 370 bool CompileToRevealInnerFunctions(C* compilable); | 361 bool CompileToRevealInnerFunctions(C* compilable); |
| 371 | 362 |
| 372 // This function is used in FunctionNameUsing* tests. | 363 // This function is used in FunctionNameUsing* tests. |
| 373 Handle<Object> FindSharedFunctionInfoInScript(Handle<Script> script, | 364 Handle<Object> FindSharedFunctionInfoInScript(Handle<Script> script, |
| 374 int position); | 365 int position); |
| 375 | 366 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 private: | 454 private: |
| 464 explicit Debug(Isolate* isolate); | 455 explicit Debug(Isolate* isolate); |
| 465 | 456 |
| 466 void UpdateState(); | 457 void UpdateState(); |
| 467 void UpdateHookOnFunctionCall(); | 458 void UpdateHookOnFunctionCall(); |
| 468 void Unload(); | 459 void Unload(); |
| 469 void SetNextBreakId() { | 460 void SetNextBreakId() { |
| 470 thread_local_.break_id_ = ++thread_local_.break_count_; | 461 thread_local_.break_id_ = ++thread_local_.break_count_; |
| 471 } | 462 } |
| 472 | 463 |
| 464 // Return the number of virtual frames below debugger entry. | |
| 465 int CurrentFrameCount(); | |
| 466 | |
| 473 inline bool ignore_events() const { | 467 inline bool ignore_events() const { |
| 474 return is_suppressed_ || !is_active_ || isolate_->needs_side_effect_check(); | 468 return is_suppressed_ || !is_active_ || isolate_->needs_side_effect_check(); |
| 475 } | 469 } |
| 476 inline bool break_disabled() const { | 470 inline bool break_disabled() const { |
| 477 return break_disabled_ || in_debug_event_listener_; | 471 return break_disabled_ || in_debug_event_listener_; |
| 478 } | 472 } |
| 479 | 473 |
| 480 void clear_suspended_generator() { | 474 void clear_suspended_generator() { |
| 481 thread_local_.suspended_generator_ = Smi::kZero; | 475 thread_local_.suspended_generator_ = Smi::kZero; |
| 482 } | 476 } |
| 483 | 477 |
| 484 bool has_suspended_generator() const { | 478 bool has_suspended_generator() const { |
| 485 return thread_local_.suspended_generator_ != Smi::kZero; | 479 return thread_local_.suspended_generator_ != Smi::kZero; |
| 486 } | 480 } |
| 487 | 481 |
| 488 // There are three types of event listeners: C++ message_handler, | 482 // There are three types of event listeners: C++ message_handler, |
| 489 // JavaScript event listener and C++ event listener. | 483 // JavaScript event listener and C++ event listener. |
| 490 // Currently inspector still uses C++ event listener and installs | 484 // Currently inspector still uses C++ event listener and installs |
| 491 // more specific event listeners for part of events. Calling of | 485 // more specific event listeners for part of events. Calling of |
| 492 // C++ event listener is redundant when more specific event listener | 486 // C++ event listener is redundant when more specific event listener |
| 493 // is presented. Other clients can install JavaScript event listener | 487 // is presented. Other clients can install JavaScript event listener |
| 494 // (e.g. some of NodeJS module). | 488 // (e.g. some of NodeJS module). |
| 495 bool non_inspector_listener_exists() const { | 489 bool non_inspector_listener_exists() const { |
| 496 return !event_listener_.is_null() && !event_listener_->IsForeign(); | 490 return !event_listener_.is_null() && !event_listener_->IsForeign(); |
| 497 } | 491 } |
| 498 | 492 |
| 499 bool IsBlackboxed(SharedFunctionInfo* shared); | |
| 500 bool IsExceptionBlackboxed(bool uncaught); | 493 bool IsExceptionBlackboxed(bool uncaught); |
| 501 | 494 |
| 502 void OnException(Handle<Object> exception, Handle<Object> promise); | 495 void OnException(Handle<Object> exception, Handle<Object> promise); |
| 503 | 496 |
| 504 // Constructors for debug event objects. | 497 // Constructors for debug event objects. |
| 505 MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState(); | 498 MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState(); |
| 506 MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent( | 499 MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent( |
| 507 Handle<Object> break_points_hit); | 500 Handle<Object> break_points_hit); |
| 508 MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent( | 501 MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent( |
| 509 Handle<Object> exception, | 502 Handle<Object> exception, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 523 // Find the closest source position for a break point for a given position. | 516 // Find the closest source position for a break point for a given position. |
| 524 int FindBreakablePosition(Handle<DebugInfo> debug_info, int source_position, | 517 int FindBreakablePosition(Handle<DebugInfo> debug_info, int source_position, |
| 525 BreakPositionAlignment alignment); | 518 BreakPositionAlignment alignment); |
| 526 // Instrument code to break at break points. | 519 // Instrument code to break at break points. |
| 527 void ApplyBreakPoints(Handle<DebugInfo> debug_info); | 520 void ApplyBreakPoints(Handle<DebugInfo> debug_info); |
| 528 // Clear code from instrumentation. | 521 // Clear code from instrumentation. |
| 529 void ClearBreakPoints(Handle<DebugInfo> debug_info); | 522 void ClearBreakPoints(Handle<DebugInfo> debug_info); |
| 530 // Clear all code from instrumentation. | 523 // Clear all code from instrumentation. |
| 531 void ClearAllBreakPoints(); | 524 void ClearAllBreakPoints(); |
| 532 // Instrument a function with one-shots. | 525 // Instrument a function with one-shots. |
| 533 void FloodWithOneShot(Handle<JSFunction> function, | 526 void FloodWithOneShot(Handle<SharedFunctionInfo> function); |
| 534 BreakLocatorType type = ALL_BREAK_LOCATIONS); | |
| 535 // Clear all one-shot instrumentations, but restore break points. | 527 // Clear all one-shot instrumentations, but restore break points. |
| 536 void ClearOneShot(); | 528 void ClearOneShot(); |
| 537 | 529 |
| 538 void ActivateStepOut(StackFrame* frame); | 530 void ActivateStepOut(StackFrame* frame); |
| 539 void RemoveDebugInfoAndClearFromShared(Handle<DebugInfo> debug_info); | 531 void RemoveDebugInfoAndClearFromShared(Handle<DebugInfo> debug_info); |
| 540 MaybeHandle<FixedArray> CheckBreakPoints(Handle<DebugInfo> debug_info, | 532 MaybeHandle<FixedArray> CheckBreakPoints(Handle<DebugInfo> debug_info, |
| 541 BreakLocation* location, | 533 BreakLocation* location, |
| 542 bool* has_break_points = nullptr); | 534 bool* has_break_points = nullptr); |
| 543 bool IsMutedAtCurrentLocation(JavaScriptFrame* frame); | 535 bool IsMutedAtCurrentLocation(JavaScriptFrame* frame); |
| 544 bool CheckBreakPoint(Handle<Object> break_point_object); | 536 bool CheckBreakPoint(Handle<Object> break_point_object); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 // Frame id for the frame of the current break. | 601 // Frame id for the frame of the current break. |
| 610 StackFrame::Id break_frame_id_; | 602 StackFrame::Id break_frame_id_; |
| 611 | 603 |
| 612 // Step action for last step performed. | 604 // Step action for last step performed. |
| 613 StepAction last_step_action_; | 605 StepAction last_step_action_; |
| 614 | 606 |
| 615 // Source statement position from last step next action. | 607 // Source statement position from last step next action. |
| 616 int last_statement_position_; | 608 int last_statement_position_; |
| 617 | 609 |
| 618 // Frame pointer from last step next or step frame action. | 610 // Frame pointer from last step next or step frame action. |
| 619 Address last_fp_; | 611 int last_frame_count_; |
| 620 | 612 |
| 621 // Frame pointer of the target frame we want to arrive at. | 613 // Frame pointer of the target frame we want to arrive at. |
| 622 Address target_fp_; | 614 int target_frame_count_; |
| 623 | 615 |
| 624 // Stores the way how LiveEdit has patched the stack. It is used when | 616 // Stores the way how LiveEdit has patched the stack. It is used when |
| 625 // debugger returns control back to user script. | 617 // debugger returns control back to user script. |
| 626 LiveEditFrameDropMode frame_drop_mode_; | 618 LiveEditFrameDropMode frame_drop_mode_; |
| 627 | 619 |
| 628 // Value of accumulator in interpreter frames. In non-interpreter frames | 620 // Value of accumulator in interpreter frames. In non-interpreter frames |
| 629 // this value will be the hole. | 621 // this value will be the hole. |
| 630 Handle<Object> return_value_; | 622 Handle<Object> return_value_; |
| 631 | 623 |
| 632 Object* suspended_generator_; | 624 Object* suspended_generator_; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 760 Handle<Code> code); | 752 Handle<Code> code); |
| 761 static bool DebugBreakSlotIsPatched(Address pc); | 753 static bool DebugBreakSlotIsPatched(Address pc); |
| 762 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); | 754 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); |
| 763 }; | 755 }; |
| 764 | 756 |
| 765 | 757 |
| 766 } // namespace internal | 758 } // namespace internal |
| 767 } // namespace v8 | 759 } // namespace v8 |
| 768 | 760 |
| 769 #endif // V8_DEBUG_DEBUG_H_ | 761 #endif // V8_DEBUG_DEBUG_H_ |
| OLD | NEW |