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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 static void FromAddressSameStatement(Handle<DebugInfo> debug_info, | 72 static void FromAddressSameStatement(Handle<DebugInfo> debug_info, |
73 BreakLocatorType type, Address pc, | 73 BreakLocatorType type, Address pc, |
74 List<BreakLocation>* result_out); | 74 List<BreakLocation>* result_out); |
75 | 75 |
76 static BreakLocation FromPosition(Handle<DebugInfo> debug_info, | 76 static BreakLocation FromPosition(Handle<DebugInfo> debug_info, |
77 BreakLocatorType type, int position, | 77 BreakLocatorType type, int position, |
78 BreakPositionAlignment alignment); | 78 BreakPositionAlignment alignment); |
79 | 79 |
80 bool IsDebugBreak() const; | 80 bool IsDebugBreak() const; |
81 inline bool IsExit() const { return RelocInfo::IsJSReturn(rmode_); } | 81 |
| 82 inline bool IsReturn() const { |
| 83 return RelocInfo::IsDebugBreakSlotAtReturn(rmode_); |
| 84 } |
82 inline bool IsCall() const { | 85 inline bool IsCall() const { |
83 return RelocInfo::IsDebugBreakSlotAtCall(rmode_); | 86 return RelocInfo::IsDebugBreakSlotAtCall(rmode_); |
84 } | 87 } |
85 inline bool IsConstructCall() const { | 88 inline bool IsConstructCall() const { |
86 return RelocInfo::IsDebugBreakSlotAtConstructCall(rmode_); | 89 return RelocInfo::IsDebugBreakSlotAtConstructCall(rmode_); |
87 } | 90 } |
88 inline int CallArgumentsCount() const { | 91 inline int CallArgumentsCount() const { |
89 DCHECK(IsCall()); | 92 DCHECK(IsCall()); |
90 return RelocInfo::DebugBreakCallArgumentsCount(data_); | 93 return RelocInfo::DebugBreakCallArgumentsCount(data_); |
91 } | 94 } |
(...skipping 13 matching lines...) Expand all Loading... |
105 | 108 |
106 | 109 |
107 inline RelocInfo rinfo() const { | 110 inline RelocInfo rinfo() const { |
108 return RelocInfo(pc(), rmode(), data_, code()); | 111 return RelocInfo(pc(), rmode(), data_, code()); |
109 } | 112 } |
110 | 113 |
111 inline int position() const { return position_; } | 114 inline int position() const { return position_; } |
112 inline int statement_position() const { return statement_position_; } | 115 inline int statement_position() const { return statement_position_; } |
113 | 116 |
114 inline Address pc() const { return code()->entry() + pc_offset_; } | 117 inline Address pc() const { return code()->entry() + pc_offset_; } |
115 inline Address original_pc() const { | |
116 return debug_info_->original_code()->entry() + original_pc_offset_; | |
117 } | |
118 | 118 |
119 inline RelocInfo::Mode rmode() const { return rmode_; } | 119 inline RelocInfo::Mode rmode() const { return rmode_; } |
120 | 120 |
121 inline Code* code() const { return debug_info_->code(); } | 121 inline Code* code() const { return debug_info_->code(); } |
122 | 122 |
123 private: | 123 private: |
124 BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo, | 124 BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo, int position, |
125 RelocInfo* original_rinfo, int position, | |
126 int statement_position); | 125 int statement_position); |
127 | 126 |
128 class Iterator { | 127 class Iterator { |
129 public: | 128 public: |
130 Iterator(Handle<DebugInfo> debug_info, BreakLocatorType type); | 129 Iterator(Handle<DebugInfo> debug_info, BreakLocatorType type); |
131 | 130 |
132 BreakLocation GetBreakLocation() { | 131 BreakLocation GetBreakLocation() { |
133 return BreakLocation(debug_info_, rinfo(), original_rinfo(), position(), | 132 return BreakLocation(debug_info_, rinfo(), position(), |
134 statement_position()); | 133 statement_position()); |
135 } | 134 } |
136 | 135 |
137 inline bool Done() const { return RinfoDone(); } | 136 inline bool Done() const { return reloc_iterator_.done(); } |
138 void Next(); | 137 void Next(); |
139 | 138 |
140 void SkipTo(int count) { | 139 void SkipTo(int count) { |
141 while (count-- > 0) Next(); | 140 while (count-- > 0) Next(); |
142 } | 141 } |
143 | 142 |
144 inline RelocInfo::Mode rmode() { return reloc_iterator_.rinfo()->rmode(); } | 143 inline RelocInfo::Mode rmode() { return reloc_iterator_.rinfo()->rmode(); } |
145 inline RelocInfo* rinfo() { return reloc_iterator_.rinfo(); } | 144 inline RelocInfo* rinfo() { return reloc_iterator_.rinfo(); } |
146 inline RelocInfo* original_rinfo() { | |
147 return reloc_iterator_original_.rinfo(); | |
148 } | |
149 | |
150 inline Address pc() { return rinfo()->pc(); } | 145 inline Address pc() { return rinfo()->pc(); } |
151 int break_index() const { return break_index_; } | 146 int break_index() const { return break_index_; } |
152 inline int position() const { return position_; } | 147 inline int position() const { return position_; } |
153 inline int statement_position() const { return statement_position_; } | 148 inline int statement_position() const { return statement_position_; } |
154 | 149 |
155 private: | 150 private: |
156 static int GetModeMask(BreakLocatorType type); | 151 static int GetModeMask(BreakLocatorType type); |
157 | 152 |
158 bool RinfoDone() const; | |
159 void RinfoNext(); | |
160 | |
161 Handle<DebugInfo> debug_info_; | 153 Handle<DebugInfo> debug_info_; |
162 RelocIterator reloc_iterator_; | 154 RelocIterator reloc_iterator_; |
163 RelocIterator reloc_iterator_original_; | |
164 int break_index_; | 155 int break_index_; |
165 int position_; | 156 int position_; |
166 int statement_position_; | 157 int statement_position_; |
167 | 158 |
168 DisallowHeapAllocation no_gc_; | 159 DisallowHeapAllocation no_gc_; |
169 | 160 |
170 DISALLOW_COPY_AND_ASSIGN(Iterator); | 161 DISALLOW_COPY_AND_ASSIGN(Iterator); |
171 }; | 162 }; |
172 | 163 |
173 friend class Debug; | 164 friend class Debug; |
174 | 165 |
175 static int BreakIndexFromAddress(Handle<DebugInfo> debug_info, | 166 static int BreakIndexFromAddress(Handle<DebugInfo> debug_info, |
176 BreakLocatorType type, Address pc); | 167 BreakLocatorType type, Address pc); |
177 | 168 |
| 169 void SetDebugBreak(); |
178 void ClearDebugBreak(); | 170 void ClearDebugBreak(); |
179 void RestoreFromOriginal(int length_in_bytes); | |
180 | |
181 void SetDebugBreak(); | |
182 void SetDebugBreakAtReturn(); | |
183 void SetDebugBreakAtSlot(); | |
184 | 171 |
185 inline bool IsDebuggerStatement() const { | 172 inline bool IsDebuggerStatement() const { |
186 return RelocInfo::IsDebuggerStatement(rmode_); | 173 return RelocInfo::IsDebuggerStatement(rmode_); |
187 } | 174 } |
188 inline bool IsDebugBreakSlot() const { | 175 inline bool IsDebugBreakSlot() const { |
189 return RelocInfo::IsDebugBreakSlot(rmode_); | 176 return RelocInfo::IsDebugBreakSlot(rmode_); |
190 } | 177 } |
191 | 178 |
192 Handle<DebugInfo> debug_info_; | 179 Handle<DebugInfo> debug_info_; |
193 int pc_offset_; | 180 int pc_offset_; |
194 int original_pc_offset_; | |
195 RelocInfo::Mode rmode_; | 181 RelocInfo::Mode rmode_; |
196 RelocInfo::Mode original_rmode_; | |
197 intptr_t data_; | 182 intptr_t data_; |
198 intptr_t original_data_; | |
199 int position_; | 183 int position_; |
200 int statement_position_; | 184 int statement_position_; |
201 }; | 185 }; |
202 | 186 |
203 | 187 |
204 // Cache of all script objects in the heap. When a script is added a weak handle | 188 // Cache of all script objects in the heap. When a script is added a weak handle |
205 // to it is created and that weak handle is stored in the cache. The weak handle | 189 // to it is created and that weak handle is stored in the cache. The weak handle |
206 // callback takes care of removing the script from the cache. The key used in | 190 // callback takes care of removing the script from the cache. The key used in |
207 // the cache is the script id. | 191 // the cache is the script id. |
208 class ScriptCache { | 192 class ScriptCache { |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 private: | 769 private: |
786 Debug* debug_; | 770 Debug* debug_; |
787 bool old_state_; | 771 bool old_state_; |
788 DISALLOW_COPY_AND_ASSIGN(SuppressDebug); | 772 DISALLOW_COPY_AND_ASSIGN(SuppressDebug); |
789 }; | 773 }; |
790 | 774 |
791 | 775 |
792 // Code generator routines. | 776 // Code generator routines. |
793 class DebugCodegen : public AllStatic { | 777 class DebugCodegen : public AllStatic { |
794 public: | 778 public: |
795 enum SlotLocation { | 779 enum DebugBreakCallHelperMode { |
796 PLAIN_DEBUG_BREAK, | 780 SAVE_RESULT_REGISTER, |
797 DEBUG_BREAK_AT_CALL, | 781 IGNORE_RESULT_REGISTER |
798 DEBUG_BREAK_AT_CONSTRUCT_CALL | |
799 }; | 782 }; |
800 | 783 |
801 static void GenerateSlot(MacroAssembler* masm, SlotLocation location, | 784 static void GenerateDebugBreakStub(MacroAssembler* masm, |
802 int call_argc = -1); | 785 DebugBreakCallHelperMode mode); |
803 static void GenerateReturnDebugBreak(MacroAssembler* masm); | 786 |
804 static void GenerateSlotDebugBreak(MacroAssembler* masm); | |
805 static void GeneratePlainReturnLiveEdit(MacroAssembler* masm); | 787 static void GeneratePlainReturnLiveEdit(MacroAssembler* masm); |
806 | 788 |
807 // FrameDropper is a code replacement for a JavaScript frame with possibly | 789 // FrameDropper is a code replacement for a JavaScript frame with possibly |
808 // several frames above. | 790 // several frames above. |
809 // There is no calling conventions here, because it never actually gets | 791 // There is no calling conventions here, because it never actually gets |
810 // called, it only gets returned to. | 792 // called, it only gets returned to. |
811 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); | 793 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); |
812 | 794 |
813 private: | 795 |
814 static void RecordRelocInfo(MacroAssembler* masm, SlotLocation location, | 796 static void GenerateSlot(MacroAssembler* masm, RelocInfo::Mode mode, |
815 int call_argc); | 797 int call_argc = -1); |
| 798 |
| 799 static void PatchDebugBreakSlot(Address pc, Handle<Code> code); |
| 800 static void ClearDebugBreakSlot(Address pc); |
816 }; | 801 }; |
817 | 802 |
818 | 803 |
819 } } // namespace v8::internal | 804 } } // namespace v8::internal |
820 | 805 |
821 #endif // V8_DEBUG_H_ | 806 #endif // V8_DEBUG_H_ |
OLD | NEW |