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 #include "src/debug/debug.h" | 5 #include "src/debug/debug.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 DCHECK(!Done()); | 179 DCHECK(!Done()); |
180 Next(); | 180 Next(); |
181 } | 181 } |
182 | 182 |
183 int CodeBreakIterator::GetModeMask() { | 183 int CodeBreakIterator::GetModeMask() { |
184 int mask = 0; | 184 int mask = 0; |
185 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_RETURN); | 185 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_RETURN); |
186 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_CALL); | 186 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_CALL); |
187 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_TAIL_CALL); | 187 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_TAIL_CALL); |
188 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); | 188 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); |
| 189 mask |= RelocInfo::ModeMask(RelocInfo::DEBUGGER_STATEMENT); |
189 return mask; | 190 return mask; |
190 } | 191 } |
191 | 192 |
192 void CodeBreakIterator::Next() { | 193 void CodeBreakIterator::Next() { |
193 DisallowHeapAllocation no_gc; | 194 DisallowHeapAllocation no_gc; |
194 DCHECK(!Done()); | 195 DCHECK(!Done()); |
195 | 196 |
196 // Iterate through reloc info stopping at each breakable code target. | 197 // Iterate through reloc info stopping at each breakable code target. |
197 bool first = break_index_ == -1; | 198 bool first = break_index_ == -1; |
198 | 199 |
199 if (!first) reloc_iterator_.next(); | 200 if (!first) reloc_iterator_.next(); |
200 first = false; | 201 first = false; |
201 if (Done()) return; | 202 if (Done()) return; |
202 | 203 |
203 int offset = code_offset(); | 204 int offset = code_offset(); |
204 while (!source_position_iterator_.done() && | 205 while (!source_position_iterator_.done() && |
205 source_position_iterator_.code_offset() <= offset) { | 206 source_position_iterator_.code_offset() <= offset) { |
206 position_ = source_position_iterator_.source_position().ScriptOffset(); | 207 position_ = source_position_iterator_.source_position().ScriptOffset(); |
207 if (source_position_iterator_.is_statement()) { | 208 if (source_position_iterator_.is_statement()) { |
208 statement_position_ = position_; | 209 statement_position_ = position_; |
209 } | 210 } |
210 source_position_iterator_.Advance(); | 211 source_position_iterator_.Advance(); |
211 } | 212 } |
212 | 213 |
213 DCHECK(RelocInfo::IsDebugBreakSlot(rmode())); | 214 DCHECK(RelocInfo::IsDebugBreakSlot(rmode()) || |
| 215 RelocInfo::IsDebuggerStatement(rmode())); |
214 break_index_++; | 216 break_index_++; |
215 } | 217 } |
216 | 218 |
217 DebugBreakType CodeBreakIterator::GetDebugBreakType() { | 219 DebugBreakType CodeBreakIterator::GetDebugBreakType() { |
218 if (RelocInfo::IsDebugBreakSlotAtReturn(rmode())) { | 220 if (RelocInfo::IsDebugBreakSlotAtReturn(rmode())) { |
219 return DEBUG_BREAK_SLOT_AT_RETURN; | 221 return DEBUG_BREAK_SLOT_AT_RETURN; |
220 } else if (RelocInfo::IsDebugBreakSlotAtCall(rmode())) { | 222 } else if (RelocInfo::IsDebugBreakSlotAtCall(rmode())) { |
221 return DEBUG_BREAK_SLOT_AT_CALL; | 223 return DEBUG_BREAK_SLOT_AT_CALL; |
222 } else if (RelocInfo::IsDebugBreakSlotAtTailCall(rmode())) { | 224 } else if (RelocInfo::IsDebugBreakSlotAtTailCall(rmode())) { |
223 return isolate()->is_tail_call_elimination_enabled() | 225 return isolate()->is_tail_call_elimination_enabled() |
224 ? DEBUG_BREAK_SLOT_AT_TAIL_CALL | 226 ? DEBUG_BREAK_SLOT_AT_TAIL_CALL |
225 : DEBUG_BREAK_SLOT_AT_CALL; | 227 : DEBUG_BREAK_SLOT_AT_CALL; |
| 228 } else if (RelocInfo::IsDebuggerStatement(rmode())) { |
| 229 return DEBUGGER_STATEMENT; |
226 } else if (RelocInfo::IsDebugBreakSlot(rmode())) { | 230 } else if (RelocInfo::IsDebugBreakSlot(rmode())) { |
227 return DEBUG_BREAK_SLOT; | 231 return DEBUG_BREAK_SLOT; |
228 } else { | 232 } else { |
229 return NOT_DEBUG_BREAK; | 233 return NOT_DEBUG_BREAK; |
230 } | 234 } |
231 } | 235 } |
232 | 236 |
233 void CodeBreakIterator::SkipToPosition(int position, | 237 void CodeBreakIterator::SkipToPosition(int position, |
234 BreakPositionAlignment alignment) { | 238 BreakPositionAlignment alignment) { |
235 CodeBreakIterator it(debug_info_); | 239 CodeBreakIterator it(debug_info_); |
236 SkipTo(it.BreakIndexFromPosition(position, alignment)); | 240 SkipTo(it.BreakIndexFromPosition(position, alignment)); |
237 } | 241 } |
238 | 242 |
239 void CodeBreakIterator::SetDebugBreak() { | 243 void CodeBreakIterator::SetDebugBreak() { |
240 DebugBreakType debug_break_type = GetDebugBreakType(); | 244 DebugBreakType debug_break_type = GetDebugBreakType(); |
| 245 if (debug_break_type == DEBUGGER_STATEMENT) return; |
241 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); | 246 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); |
242 Builtins* builtins = isolate()->builtins(); | 247 Builtins* builtins = isolate()->builtins(); |
243 Handle<Code> target = debug_break_type == DEBUG_BREAK_SLOT_AT_RETURN | 248 Handle<Code> target = debug_break_type == DEBUG_BREAK_SLOT_AT_RETURN |
244 ? builtins->Return_DebugBreak() | 249 ? builtins->Return_DebugBreak() |
245 : builtins->Slot_DebugBreak(); | 250 : builtins->Slot_DebugBreak(); |
246 DebugCodegen::PatchDebugBreakSlot(isolate(), rinfo()->pc(), target); | 251 DebugCodegen::PatchDebugBreakSlot(isolate(), rinfo()->pc(), target); |
247 } | 252 } |
248 | 253 |
249 void CodeBreakIterator::ClearDebugBreak() { | 254 void CodeBreakIterator::ClearDebugBreak() { |
250 DCHECK(GetDebugBreakType() >= DEBUG_BREAK_SLOT); | 255 DebugBreakType debug_break_type = GetDebugBreakType(); |
| 256 if (debug_break_type == DEBUGGER_STATEMENT) return; |
| 257 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); |
251 DebugCodegen::ClearDebugBreakSlot(isolate(), rinfo()->pc()); | 258 DebugCodegen::ClearDebugBreakSlot(isolate(), rinfo()->pc()); |
252 } | 259 } |
253 | 260 |
254 bool CodeBreakIterator::IsDebugBreak() { | 261 bool CodeBreakIterator::IsDebugBreak() { |
255 DCHECK(GetDebugBreakType() >= DEBUG_BREAK_SLOT); | 262 DebugBreakType debug_break_type = GetDebugBreakType(); |
| 263 if (debug_break_type == DEBUGGER_STATEMENT) return false; |
| 264 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); |
256 return DebugCodegen::DebugBreakSlotIsPatched(rinfo()->pc()); | 265 return DebugCodegen::DebugBreakSlotIsPatched(rinfo()->pc()); |
257 } | 266 } |
258 | 267 |
259 BreakLocation CodeBreakIterator::GetBreakLocation() { | 268 BreakLocation CodeBreakIterator::GetBreakLocation() { |
260 Handle<AbstractCode> code(AbstractCode::cast(debug_info_->DebugCode())); | 269 Handle<AbstractCode> code(AbstractCode::cast(debug_info_->DebugCode())); |
261 return BreakLocation(code, GetDebugBreakType(), code_offset(), position_); | 270 return BreakLocation(code, GetDebugBreakType(), code_offset(), position_); |
262 } | 271 } |
263 | 272 |
264 BytecodeArrayBreakIterator::BytecodeArrayBreakIterator( | 273 BytecodeArrayBreakIterator::BytecodeArrayBreakIterator( |
265 Handle<DebugInfo> debug_info) | 274 Handle<DebugInfo> debug_info) |
(...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2411 return v8::Utils::ToLocal(callback_data_); | 2420 return v8::Utils::ToLocal(callback_data_); |
2412 } | 2421 } |
2413 | 2422 |
2414 | 2423 |
2415 v8::Isolate* EventDetailsImpl::GetIsolate() const { | 2424 v8::Isolate* EventDetailsImpl::GetIsolate() const { |
2416 return reinterpret_cast<v8::Isolate*>(exec_state_->GetIsolate()); | 2425 return reinterpret_cast<v8::Isolate*>(exec_state_->GetIsolate()); |
2417 } | 2426 } |
2418 | 2427 |
2419 } // namespace internal | 2428 } // namespace internal |
2420 } // namespace v8 | 2429 } // namespace v8 |
OLD | NEW |