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" |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 // Threading support. | 467 // Threading support. |
468 void Debug::ThreadInit() { | 468 void Debug::ThreadInit() { |
469 thread_local_.break_count_ = 0; | 469 thread_local_.break_count_ = 0; |
470 thread_local_.break_id_ = 0; | 470 thread_local_.break_id_ = 0; |
471 thread_local_.break_frame_id_ = StackFrame::NO_ID; | 471 thread_local_.break_frame_id_ = StackFrame::NO_ID; |
472 thread_local_.last_step_action_ = StepNone; | 472 thread_local_.last_step_action_ = StepNone; |
473 thread_local_.last_statement_position_ = RelocInfo::kNoPosition; | 473 thread_local_.last_statement_position_ = RelocInfo::kNoPosition; |
474 thread_local_.last_fp_ = 0; | 474 thread_local_.last_fp_ = 0; |
475 thread_local_.target_fp_ = 0; | 475 thread_local_.target_fp_ = 0; |
476 thread_local_.step_in_enabled_ = false; | 476 thread_local_.step_in_enabled_ = false; |
477 thread_local_.return_value_ = Handle<Object>(); | |
477 // TODO(isolates): frames_are_dropped_? | 478 // TODO(isolates): frames_are_dropped_? |
478 base::NoBarrier_Store(&thread_local_.current_debug_scope_, | 479 base::NoBarrier_Store(&thread_local_.current_debug_scope_, |
479 static_cast<base::AtomicWord>(0)); | 480 static_cast<base::AtomicWord>(0)); |
480 } | 481 } |
481 | 482 |
482 | 483 |
483 char* Debug::ArchiveDebug(char* storage) { | 484 char* Debug::ArchiveDebug(char* storage) { |
484 char* to = storage; | 485 char* to = storage; |
485 MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); | 486 MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); |
486 ThreadInit(); | 487 ThreadInit(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 if (!is_loaded()) return; | 557 if (!is_loaded()) return; |
557 | 558 |
558 // Clear debugger context global handle. | 559 // Clear debugger context global handle. |
559 GlobalHandles::Destroy(Handle<Object>::cast(debug_context_).location()); | 560 GlobalHandles::Destroy(Handle<Object>::cast(debug_context_).location()); |
560 debug_context_ = Handle<Context>(); | 561 debug_context_ = Handle<Context>(); |
561 } | 562 } |
562 | 563 |
563 | 564 |
564 void Debug::Break(Arguments args, JavaScriptFrame* frame) { | 565 void Debug::Break(Arguments args, JavaScriptFrame* frame) { |
565 HandleScope scope(isolate_); | 566 HandleScope scope(isolate_); |
566 DCHECK(args.length() == 0); | 567 DCHECK(args.length() == 1); |
568 | |
569 // args[0] contains the return value (eax/rax/r0/accumulator) if we break | |
570 // on return. | |
571 thread_local_.return_value_ = args.at<Object>(0); | |
Yang
2016/03/22 12:22:57
Please introduce a method to set and retrieve the
| |
567 | 572 |
568 // Initialize LiveEdit. | 573 // Initialize LiveEdit. |
569 LiveEdit::InitializeThreadLocal(this); | 574 LiveEdit::InitializeThreadLocal(this); |
570 | 575 |
571 // Just continue if breaks are disabled or debugger cannot be loaded. | 576 // Just continue if breaks are disabled or debugger cannot be loaded. |
572 if (break_disabled()) return; | 577 if (break_disabled()) return; |
573 | 578 |
574 // Enter the debugger. | 579 // Enter the debugger. |
575 DebugScope debug_scope(this); | 580 DebugScope debug_scope(this); |
576 if (debug_scope.failed()) return; | 581 if (debug_scope.failed()) return; |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1579 int bytecode_offset = interpreted_frame->GetBytecodeOffset(); | 1584 int bytecode_offset = interpreted_frame->GetBytecodeOffset(); |
1580 interpreter::Bytecode bytecode = | 1585 interpreter::Bytecode bytecode = |
1581 interpreter::Bytecodes::FromByte(bytecode_array->get(bytecode_offset)); | 1586 interpreter::Bytecodes::FromByte(bytecode_array->get(bytecode_offset)); |
1582 return isolate_->interpreter()->GetBytecodeHandler(bytecode); | 1587 return isolate_->interpreter()->GetBytecodeHandler(bytecode); |
1583 } else { | 1588 } else { |
1584 after_break_target_ = NULL; | 1589 after_break_target_ = NULL; |
1585 if (!LiveEdit::SetAfterBreakTarget(this)) { | 1590 if (!LiveEdit::SetAfterBreakTarget(this)) { |
1586 // Continue just after the slot. | 1591 // Continue just after the slot. |
1587 after_break_target_ = frame->pc(); | 1592 after_break_target_ = frame->pc(); |
1588 } | 1593 } |
1589 return isolate_->heap()->undefined_value(); | 1594 return *thread_local_.return_value_; |
mythria
2016/03/21 16:24:29
Returns the actual return value to avoid pushing a
Yang
2016/03/22 12:22:58
I forgot about this part. For the interpreter, the
mythria
2016/03/22 15:11:44
Done.
| |
1590 } | 1595 } |
1591 } | 1596 } |
1592 | 1597 |
1593 | 1598 |
1594 bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) { | 1599 bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) { |
1595 HandleScope scope(isolate_); | 1600 HandleScope scope(isolate_); |
1596 | 1601 |
1597 // Get the executing function in which the debug break occurred. | 1602 // Get the executing function in which the debug break occurred. |
1598 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 1603 Handle<JSFunction> function(JSFunction::cast(frame->function())); |
1599 Handle<SharedFunctionInfo> shared(function->shared()); | 1604 Handle<SharedFunctionInfo> shared(function->shared()); |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2320 DebugScope::DebugScope(Debug* debug) | 2325 DebugScope::DebugScope(Debug* debug) |
2321 : debug_(debug), | 2326 : debug_(debug), |
2322 prev_(debug->debugger_entry()), | 2327 prev_(debug->debugger_entry()), |
2323 save_(debug_->isolate_), | 2328 save_(debug_->isolate_), |
2324 no_termination_exceptons_(debug_->isolate_, | 2329 no_termination_exceptons_(debug_->isolate_, |
2325 StackGuard::TERMINATE_EXECUTION) { | 2330 StackGuard::TERMINATE_EXECUTION) { |
2326 // Link recursive debugger entry. | 2331 // Link recursive debugger entry. |
2327 base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_, | 2332 base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_, |
2328 reinterpret_cast<base::AtomicWord>(this)); | 2333 reinterpret_cast<base::AtomicWord>(this)); |
2329 | 2334 |
2330 // Store the previous break id and frame id. | 2335 // Store the previous break id, frame id and return value. |
2331 break_id_ = debug_->break_id(); | 2336 break_id_ = debug_->break_id(); |
2332 break_frame_id_ = debug_->break_frame_id(); | 2337 break_frame_id_ = debug_->break_frame_id(); |
2338 return_value_ = debug_->get_return_value(); | |
2333 | 2339 |
2334 // Create the new break info. If there is no JavaScript frames there is no | 2340 // Create the new break info. If there is no JavaScript frames there is no |
2335 // break frame id. | 2341 // break frame id. |
2336 JavaScriptFrameIterator it(isolate()); | 2342 JavaScriptFrameIterator it(isolate()); |
2337 bool has_js_frames = !it.done(); | 2343 bool has_js_frames = !it.done(); |
2338 debug_->thread_local_.break_frame_id_ = has_js_frames ? it.frame()->id() | 2344 debug_->thread_local_.break_frame_id_ = has_js_frames ? it.frame()->id() |
2339 : StackFrame::NO_ID; | 2345 : StackFrame::NO_ID; |
2340 debug_->SetNextBreakId(); | 2346 debug_->SetNextBreakId(); |
2341 | 2347 |
2342 debug_->UpdateState(); | 2348 debug_->UpdateState(); |
(...skipping 17 matching lines...) Expand all Loading... | |
2360 if (debug_->has_commands()) isolate()->stack_guard()->RequestDebugCommand(); | 2366 if (debug_->has_commands()) isolate()->stack_guard()->RequestDebugCommand(); |
2361 } | 2367 } |
2362 | 2368 |
2363 // Leaving this debugger entry. | 2369 // Leaving this debugger entry. |
2364 base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_, | 2370 base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_, |
2365 reinterpret_cast<base::AtomicWord>(prev_)); | 2371 reinterpret_cast<base::AtomicWord>(prev_)); |
2366 | 2372 |
2367 // Restore to the previous break state. | 2373 // Restore to the previous break state. |
2368 debug_->thread_local_.break_frame_id_ = break_frame_id_; | 2374 debug_->thread_local_.break_frame_id_ = break_frame_id_; |
2369 debug_->thread_local_.break_id_ = break_id_; | 2375 debug_->thread_local_.break_id_ = break_id_; |
2376 debug_->thread_local_.return_value_ = return_value_; | |
2370 | 2377 |
2371 debug_->UpdateState(); | 2378 debug_->UpdateState(); |
2372 } | 2379 } |
2373 | 2380 |
2374 | 2381 |
2375 MessageImpl MessageImpl::NewEvent(DebugEvent event, | 2382 MessageImpl MessageImpl::NewEvent(DebugEvent event, |
2376 bool running, | 2383 bool running, |
2377 Handle<JSObject> exec_state, | 2384 Handle<JSObject> exec_state, |
2378 Handle<JSObject> event_data) { | 2385 Handle<JSObject> event_data) { |
2379 MessageImpl message(true, event, running, | 2386 MessageImpl message(true, event, running, |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2620 } | 2627 } |
2621 | 2628 |
2622 | 2629 |
2623 void LockingCommandMessageQueue::Clear() { | 2630 void LockingCommandMessageQueue::Clear() { |
2624 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2631 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
2625 queue_.Clear(); | 2632 queue_.Clear(); |
2626 } | 2633 } |
2627 | 2634 |
2628 } // namespace internal | 2635 } // namespace internal |
2629 } // namespace v8 | 2636 } // namespace v8 |
OLD | NEW |