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

Side by Side Diff: runtime/vm/debugger.cc

Issue 249533003: Support evaluation of expressions in context of a stack frame (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/debugger_api_impl.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/debugger.h" 5 #include "vm/debugger.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 for (intptr_t i = 0; i < num_variables; i++) { 758 for (intptr_t i = 0; i < num_variables; i++) {
759 intptr_t ignore; 759 intptr_t ignore;
760 VariableAt(i, &var_name, &ignore, &ignore, &value); 760 VariableAt(i, &var_name, &ignore, &ignore, &value);
761 list.SetAt(2 * i, var_name); 761 list.SetAt(2 * i, var_name);
762 list.SetAt((2 * i) + 1, value); 762 list.SetAt((2 * i) + 1, value);
763 } 763 }
764 return list.raw(); 764 return list.raw();
765 } 765 }
766 766
767 767
768 RawObject* ActivationFrame::GetReceiver() {
769 GetDescIndices();
770 intptr_t num_variables = desc_indices_.length();
771 String& var_name = String::Handle();
772 Instance& value = Instance::Handle();
773 for (intptr_t i = 0; i < num_variables; i++) {
774 intptr_t ignore;
775 VariableAt(i, &var_name, &ignore, &ignore, &value);
776 if (var_name.Equals(Symbols::This())) {
777 return value.raw();
778 }
779 }
780 return Object::null();
781 }
782
783
784 RawObject* ActivationFrame::Evaluate(const String& expr) {
785 GetDescIndices();
786 const GrowableObjectArray& param_names =
787 GrowableObjectArray::Handle(GrowableObjectArray::New());
788 const GrowableObjectArray& param_values =
789 GrowableObjectArray::Handle(GrowableObjectArray::New());
790 String& name = String::Handle();
791 Instance& value = Instance::Handle();
792 intptr_t num_variables = desc_indices_.length();
793 for (intptr_t i = 0; i < num_variables; i++) {
794 intptr_t ignore;
795 VariableAt(i, &name, &ignore, &ignore, &value);
796 if (!name.Equals(Symbols::This())) {
797 param_names.Add(name);
798 param_values.Add(value);
799 }
800 }
801
802 if (function().is_static()) {
803 const Class& cls = Class::Handle(function().Owner());
804 return cls.Evaluate(expr,
805 Array::Handle(Array::MakeArray(param_names)),
806 Array::Handle(Array::MakeArray(param_values)));
807 } else {
808 const Object& receiver = Object::Handle(GetReceiver());
809 ASSERT(receiver.IsInstance());
810 if (!receiver.IsInstance()) {
811 return Object::null();
812 }
813 const Instance& inst = Instance::Cast(receiver);
814 return inst.Evaluate(expr,
815 Array::Handle(Array::MakeArray(param_names)),
816 Array::Handle(Array::MakeArray(param_values)));
817 }
818 UNREACHABLE();
819 return Object::null();
820 }
821
822
768 const char* ActivationFrame::ToCString() { 823 const char* ActivationFrame::ToCString() {
769 const String& url = String::Handle(SourceUrl()); 824 const String& url = String::Handle(SourceUrl());
770 intptr_t line = LineNumber(); 825 intptr_t line = LineNumber();
771 const char* func_name = Debugger::QualifiedFunctionName(function()); 826 const char* func_name = Debugger::QualifiedFunctionName(function());
772 return Isolate::Current()->current_zone()-> 827 return Isolate::Current()->current_zone()->
773 PrintToString("[ Frame pc(0x%" Px ") fp(0x%" Px ") sp(0x%" Px ")\n" 828 PrintToString("[ Frame pc(0x%" Px ") fp(0x%" Px ") sp(0x%" Px ")\n"
774 "\tfunction = %s\n" 829 "\tfunction = %s\n"
775 "\turl = %s\n" 830 "\turl = %s\n"
776 "\tline = %" Pd "\n" 831 "\tline = %" Pd "\n"
777 "\tcontext = %s\n" 832 "\tcontext = %s\n"
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 } 2503 }
2449 2504
2450 2505
2451 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 2506 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
2452 ASSERT(bpt->next() == NULL); 2507 ASSERT(bpt->next() == NULL);
2453 bpt->set_next(code_breakpoints_); 2508 bpt->set_next(code_breakpoints_);
2454 code_breakpoints_ = bpt; 2509 code_breakpoints_ = bpt;
2455 } 2510 }
2456 2511
2457 } // namespace dart 2512 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/debugger_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698