| 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 "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| 11 #include "src/codegen.h" | 11 #include "src/codegen.h" |
| 12 #include "src/compilation-cache.h" | 12 #include "src/compilation-cache.h" |
| 13 #include "src/compiler.h" | 13 #include "src/compiler.h" |
| 14 #include "src/deoptimizer.h" | 14 #include "src/deoptimizer.h" |
| 15 #include "src/execution.h" | 15 #include "src/execution.h" |
| 16 #include "src/frames-inl.h" | 16 #include "src/frames-inl.h" |
| 17 #include "src/full-codegen/full-codegen.h" | 17 #include "src/full-codegen/full-codegen.h" |
| 18 #include "src/global-handles.h" | 18 #include "src/global-handles.h" |
| 19 #include "src/interpreter/bytecodes.h" |
| 19 #include "src/interpreter/interpreter.h" | 20 #include "src/interpreter/interpreter.h" |
| 20 #include "src/isolate-inl.h" | 21 #include "src/isolate-inl.h" |
| 21 #include "src/list.h" | 22 #include "src/list.h" |
| 22 #include "src/log.h" | 23 #include "src/log.h" |
| 23 #include "src/messages.h" | 24 #include "src/messages.h" |
| 24 #include "src/snapshot/natives.h" | 25 #include "src/snapshot/natives.h" |
| 25 | 26 |
| 26 #include "include/v8-debug.h" | 27 #include "include/v8-debug.h" |
| 27 | 28 |
| 28 namespace v8 { | 29 namespace v8 { |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 // Threading support. | 467 // Threading support. |
| 467 void Debug::ThreadInit() { | 468 void Debug::ThreadInit() { |
| 468 thread_local_.break_count_ = 0; | 469 thread_local_.break_count_ = 0; |
| 469 thread_local_.break_id_ = 0; | 470 thread_local_.break_id_ = 0; |
| 470 thread_local_.break_frame_id_ = StackFrame::NO_ID; | 471 thread_local_.break_frame_id_ = StackFrame::NO_ID; |
| 471 thread_local_.last_step_action_ = StepNone; | 472 thread_local_.last_step_action_ = StepNone; |
| 472 thread_local_.last_statement_position_ = RelocInfo::kNoPosition; | 473 thread_local_.last_statement_position_ = RelocInfo::kNoPosition; |
| 473 thread_local_.last_fp_ = 0; | 474 thread_local_.last_fp_ = 0; |
| 474 thread_local_.target_fp_ = 0; | 475 thread_local_.target_fp_ = 0; |
| 475 thread_local_.step_in_enabled_ = false; | 476 thread_local_.step_in_enabled_ = false; |
| 476 thread_local_.return_value_ = Handle<Object>(); | |
| 477 // TODO(isolates): frames_are_dropped_? | 477 // TODO(isolates): frames_are_dropped_? |
| 478 base::NoBarrier_Store(&thread_local_.current_debug_scope_, | 478 base::NoBarrier_Store(&thread_local_.current_debug_scope_, |
| 479 static_cast<base::AtomicWord>(0)); | 479 static_cast<base::AtomicWord>(0)); |
| 480 } | 480 } |
| 481 | 481 |
| 482 | 482 |
| 483 char* Debug::ArchiveDebug(char* storage) { | 483 char* Debug::ArchiveDebug(char* storage) { |
| 484 char* to = storage; | 484 char* to = storage; |
| 485 MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); | 485 MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); |
| 486 ThreadInit(); | 486 ThreadInit(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 ClearStepping(); | 553 ClearStepping(); |
| 554 | 554 |
| 555 // Return debugger is not loaded. | 555 // Return debugger is not loaded. |
| 556 if (!is_loaded()) return; | 556 if (!is_loaded()) return; |
| 557 | 557 |
| 558 // Clear debugger context global handle. | 558 // Clear debugger context global handle. |
| 559 GlobalHandles::Destroy(Handle<Object>::cast(debug_context_).location()); | 559 GlobalHandles::Destroy(Handle<Object>::cast(debug_context_).location()); |
| 560 debug_context_ = Handle<Context>(); | 560 debug_context_ = Handle<Context>(); |
| 561 } | 561 } |
| 562 | 562 |
| 563 void Debug::Break(JavaScriptFrame* frame) { | 563 |
| 564 void Debug::Break(Arguments args, JavaScriptFrame* frame) { |
| 564 HandleScope scope(isolate_); | 565 HandleScope scope(isolate_); |
| 566 DCHECK(args.length() == 0); |
| 565 | 567 |
| 566 // Initialize LiveEdit. | 568 // Initialize LiveEdit. |
| 567 LiveEdit::InitializeThreadLocal(this); | 569 LiveEdit::InitializeThreadLocal(this); |
| 568 | 570 |
| 569 // Just continue if breaks are disabled or debugger cannot be loaded. | 571 // Just continue if breaks are disabled or debugger cannot be loaded. |
| 570 if (break_disabled()) return; | 572 if (break_disabled()) return; |
| 571 | 573 |
| 572 // Enter the debugger. | 574 // Enter the debugger. |
| 573 DebugScope debug_scope(this); | 575 DebugScope debug_scope(this); |
| 574 if (debug_scope.failed()) return; | 576 if (debug_scope.failed()) return; |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1560 return; | 1562 return; |
| 1561 } | 1563 } |
| 1562 // Move to next in list. | 1564 // Move to next in list. |
| 1563 prev = current; | 1565 prev = current; |
| 1564 current = current->next(); | 1566 current = current->next(); |
| 1565 } | 1567 } |
| 1566 | 1568 |
| 1567 UNREACHABLE(); | 1569 UNREACHABLE(); |
| 1568 } | 1570 } |
| 1569 | 1571 |
| 1570 void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) { | 1572 Object* Debug::SetAfterBreakTarget(JavaScriptFrame* frame) { |
| 1571 after_break_target_ = NULL; | 1573 if (frame->is_interpreted()) { |
| 1572 if (!LiveEdit::SetAfterBreakTarget(this)) { | 1574 // Find the handler from the original bytecode array. |
| 1573 // Continue just after the slot. | 1575 InterpretedFrame* interpreted_frame = |
| 1574 after_break_target_ = frame->pc(); | 1576 reinterpret_cast<InterpretedFrame*>(frame); |
| 1577 SharedFunctionInfo* shared = interpreted_frame->function()->shared(); |
| 1578 BytecodeArray* bytecode_array = shared->bytecode_array(); |
| 1579 int bytecode_offset = interpreted_frame->GetBytecodeOffset(); |
| 1580 interpreter::Bytecode bytecode = |
| 1581 interpreter::Bytecodes::FromByte(bytecode_array->get(bytecode_offset)); |
| 1582 return isolate_->interpreter()->GetBytecodeHandler( |
| 1583 bytecode, interpreter::OperandScale::kSingle); |
| 1584 } else { |
| 1585 after_break_target_ = NULL; |
| 1586 if (!LiveEdit::SetAfterBreakTarget(this)) { |
| 1587 // Continue just after the slot. |
| 1588 after_break_target_ = frame->pc(); |
| 1589 } |
| 1590 return isolate_->heap()->undefined_value(); |
| 1575 } | 1591 } |
| 1576 } | 1592 } |
| 1577 | 1593 |
| 1578 | 1594 |
| 1579 bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) { | 1595 bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) { |
| 1580 HandleScope scope(isolate_); | 1596 HandleScope scope(isolate_); |
| 1581 | 1597 |
| 1582 // Get the executing function in which the debug break occurred. | 1598 // Get the executing function in which the debug break occurred. |
| 1583 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 1599 Handle<JSFunction> function(JSFunction::cast(frame->function())); |
| 1584 Handle<SharedFunctionInfo> shared(function->shared()); | 1600 Handle<SharedFunctionInfo> shared(function->shared()); |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2305 DebugScope::DebugScope(Debug* debug) | 2321 DebugScope::DebugScope(Debug* debug) |
| 2306 : debug_(debug), | 2322 : debug_(debug), |
| 2307 prev_(debug->debugger_entry()), | 2323 prev_(debug->debugger_entry()), |
| 2308 save_(debug_->isolate_), | 2324 save_(debug_->isolate_), |
| 2309 no_termination_exceptons_(debug_->isolate_, | 2325 no_termination_exceptons_(debug_->isolate_, |
| 2310 StackGuard::TERMINATE_EXECUTION) { | 2326 StackGuard::TERMINATE_EXECUTION) { |
| 2311 // Link recursive debugger entry. | 2327 // Link recursive debugger entry. |
| 2312 base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_, | 2328 base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_, |
| 2313 reinterpret_cast<base::AtomicWord>(this)); | 2329 reinterpret_cast<base::AtomicWord>(this)); |
| 2314 | 2330 |
| 2315 // Store the previous break id, frame id and return value. | 2331 // Store the previous break id and frame id. |
| 2316 break_id_ = debug_->break_id(); | 2332 break_id_ = debug_->break_id(); |
| 2317 break_frame_id_ = debug_->break_frame_id(); | 2333 break_frame_id_ = debug_->break_frame_id(); |
| 2318 return_value_ = debug_->return_value(); | |
| 2319 | 2334 |
| 2320 // Create the new break info. If there is no JavaScript frames there is no | 2335 // Create the new break info. If there is no JavaScript frames there is no |
| 2321 // break frame id. | 2336 // break frame id. |
| 2322 JavaScriptFrameIterator it(isolate()); | 2337 JavaScriptFrameIterator it(isolate()); |
| 2323 bool has_js_frames = !it.done(); | 2338 bool has_js_frames = !it.done(); |
| 2324 debug_->thread_local_.break_frame_id_ = has_js_frames ? it.frame()->id() | 2339 debug_->thread_local_.break_frame_id_ = has_js_frames ? it.frame()->id() |
| 2325 : StackFrame::NO_ID; | 2340 : StackFrame::NO_ID; |
| 2326 debug_->SetNextBreakId(); | 2341 debug_->SetNextBreakId(); |
| 2327 | 2342 |
| 2328 debug_->UpdateState(); | 2343 debug_->UpdateState(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2346 if (debug_->has_commands()) isolate()->stack_guard()->RequestDebugCommand(); | 2361 if (debug_->has_commands()) isolate()->stack_guard()->RequestDebugCommand(); |
| 2347 } | 2362 } |
| 2348 | 2363 |
| 2349 // Leaving this debugger entry. | 2364 // Leaving this debugger entry. |
| 2350 base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_, | 2365 base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_, |
| 2351 reinterpret_cast<base::AtomicWord>(prev_)); | 2366 reinterpret_cast<base::AtomicWord>(prev_)); |
| 2352 | 2367 |
| 2353 // Restore to the previous break state. | 2368 // Restore to the previous break state. |
| 2354 debug_->thread_local_.break_frame_id_ = break_frame_id_; | 2369 debug_->thread_local_.break_frame_id_ = break_frame_id_; |
| 2355 debug_->thread_local_.break_id_ = break_id_; | 2370 debug_->thread_local_.break_id_ = break_id_; |
| 2356 debug_->thread_local_.return_value_ = return_value_; | |
| 2357 | 2371 |
| 2358 debug_->UpdateState(); | 2372 debug_->UpdateState(); |
| 2359 } | 2373 } |
| 2360 | 2374 |
| 2361 | 2375 |
| 2362 MessageImpl MessageImpl::NewEvent(DebugEvent event, | 2376 MessageImpl MessageImpl::NewEvent(DebugEvent event, |
| 2363 bool running, | 2377 bool running, |
| 2364 Handle<JSObject> exec_state, | 2378 Handle<JSObject> exec_state, |
| 2365 Handle<JSObject> event_data) { | 2379 Handle<JSObject> event_data) { |
| 2366 MessageImpl message(true, event, running, | 2380 MessageImpl message(true, event, running, |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2607 } | 2621 } |
| 2608 | 2622 |
| 2609 | 2623 |
| 2610 void LockingCommandMessageQueue::Clear() { | 2624 void LockingCommandMessageQueue::Clear() { |
| 2611 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2625 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 2612 queue_.Clear(); | 2626 queue_.Clear(); |
| 2613 } | 2627 } |
| 2614 | 2628 |
| 2615 } // namespace internal | 2629 } // namespace internal |
| 2616 } // namespace v8 | 2630 } // namespace v8 |
| OLD | NEW |