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

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

Issue 2069823003: [wasm] Enable wasm frame inspection for debugging (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@split-wasm-debug
Patch Set: Add two DCHECKs Created 4 years, 6 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-scopes.h ('k') | src/debug/mirrors.js » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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-scopes.h" 5 #include "src/debug/debug-scopes.h"
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/frames-inl.h" 10 #include "src/frames-inl.h"
11 #include "src/globals.h" 11 #include "src/globals.h"
12 #include "src/isolate-inl.h" 12 #include "src/isolate-inl.h"
13 #include "src/parsing/parser.h" 13 #include "src/parsing/parser.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, 18 ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector,
19 ScopeIterator::Option option) 19 ScopeIterator::Option option)
20 : isolate_(isolate), 20 : isolate_(isolate),
21 frame_inspector_(frame_inspector), 21 frame_inspector_(frame_inspector),
22 nested_scope_chain_(4), 22 nested_scope_chain_(4),
23 seen_script_scope_(false), 23 seen_script_scope_(false),
24 failed_(false) { 24 failed_(false) {
25 if (!frame_inspector->GetContext()->IsContext() || 25 if (!frame_inspector->GetContext()->IsContext()) {
26 !frame_inspector->GetFunction()->IsJSFunction()) {
27 // Optimized frame, context or function cannot be materialized. Give up. 26 // Optimized frame, context or function cannot be materialized. Give up.
28 return; 27 return;
29 } 28 }
30 29
31 context_ = Handle<Context>::cast(frame_inspector->GetContext()); 30 context_ = Handle<Context>::cast(frame_inspector->GetContext());
32 31
32 // We should not instantiate a ScopeIterator for wasm frames.
33 DCHECK(frame_inspector->GetScript()->type() != Script::TYPE_WASM);
34
33 // Catch the case when the debugger stops in an internal function. 35 // Catch the case when the debugger stops in an internal function.
34 Handle<JSFunction> function = GetFunction(); 36 Handle<JSFunction> function = GetFunction();
35 Handle<SharedFunctionInfo> shared_info(function->shared()); 37 Handle<SharedFunctionInfo> shared_info(function->shared());
36 Handle<ScopeInfo> scope_info(shared_info->scope_info()); 38 Handle<ScopeInfo> scope_info(shared_info->scope_info());
37 if (shared_info->script()->IsUndefined(isolate)) { 39 if (shared_info->script()->IsUndefined(isolate)) {
38 while (context_->closure() == *function) { 40 while (context_->closure() == *function) {
39 context_ = Handle<Context>(context_->previous(), isolate_); 41 context_ = Handle<Context>(context_->previous(), isolate_);
40 } 42 }
41 return; 43 return;
42 } 44 }
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 for (int i = 0; i < scope_info->ParameterCount(); ++i) { 609 for (int i = 0; i < scope_info->ParameterCount(); ++i) {
608 if (String::Equals(handle(scope_info->ParameterName(i)), parameter_name)) { 610 if (String::Equals(handle(scope_info->ParameterName(i)), parameter_name)) {
609 frame->SetParameterValue(i, *new_value); 611 frame->SetParameterValue(i, *new_value);
610 return true; 612 return true;
611 } 613 }
612 } 614 }
613 return false; 615 return false;
614 } 616 }
615 617
616 bool ScopeIterator::SetStackVariableValue(Handle<ScopeInfo> scope_info, 618 bool ScopeIterator::SetStackVariableValue(Handle<ScopeInfo> scope_info,
617 JavaScriptFrame* frame,
618 Handle<String> variable_name, 619 Handle<String> variable_name,
619 Handle<Object> new_value) { 620 Handle<Object> new_value) {
621 JavaScriptFrame* frame = GetFrame();
620 // Setting stack locals of optimized frames is not supported. 622 // Setting stack locals of optimized frames is not supported.
621 if (frame->is_optimized()) return false; 623 if (frame->is_optimized()) return false;
622 HandleScope scope(isolate_); 624 HandleScope scope(isolate_);
623 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { 625 for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
624 if (String::Equals(handle(scope_info->StackLocalName(i)), variable_name)) { 626 if (String::Equals(handle(scope_info->StackLocalName(i)), variable_name)) {
625 frame->SetExpression(scope_info->StackLocalIndex(i), *new_value); 627 frame->SetExpression(scope_info->StackLocalIndex(i), *new_value);
626 return true; 628 return true;
627 } 629 }
628 } 630 }
629 return false; 631 return false;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 667
666 bool ScopeIterator::SetLocalVariableValue(Handle<String> variable_name, 668 bool ScopeIterator::SetLocalVariableValue(Handle<String> variable_name,
667 Handle<Object> new_value) { 669 Handle<Object> new_value) {
668 JavaScriptFrame* frame = GetFrame(); 670 JavaScriptFrame* frame = GetFrame();
669 Handle<ScopeInfo> scope_info(frame->function()->shared()->scope_info()); 671 Handle<ScopeInfo> scope_info(frame->function()->shared()->scope_info());
670 672
671 // Parameter might be shadowed in context. Don't stop here. 673 // Parameter might be shadowed in context. Don't stop here.
672 bool result = SetParameterValue(scope_info, frame, variable_name, new_value); 674 bool result = SetParameterValue(scope_info, frame, variable_name, new_value);
673 675
674 // Stack locals. 676 // Stack locals.
675 if (SetStackVariableValue(scope_info, frame, variable_name, new_value)) { 677 if (SetStackVariableValue(scope_info, variable_name, new_value)) {
676 return true; 678 return true;
677 } 679 }
678 680
679 if (scope_info->HasContext() && 681 if (scope_info->HasContext() &&
680 SetContextVariableValue(scope_info, CurrentContext(), variable_name, 682 SetContextVariableValue(scope_info, CurrentContext(), variable_name,
681 new_value)) { 683 new_value)) {
682 return true; 684 return true;
683 } 685 }
684 686
685 return result; 687 return result;
686 } 688 }
687 689
688 bool ScopeIterator::SetInnerScopeVariableValue(Handle<String> variable_name, 690 bool ScopeIterator::SetInnerScopeVariableValue(Handle<String> variable_name,
689 Handle<Object> new_value) { 691 Handle<Object> new_value) {
690 Handle<ScopeInfo> scope_info = CurrentScopeInfo(); 692 Handle<ScopeInfo> scope_info = CurrentScopeInfo();
691 DCHECK(scope_info->scope_type() == BLOCK_SCOPE || 693 DCHECK(scope_info->scope_type() == BLOCK_SCOPE ||
692 scope_info->scope_type() == EVAL_SCOPE); 694 scope_info->scope_type() == EVAL_SCOPE);
693 JavaScriptFrame* frame = GetFrame();
694 695
695 // Setting stack locals of optimized frames is not supported. 696 // Setting stack locals of optimized frames is not supported.
696 if (SetStackVariableValue(scope_info, frame, variable_name, new_value)) { 697 if (SetStackVariableValue(scope_info, variable_name, new_value)) {
697 return true; 698 return true;
698 } 699 }
699 700
700 if (HasContext() && SetContextVariableValue(scope_info, CurrentContext(), 701 if (HasContext() && SetContextVariableValue(scope_info, CurrentContext(),
701 variable_name, new_value)) { 702 variable_name, new_value)) {
702 return true; 703 return true;
703 } 704 }
704 705
705 return false; 706 return false;
706 } 707 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); 803 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden());
803 if (beg_pos <= position && position < end_pos) { 804 if (beg_pos <= position && position < end_pos) {
804 GetNestedScopeChain(isolate, inner_scope, position); 805 GetNestedScopeChain(isolate, inner_scope, position);
805 return; 806 return;
806 } 807 }
807 } 808 }
808 } 809 }
809 810
810 } // namespace internal 811 } // namespace internal
811 } // namespace v8 812 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug-scopes.h ('k') | src/debug/mirrors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698