| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. | 53 // Type of exception break. |
| 54 enum BreakLocatorType { | 54 enum BreakLocatorType { ALL_BREAK_LOCATIONS, CALLS_AND_RETURNS }; |
| 55 ALL_BREAK_LOCATIONS = 0, | |
| 56 SOURCE_BREAK_LOCATIONS = 1, | |
| 57 CALLS_AND_RETURNS = 2 | |
| 58 }; | |
| 59 | 55 |
| 60 | 56 |
| 61 // The different types of breakpoint position alignments. | 57 // The different types of breakpoint position alignments. |
| 62 // Must match Debug.BreakPositionAlignment in debug-debugger.js | 58 // Must match Debug.BreakPositionAlignment in debug-debugger.js |
| 63 enum BreakPositionAlignment { | 59 enum BreakPositionAlignment { |
| 64 STATEMENT_ALIGNED = 0, | 60 STATEMENT_ALIGNED = 0, |
| 65 BREAK_POSITION_ALIGNED = 1 | 61 BREAK_POSITION_ALIGNED = 1 |
| 66 }; | 62 }; |
| 67 | 63 |
| 68 | 64 |
| 69 class BreakLocation { | 65 class BreakLocation { |
| 70 public: | 66 public: |
| 71 // Find the break point at the supplied address, or the closest one before | 67 // Find the break point at the supplied address, or the closest one before |
| 72 // the address. | 68 // the address. |
| 73 static BreakLocation FromAddress(Handle<DebugInfo> debug_info, | 69 static BreakLocation FromAddress(Handle<DebugInfo> debug_info, |
| 74 BreakLocatorType type, Address pc); | 70 BreakLocatorType type, Address pc); |
| 75 | 71 |
| 76 static void FromAddressSameStatement(Handle<DebugInfo> debug_info, | 72 static void FromAddressSameStatement(Handle<DebugInfo> debug_info, |
| 77 BreakLocatorType type, Address pc, | 73 BreakLocatorType type, Address pc, |
| 78 List<BreakLocation>* result_out); | 74 List<BreakLocation>* result_out); |
| 79 | 75 |
| 80 static BreakLocation FromPosition(Handle<DebugInfo> debug_info, | 76 static BreakLocation FromPosition(Handle<DebugInfo> debug_info, |
| 81 BreakLocatorType type, int position, | 77 BreakLocatorType type, int position, |
| 82 BreakPositionAlignment alignment); | 78 BreakPositionAlignment alignment); |
| 83 | 79 |
| 84 bool IsDebugBreak() const; | 80 bool IsDebugBreak() const; |
| 85 inline bool IsExit() const { return RelocInfo::IsJSReturn(rmode_); } | 81 inline bool IsExit() const { return RelocInfo::IsJSReturn(rmode_); } |
| 82 inline bool IsCall() const { |
| 83 return IsDebugBreakSlot() && RelocInfo::DebugBreakIsCall(data_); |
| 84 } |
| 86 inline bool IsConstructCall() const { | 85 inline bool IsConstructCall() const { |
| 87 return RelocInfo::IsConstructCall(rmode_); | 86 return IsDebugBreakSlot() && RelocInfo::DebugBreakIsConstructCall(data_); |
| 88 } | 87 } |
| 89 inline bool IsCodeTarget() const { return RelocInfo::IsCodeTarget(rmode_); } | 88 inline int CallArgumentsCount() const { |
| 90 | 89 DCHECK(IsCall()); |
| 91 Handle<Code> CodeTarget() const; | 90 return RelocInfo::DebugBreakCallArgumentsCount(data_); |
| 92 Handle<Code> OriginalCodeTarget() const; | 91 } |
| 93 | 92 |
| 94 bool IsStepInLocation() const; | 93 bool IsStepInLocation() const; |
| 95 inline bool HasBreakPoint() const { | 94 inline bool HasBreakPoint() const { |
| 96 return debug_info_->HasBreakPoint(pc_offset_); | 95 return debug_info_->HasBreakPoint(pc_offset_); |
| 97 } | 96 } |
| 98 | 97 |
| 99 Handle<Object> BreakPointObjects() const; | 98 Handle<Object> BreakPointObjects() const; |
| 100 | 99 |
| 101 void SetBreakPoint(Handle<Object> break_point_object); | 100 void SetBreakPoint(Handle<Object> break_point_object); |
| 102 void ClearBreakPoint(Handle<Object> break_point_object); | 101 void ClearBreakPoint(Handle<Object> break_point_object); |
| 103 | 102 |
| 104 void SetOneShot(); | 103 void SetOneShot(); |
| 105 void ClearOneShot(); | 104 void ClearOneShot(); |
| 106 | 105 |
| 106 |
| 107 inline RelocInfo rinfo() const { | 107 inline RelocInfo rinfo() const { |
| 108 return RelocInfo(pc(), rmode(), data_, code()); | 108 return RelocInfo(pc(), rmode(), data_, code()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 inline RelocInfo original_rinfo() const { | |
| 112 return RelocInfo(original_pc(), original_rmode(), original_data_, | |
| 113 original_code()); | |
| 114 } | |
| 115 | |
| 116 inline int position() const { return position_; } | 111 inline int position() const { return position_; } |
| 117 inline int statement_position() const { return statement_position_; } | 112 inline int statement_position() const { return statement_position_; } |
| 118 | 113 |
| 119 inline Address pc() const { return code()->entry() + pc_offset_; } | 114 inline Address pc() const { return code()->entry() + pc_offset_; } |
| 120 inline Address original_pc() const { | 115 inline Address original_pc() const { |
| 121 return original_code()->entry() + original_pc_offset_; | 116 return debug_info_->original_code()->entry() + original_pc_offset_; |
| 122 } | 117 } |
| 123 | 118 |
| 124 inline RelocInfo::Mode rmode() const { return rmode_; } | 119 inline RelocInfo::Mode rmode() const { return rmode_; } |
| 125 inline RelocInfo::Mode original_rmode() const { return original_rmode_; } | |
| 126 | 120 |
| 127 inline Code* code() const { return debug_info_->code(); } | 121 inline Code* code() const { return debug_info_->code(); } |
| 128 inline Code* original_code() const { return debug_info_->original_code(); } | |
| 129 | 122 |
| 130 private: | 123 private: |
| 131 BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo, | 124 BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo, |
| 132 RelocInfo* original_rinfo, int position, | 125 RelocInfo* original_rinfo, int position, |
| 133 int statement_position); | 126 int statement_position); |
| 134 | 127 |
| 135 class Iterator { | 128 class Iterator { |
| 136 public: | 129 public: |
| 137 Iterator(Handle<DebugInfo> debug_info, BreakLocatorType type); | 130 Iterator(Handle<DebugInfo> debug_info, BreakLocatorType type); |
| 138 | 131 |
| 139 BreakLocation GetBreakLocation() { | 132 BreakLocation GetBreakLocation() { |
| 140 return BreakLocation(debug_info_, rinfo(), original_rinfo(), position(), | 133 return BreakLocation(debug_info_, rinfo(), original_rinfo(), position(), |
| 141 statement_position()); | 134 statement_position()); |
| 142 } | 135 } |
| 143 | 136 |
| 144 inline bool Done() const { return RinfoDone(); } | 137 inline bool Done() const { return RinfoDone(); } |
| 145 void Next(); | 138 void Next(); |
| 146 | 139 |
| 147 void SkipTo(int count) { | 140 void SkipTo(int count) { |
| 148 while (count-- > 0) Next(); | 141 while (count-- > 0) Next(); |
| 149 } | 142 } |
| 150 | 143 |
| 151 inline RelocInfo::Mode rmode() { return reloc_iterator_.rinfo()->rmode(); } | 144 inline RelocInfo::Mode rmode() { return reloc_iterator_.rinfo()->rmode(); } |
| 152 inline RelocInfo::Mode original_rmode() { | |
| 153 return reloc_iterator_.rinfo()->rmode(); | |
| 154 } | |
| 155 | |
| 156 inline RelocInfo* rinfo() { return reloc_iterator_.rinfo(); } | 145 inline RelocInfo* rinfo() { return reloc_iterator_.rinfo(); } |
| 157 inline RelocInfo* original_rinfo() { | 146 inline RelocInfo* original_rinfo() { |
| 158 return reloc_iterator_original_.rinfo(); | 147 return reloc_iterator_original_.rinfo(); |
| 159 } | 148 } |
| 160 | 149 |
| 161 inline Address pc() { return rinfo()->pc(); } | 150 inline Address pc() { return rinfo()->pc(); } |
| 162 inline Address original_pc() { return original_rinfo()->pc(); } | |
| 163 | |
| 164 int break_index() const { return break_index_; } | 151 int break_index() const { return break_index_; } |
| 165 | |
| 166 inline int position() const { return position_; } | 152 inline int position() const { return position_; } |
| 167 inline int statement_position() const { return statement_position_; } | 153 inline int statement_position() const { return statement_position_; } |
| 168 | 154 |
| 169 private: | 155 private: |
| 170 bool RinfoDone() const; | 156 bool RinfoDone() const; |
| 171 void RinfoNext(); | 157 void RinfoNext(); |
| 172 | 158 |
| 173 Handle<DebugInfo> debug_info_; | 159 Handle<DebugInfo> debug_info_; |
| 174 BreakLocatorType type_; | 160 BreakLocatorType type_; |
| 175 RelocIterator reloc_iterator_; | 161 RelocIterator reloc_iterator_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 187 | 173 |
| 188 static int BreakIndexFromAddress(Handle<DebugInfo> debug_info, | 174 static int BreakIndexFromAddress(Handle<DebugInfo> debug_info, |
| 189 BreakLocatorType type, Address pc); | 175 BreakLocatorType type, Address pc); |
| 190 | 176 |
| 191 void ClearDebugBreak(); | 177 void ClearDebugBreak(); |
| 192 void RestoreFromOriginal(int length_in_bytes); | 178 void RestoreFromOriginal(int length_in_bytes); |
| 193 | 179 |
| 194 void SetDebugBreak(); | 180 void SetDebugBreak(); |
| 195 void SetDebugBreakAtReturn(); | 181 void SetDebugBreakAtReturn(); |
| 196 void SetDebugBreakAtSlot(); | 182 void SetDebugBreakAtSlot(); |
| 197 void SetDebugBreakAtIC(); | |
| 198 | 183 |
| 199 inline bool IsDebuggerStatement() const { | 184 inline bool IsDebuggerStatement() const { |
| 200 return RelocInfo::IsDebuggerStatement(rmode_); | 185 return RelocInfo::IsDebuggerStatement(rmode_); |
| 201 } | 186 } |
| 202 inline bool IsDebugBreakSlot() const { | 187 inline bool IsDebugBreakSlot() const { |
| 203 return RelocInfo::IsDebugBreakSlot(rmode_); | 188 return RelocInfo::IsDebugBreakSlot(rmode_); |
| 204 } | 189 } |
| 205 | 190 |
| 206 Handle<DebugInfo> debug_info_; | 191 Handle<DebugInfo> debug_info_; |
| 207 int pc_offset_; | 192 int pc_offset_; |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 Debug* debug_; | 785 Debug* debug_; |
| 801 bool old_state_; | 786 bool old_state_; |
| 802 DISALLOW_COPY_AND_ASSIGN(SuppressDebug); | 787 DISALLOW_COPY_AND_ASSIGN(SuppressDebug); |
| 803 }; | 788 }; |
| 804 | 789 |
| 805 | 790 |
| 806 // Code generator routines. | 791 // Code generator routines. |
| 807 class DebugCodegen : public AllStatic { | 792 class DebugCodegen : public AllStatic { |
| 808 public: | 793 public: |
| 809 static void GenerateSlot(MacroAssembler* masm); | 794 static void GenerateSlot(MacroAssembler* masm); |
| 810 static void GenerateCallICStubDebugBreak(MacroAssembler* masm); | |
| 811 static void GenerateLoadICDebugBreak(MacroAssembler* masm); | |
| 812 static void GenerateStoreICDebugBreak(MacroAssembler* masm); | |
| 813 static void GenerateKeyedLoadICDebugBreak(MacroAssembler* masm); | |
| 814 static void GenerateKeyedStoreICDebugBreak(MacroAssembler* masm); | |
| 815 static void GenerateCompareNilICDebugBreak(MacroAssembler* masm); | |
| 816 static void GenerateReturnDebugBreak(MacroAssembler* masm); | 795 static void GenerateReturnDebugBreak(MacroAssembler* masm); |
| 817 static void GenerateCallFunctionStubDebugBreak(MacroAssembler* masm); | |
| 818 static void GenerateCallConstructStubDebugBreak(MacroAssembler* masm); | |
| 819 static void GenerateCallConstructStubRecordDebugBreak(MacroAssembler* masm); | |
| 820 static void GenerateSlotDebugBreak(MacroAssembler* masm); | 796 static void GenerateSlotDebugBreak(MacroAssembler* masm); |
| 821 static void GeneratePlainReturnLiveEdit(MacroAssembler* masm); | 797 static void GeneratePlainReturnLiveEdit(MacroAssembler* masm); |
| 822 | 798 |
| 823 // FrameDropper is a code replacement for a JavaScript frame with possibly | 799 // FrameDropper is a code replacement for a JavaScript frame with possibly |
| 824 // several frames above. | 800 // several frames above. |
| 825 // There is no calling conventions here, because it never actually gets | 801 // There is no calling conventions here, because it never actually gets |
| 826 // called, it only gets returned to. | 802 // called, it only gets returned to. |
| 827 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); | 803 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); |
| 828 }; | 804 }; |
| 829 | 805 |
| 830 | 806 |
| 831 } } // namespace v8::internal | 807 } } // namespace v8::internal |
| 832 | 808 |
| 833 #endif // V8_DEBUG_H_ | 809 #endif // V8_DEBUG_H_ |
| OLD | NEW |