| OLD | NEW |
| 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 return Context::ZoneHandle(Context::null()); | 702 return Context::ZoneHandle(Context::null()); |
| 703 } | 703 } |
| 704 | 704 |
| 705 | 705 |
| 706 RawObject* ActivationFrame::GetAsyncOperation() { | 706 RawObject* ActivationFrame::GetAsyncOperation() { |
| 707 GetVarDescriptors(); | 707 GetVarDescriptors(); |
| 708 intptr_t var_desc_len = var_descriptors_.Length(); | 708 intptr_t var_desc_len = var_descriptors_.Length(); |
| 709 for (intptr_t i = 0; i < var_desc_len; i++) { | 709 for (intptr_t i = 0; i < var_desc_len; i++) { |
| 710 RawLocalVarDescriptors::VarInfo var_info; | 710 RawLocalVarDescriptors::VarInfo var_info; |
| 711 var_descriptors_.GetInfo(i, &var_info); | 711 var_descriptors_.GetInfo(i, &var_info); |
| 712 const int8_t kind = var_info.kind(); | 712 if (var_descriptors_.GetName(i) == Symbols::AsyncOperation().raw()) { |
| 713 if (kind == RawLocalVarDescriptors::kAsyncOperation) { | 713 const int8_t kind = var_info.kind(); |
| 714 return GetContextVar(var_info.scope_id, var_info.index()); | 714 if (kind == RawLocalVarDescriptors::kStackVar) { |
| 715 return GetStackVar(var_info.index()); |
| 716 } else { |
| 717 ASSERT(kind == RawLocalVarDescriptors::kContextVar); |
| 718 return GetContextVar(var_info.scope_id, var_info.index()); |
| 719 } |
| 715 } | 720 } |
| 716 } | 721 } |
| 717 return Object::null(); | 722 return Object::null(); |
| 718 } | 723 } |
| 719 | 724 |
| 720 | 725 |
| 721 ActivationFrame* DebuggerStackTrace::GetHandlerFrame( | 726 ActivationFrame* DebuggerStackTrace::GetHandlerFrame( |
| 722 const Instance& exc_obj) const { | 727 const Instance& exc_obj) const { |
| 723 ExceptionHandlers& handlers = ExceptionHandlers::Handle(); | 728 ExceptionHandlers& handlers = ExceptionHandlers::Handle(); |
| 724 Array& handled_types = Array::Handle(); | 729 Array& handled_types = Array::Handle(); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 void ActivationFrame::VariableAt(intptr_t i, | 930 void ActivationFrame::VariableAt(intptr_t i, |
| 926 String* name, | 931 String* name, |
| 927 intptr_t* token_pos, | 932 intptr_t* token_pos, |
| 928 intptr_t* end_pos, | 933 intptr_t* end_pos, |
| 929 Object* value) { | 934 Object* value) { |
| 930 GetDescIndices(); | 935 GetDescIndices(); |
| 931 ASSERT(i < desc_indices_.length()); | 936 ASSERT(i < desc_indices_.length()); |
| 932 intptr_t desc_index = desc_indices_[i]; | 937 intptr_t desc_index = desc_indices_[i]; |
| 933 ASSERT(name != NULL); | 938 ASSERT(name != NULL); |
| 934 | 939 |
| 935 const String& tmp = String::Handle(var_descriptors_.GetName(desc_index)); | 940 *name = var_descriptors_.GetName(desc_index); |
| 936 *name ^= String::IdentifierPrettyName(tmp); | |
| 937 | 941 |
| 938 RawLocalVarDescriptors::VarInfo var_info; | 942 RawLocalVarDescriptors::VarInfo var_info; |
| 939 var_descriptors_.GetInfo(desc_index, &var_info); | 943 var_descriptors_.GetInfo(desc_index, &var_info); |
| 940 ASSERT(token_pos != NULL); | 944 ASSERT(token_pos != NULL); |
| 941 *token_pos = var_info.begin_pos; | 945 *token_pos = var_info.begin_pos; |
| 942 ASSERT(end_pos != NULL); | 946 ASSERT(end_pos != NULL); |
| 943 *end_pos = var_info.end_pos; | 947 *end_pos = var_info.end_pos; |
| 944 ASSERT(value != NULL); | 948 ASSERT(value != NULL); |
| 945 const int8_t kind = var_info.kind(); | 949 const int8_t kind = var_info.kind(); |
| 946 if (kind == RawLocalVarDescriptors::kStackVar) { | 950 if (kind == RawLocalVarDescriptors::kStackVar) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 if (full) { | 1092 if (full) { |
| 1089 // TODO(cutch): The old "full" script usage no longer fits | 1093 // TODO(cutch): The old "full" script usage no longer fits |
| 1090 // in the world where we pass the script as part of the | 1094 // in the world where we pass the script as part of the |
| 1091 // location. | 1095 // location. |
| 1092 jsobj->AddProperty("script", script, !full); | 1096 jsobj->AddProperty("script", script, !full); |
| 1093 } | 1097 } |
| 1094 { | 1098 { |
| 1095 JSONArray jsvars(jsobj, "vars"); | 1099 JSONArray jsvars(jsobj, "vars"); |
| 1096 const int num_vars = NumLocalVariables(); | 1100 const int num_vars = NumLocalVariables(); |
| 1097 for (intptr_t v = 0; v < num_vars; v++) { | 1101 for (intptr_t v = 0; v < num_vars; v++) { |
| 1098 JSONObject jsvar(&jsvars); | |
| 1099 String& var_name = String::Handle(); | 1102 String& var_name = String::Handle(); |
| 1100 Instance& var_value = Instance::Handle(); | 1103 Instance& var_value = Instance::Handle(); |
| 1101 intptr_t token_pos; | 1104 intptr_t token_pos; |
| 1102 intptr_t end_token_pos; | 1105 intptr_t end_token_pos; |
| 1103 VariableAt(v, &var_name, &token_pos, &end_token_pos, &var_value); | 1106 VariableAt(v, &var_name, &token_pos, &end_token_pos, &var_value); |
| 1104 jsvar.AddProperty("name", var_name.ToCString()); | 1107 if (var_name.raw() != Symbols::AsyncOperation().raw()) { |
| 1105 jsvar.AddProperty("value", var_value, !full); | 1108 JSONObject jsvar(&jsvars); |
| 1106 // TODO(turnidge): Do we really want to provide this on every | 1109 jsvar.AddProperty("name", var_name.ToCString()); |
| 1107 // stack dump? Should be associated with the function object, I | 1110 jsvar.AddProperty("value", var_value, !full); |
| 1108 // think, and not the stack frame. | 1111 // TODO(turnidge): Do we really want to provide this on every |
| 1109 jsvar.AddProperty("_tokenPos", token_pos); | 1112 // stack dump? Should be associated with the function object, I |
| 1110 jsvar.AddProperty("_endTokenPos", end_token_pos); | 1113 // think, and not the stack frame. |
| 1114 jsvar.AddProperty("_tokenPos", token_pos); |
| 1115 jsvar.AddProperty("_endTokenPos", end_token_pos); |
| 1116 } |
| 1111 } | 1117 } |
| 1112 } | 1118 } |
| 1113 } | 1119 } |
| 1114 | 1120 |
| 1115 | 1121 |
| 1116 | 1122 |
| 1117 void DebuggerStackTrace::AddActivation(ActivationFrame* frame) { | 1123 void DebuggerStackTrace::AddActivation(ActivationFrame* frame) { |
| 1118 if (FLAG_show_invisible_frames || frame->function().is_visible()) { | 1124 if (FLAG_show_invisible_frames || frame->function().is_visible()) { |
| 1119 trace_.Add(frame); | 1125 trace_.Add(frame); |
| 1120 } | 1126 } |
| (...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2556 if ((bpt != NULL) && bpt->IsSingleShot()) { | 2562 if ((bpt != NULL) && bpt->IsSingleShot()) { |
| 2557 RemoveBreakpoint(bpt->id()); | 2563 RemoveBreakpoint(bpt->id()); |
| 2558 bpt = NULL; | 2564 bpt = NULL; |
| 2559 } | 2565 } |
| 2560 | 2566 |
| 2561 DebuggerEvent event(isolate_, DebuggerEvent::kBreakpointReached); | 2567 DebuggerEvent event(isolate_, DebuggerEvent::kBreakpointReached); |
| 2562 event.set_top_frame(top_frame); | 2568 event.set_top_frame(top_frame); |
| 2563 event.set_breakpoint(bpt); | 2569 event.set_breakpoint(bpt); |
| 2564 Object& closure_or_null = Object::Handle(top_frame->GetAsyncOperation()); | 2570 Object& closure_or_null = Object::Handle(top_frame->GetAsyncOperation()); |
| 2565 if (!closure_or_null.IsNull()) { | 2571 if (!closure_or_null.IsNull()) { |
| 2572 ASSERT(closure_or_null.IsInstance()); |
| 2573 ASSERT(Instance::Cast(closure_or_null).IsClosure()); |
| 2566 event.set_async_continuation(&closure_or_null); | 2574 event.set_async_continuation(&closure_or_null); |
| 2567 const Script& script = Script::Handle(top_frame->SourceScript()); | 2575 const Script& script = Script::Handle(top_frame->SourceScript()); |
| 2568 const TokenStream& tokens = TokenStream::Handle(script.tokens()); | 2576 const TokenStream& tokens = TokenStream::Handle(script.tokens()); |
| 2569 TokenStream::Iterator iter(tokens, top_frame->TokenPos()); | 2577 TokenStream::Iterator iter(tokens, top_frame->TokenPos()); |
| 2570 if ((iter.CurrentTokenKind() == Token::kIDENT) && | 2578 if ((iter.CurrentTokenKind() == Token::kIDENT) && |
| 2571 ((iter.CurrentLiteral() == Symbols::Await().raw()) || | 2579 ((iter.CurrentLiteral() == Symbols::Await().raw()) || |
| 2572 (iter.CurrentLiteral() == Symbols::YieldKw().raw()))) { | 2580 (iter.CurrentLiteral() == Symbols::YieldKw().raw()))) { |
| 2573 event.set_at_async_jump(true); | 2581 event.set_at_async_jump(true); |
| 2574 } | 2582 } |
| 2575 } | 2583 } |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3213 } | 3221 } |
| 3214 | 3222 |
| 3215 | 3223 |
| 3216 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 3224 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 3217 ASSERT(bpt->next() == NULL); | 3225 ASSERT(bpt->next() == NULL); |
| 3218 bpt->set_next(code_breakpoints_); | 3226 bpt->set_next(code_breakpoints_); |
| 3219 code_breakpoints_ = bpt; | 3227 code_breakpoints_ = bpt; |
| 3220 } | 3228 } |
| 3221 | 3229 |
| 3222 } // namespace dart | 3230 } // namespace dart |
| OLD | NEW |