Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: src/debug/debug.cc

Issue 1818873003: [Interpreter] Adds support to fetch return value on break at return. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Port to ppc,mips,mips64,x87,s390 Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/ia32/debug-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
20 #include "src/interpreter/interpreter.h" 19 #include "src/interpreter/interpreter.h"
21 #include "src/isolate-inl.h" 20 #include "src/isolate-inl.h"
22 #include "src/list.h" 21 #include "src/list.h"
23 #include "src/log.h" 22 #include "src/log.h"
24 #include "src/messages.h" 23 #include "src/messages.h"
25 #include "src/snapshot/natives.h" 24 #include "src/snapshot/natives.h"
26 25
27 #include "include/v8-debug.h" 26 #include "include/v8-debug.h"
28 27
29 namespace v8 { 28 namespace v8 {
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 // Threading support. 466 // Threading support.
468 void Debug::ThreadInit() { 467 void Debug::ThreadInit() {
469 thread_local_.break_count_ = 0; 468 thread_local_.break_count_ = 0;
470 thread_local_.break_id_ = 0; 469 thread_local_.break_id_ = 0;
471 thread_local_.break_frame_id_ = StackFrame::NO_ID; 470 thread_local_.break_frame_id_ = StackFrame::NO_ID;
472 thread_local_.last_step_action_ = StepNone; 471 thread_local_.last_step_action_ = StepNone;
473 thread_local_.last_statement_position_ = RelocInfo::kNoPosition; 472 thread_local_.last_statement_position_ = RelocInfo::kNoPosition;
474 thread_local_.last_fp_ = 0; 473 thread_local_.last_fp_ = 0;
475 thread_local_.target_fp_ = 0; 474 thread_local_.target_fp_ = 0;
476 thread_local_.step_in_enabled_ = false; 475 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
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 563 void Debug::Break(JavaScriptFrame* frame) {
564 void Debug::Break(Arguments args, JavaScriptFrame* frame) {
565 HandleScope scope(isolate_); 564 HandleScope scope(isolate_);
566 DCHECK(args.length() == 0);
567 565
568 // Initialize LiveEdit. 566 // Initialize LiveEdit.
569 LiveEdit::InitializeThreadLocal(this); 567 LiveEdit::InitializeThreadLocal(this);
570 568
571 // Just continue if breaks are disabled or debugger cannot be loaded. 569 // Just continue if breaks are disabled or debugger cannot be loaded.
572 if (break_disabled()) return; 570 if (break_disabled()) return;
573 571
574 // Enter the debugger. 572 // Enter the debugger.
575 DebugScope debug_scope(this); 573 DebugScope debug_scope(this);
576 if (debug_scope.failed()) return; 574 if (debug_scope.failed()) return;
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 return; 1560 return;
1563 } 1561 }
1564 // Move to next in list. 1562 // Move to next in list.
1565 prev = current; 1563 prev = current;
1566 current = current->next(); 1564 current = current->next();
1567 } 1565 }
1568 1566
1569 UNREACHABLE(); 1567 UNREACHABLE();
1570 } 1568 }
1571 1569
1572 Object* Debug::SetAfterBreakTarget(JavaScriptFrame* frame) { 1570 void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) {
1573 if (frame->is_interpreted()) { 1571 after_break_target_ = NULL;
1574 // Find the handler from the original bytecode array. 1572 if (!LiveEdit::SetAfterBreakTarget(this)) {
1575 InterpretedFrame* interpreted_frame = 1573 // Continue just after the slot.
1576 reinterpret_cast<InterpretedFrame*>(frame); 1574 after_break_target_ = frame->pc();
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();
1591 } 1575 }
1592 } 1576 }
1593 1577
1594 1578
1595 bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) { 1579 bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) {
1596 HandleScope scope(isolate_); 1580 HandleScope scope(isolate_);
1597 1581
1598 // Get the executing function in which the debug break occurred. 1582 // Get the executing function in which the debug break occurred.
1599 Handle<JSFunction> function(JSFunction::cast(frame->function())); 1583 Handle<JSFunction> function(JSFunction::cast(frame->function()));
1600 Handle<SharedFunctionInfo> shared(function->shared()); 1584 Handle<SharedFunctionInfo> shared(function->shared());
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 DebugScope::DebugScope(Debug* debug) 2305 DebugScope::DebugScope(Debug* debug)
2322 : debug_(debug), 2306 : debug_(debug),
2323 prev_(debug->debugger_entry()), 2307 prev_(debug->debugger_entry()),
2324 save_(debug_->isolate_), 2308 save_(debug_->isolate_),
2325 no_termination_exceptons_(debug_->isolate_, 2309 no_termination_exceptons_(debug_->isolate_,
2326 StackGuard::TERMINATE_EXECUTION) { 2310 StackGuard::TERMINATE_EXECUTION) {
2327 // Link recursive debugger entry. 2311 // Link recursive debugger entry.
2328 base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_, 2312 base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_,
2329 reinterpret_cast<base::AtomicWord>(this)); 2313 reinterpret_cast<base::AtomicWord>(this));
2330 2314
2331 // Store the previous break id and frame id. 2315 // Store the previous break id, frame id and return value.
2332 break_id_ = debug_->break_id(); 2316 break_id_ = debug_->break_id();
2333 break_frame_id_ = debug_->break_frame_id(); 2317 break_frame_id_ = debug_->break_frame_id();
2318 return_value_ = debug_->return_value();
2334 2319
2335 // Create the new break info. If there is no JavaScript frames there is no 2320 // Create the new break info. If there is no JavaScript frames there is no
2336 // break frame id. 2321 // break frame id.
2337 JavaScriptFrameIterator it(isolate()); 2322 JavaScriptFrameIterator it(isolate());
2338 bool has_js_frames = !it.done(); 2323 bool has_js_frames = !it.done();
2339 debug_->thread_local_.break_frame_id_ = has_js_frames ? it.frame()->id() 2324 debug_->thread_local_.break_frame_id_ = has_js_frames ? it.frame()->id()
2340 : StackFrame::NO_ID; 2325 : StackFrame::NO_ID;
2341 debug_->SetNextBreakId(); 2326 debug_->SetNextBreakId();
2342 2327
2343 debug_->UpdateState(); 2328 debug_->UpdateState();
(...skipping 17 matching lines...) Expand all
2361 if (debug_->has_commands()) isolate()->stack_guard()->RequestDebugCommand(); 2346 if (debug_->has_commands()) isolate()->stack_guard()->RequestDebugCommand();
2362 } 2347 }
2363 2348
2364 // Leaving this debugger entry. 2349 // Leaving this debugger entry.
2365 base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_, 2350 base::NoBarrier_Store(&debug_->thread_local_.current_debug_scope_,
2366 reinterpret_cast<base::AtomicWord>(prev_)); 2351 reinterpret_cast<base::AtomicWord>(prev_));
2367 2352
2368 // Restore to the previous break state. 2353 // Restore to the previous break state.
2369 debug_->thread_local_.break_frame_id_ = break_frame_id_; 2354 debug_->thread_local_.break_frame_id_ = break_frame_id_;
2370 debug_->thread_local_.break_id_ = break_id_; 2355 debug_->thread_local_.break_id_ = break_id_;
2356 debug_->thread_local_.return_value_ = return_value_;
2371 2357
2372 debug_->UpdateState(); 2358 debug_->UpdateState();
2373 } 2359 }
2374 2360
2375 2361
2376 MessageImpl MessageImpl::NewEvent(DebugEvent event, 2362 MessageImpl MessageImpl::NewEvent(DebugEvent event,
2377 bool running, 2363 bool running,
2378 Handle<JSObject> exec_state, 2364 Handle<JSObject> exec_state,
2379 Handle<JSObject> event_data) { 2365 Handle<JSObject> event_data) {
2380 MessageImpl message(true, event, running, 2366 MessageImpl message(true, event, running,
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2621 } 2607 }
2622 2608
2623 2609
2624 void LockingCommandMessageQueue::Clear() { 2610 void LockingCommandMessageQueue::Clear() {
2625 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2611 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2626 queue_.Clear(); 2612 queue_.Clear();
2627 } 2613 }
2628 2614
2629 } // namespace internal 2615 } // namespace internal
2630 } // namespace v8 2616 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/ia32/debug-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698