| 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/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 12971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12982 const Array& code_array, | 12982 const Array& code_array, |
| 12983 const Array& pc_offset_array) const { | 12983 const Array& pc_offset_array) const { |
| 12984 StorePointer(&raw_ptr()->catch_func_array_, func_array.raw()); | 12984 StorePointer(&raw_ptr()->catch_func_array_, func_array.raw()); |
| 12985 StorePointer(&raw_ptr()->catch_code_array_, code_array.raw()); | 12985 StorePointer(&raw_ptr()->catch_code_array_, code_array.raw()); |
| 12986 StorePointer(&raw_ptr()->catch_pc_offset_array_, pc_offset_array.raw()); | 12986 StorePointer(&raw_ptr()->catch_pc_offset_array_, pc_offset_array.raw()); |
| 12987 } | 12987 } |
| 12988 | 12988 |
| 12989 | 12989 |
| 12990 RawString* Stacktrace::FullStacktrace() const { | 12990 RawString* Stacktrace::FullStacktrace() const { |
| 12991 const Array& func_array = Array::Handle(raw_ptr()->catch_func_array_); | 12991 const Array& func_array = Array::Handle(raw_ptr()->catch_func_array_); |
| 12992 if (!func_array.IsNull() && | 12992 if (!func_array.IsNull() && (func_array.Length() > 0)) { |
| 12993 func_array.raw() != Object::empty_array().raw()) { | |
| 12994 const Array& code_array = Array::Handle(raw_ptr()->catch_code_array_); | 12993 const Array& code_array = Array::Handle(raw_ptr()->catch_code_array_); |
| 12995 const Array& pc_offset_array = | 12994 const Array& pc_offset_array = |
| 12996 Array::Handle(raw_ptr()->catch_pc_offset_array_); | 12995 Array::Handle(raw_ptr()->catch_pc_offset_array_); |
| 12997 const Stacktrace& catch_trace = Stacktrace::Handle( | 12996 const Stacktrace& catch_trace = Stacktrace::Handle( |
| 12998 Stacktrace::New(func_array, code_array, pc_offset_array)); | 12997 Stacktrace::New(func_array, code_array, pc_offset_array)); |
| 12998 intptr_t idx = Length(); |
| 12999 const String& trace = | 12999 const String& trace = |
| 13000 String::Handle(String::New(catch_trace.ToCStringInternal())); | 13000 String::Handle(String::New(catch_trace.ToCStringInternal(idx))); |
| 13001 const String& throw_trace = | 13001 const String& throw_trace = |
| 13002 String::Handle(String::New(ToCStringInternal())); | 13002 String::Handle(String::New(ToCStringInternal(0))); |
| 13003 return String::Concat(throw_trace, trace); | 13003 return String::Concat(throw_trace, trace); |
| 13004 } | 13004 } |
| 13005 return String::New(ToCStringInternal()); | 13005 return String::New(ToCStringInternal(0)); |
| 13006 } | 13006 } |
| 13007 | 13007 |
| 13008 | 13008 |
| 13009 const char* Stacktrace::ToCString() const { | 13009 const char* Stacktrace::ToCString() const { |
| 13010 const String& trace = String::Handle(FullStacktrace()); | 13010 const String& trace = String::Handle(FullStacktrace()); |
| 13011 return trace.ToCString(); | 13011 return trace.ToCString(); |
| 13012 } | 13012 } |
| 13013 | 13013 |
| 13014 | 13014 |
| 13015 const char* Stacktrace::ToCStringInternal() const { | 13015 const char* Stacktrace::ToCStringInternal(intptr_t frame_index) const { |
| 13016 Isolate* isolate = Isolate::Current(); | 13016 Isolate* isolate = Isolate::Current(); |
| 13017 Function& function = Function::Handle(); | 13017 Function& function = Function::Handle(); |
| 13018 Code& code = Code::Handle(); | 13018 Code& code = Code::Handle(); |
| 13019 Script& script = Script::Handle(); | 13019 Script& script = Script::Handle(); |
| 13020 String& function_name = String::Handle(); | 13020 String& function_name = String::Handle(); |
| 13021 String& url = String::Handle(); | 13021 String& url = String::Handle(); |
| 13022 | 13022 |
| 13023 // Iterate through the stack frames and create C string description | 13023 // Iterate through the stack frames and create C string description |
| 13024 // for each frame. | 13024 // for each frame. |
| 13025 intptr_t total_len = 0; | 13025 intptr_t total_len = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 13045 intptr_t token_pos = code.GetTokenIndexOfPC(pc); | 13045 intptr_t token_pos = code.GetTokenIndexOfPC(pc); |
| 13046 script = function.script(); | 13046 script = function.script(); |
| 13047 function_name = function.QualifiedUserVisibleName(); | 13047 function_name = function.QualifiedUserVisibleName(); |
| 13048 url = script.url(); | 13048 url = script.url(); |
| 13049 intptr_t line = -1; | 13049 intptr_t line = -1; |
| 13050 intptr_t column = -1; | 13050 intptr_t column = -1; |
| 13051 if (token_pos >= 0) { | 13051 if (token_pos >= 0) { |
| 13052 script.GetTokenLocation(token_pos, &line, &column); | 13052 script.GetTokenLocation(token_pos, &line, &column); |
| 13053 } | 13053 } |
| 13054 intptr_t len = OS::SNPrint(NULL, 0, kFormat, | 13054 intptr_t len = OS::SNPrint(NULL, 0, kFormat, |
| 13055 i, | 13055 (frame_index + i), |
| 13056 function_name.ToCString(), | 13056 function_name.ToCString(), |
| 13057 url.ToCString(), | 13057 url.ToCString(), |
| 13058 line, column); | 13058 line, column); |
| 13059 total_len += len; | 13059 total_len += len; |
| 13060 chars = isolate->current_zone()->Alloc<char>(len + 1); | 13060 chars = isolate->current_zone()->Alloc<char>(len + 1); |
| 13061 OS::SNPrint(chars, (len + 1), kFormat, | 13061 OS::SNPrint(chars, (len + 1), kFormat, |
| 13062 i, | 13062 (frame_index + i), |
| 13063 function_name.ToCString(), | 13063 function_name.ToCString(), |
| 13064 url.ToCString(), | 13064 url.ToCString(), |
| 13065 line, column); | 13065 line, column); |
| 13066 frame_strings.Add(chars); | 13066 frame_strings.Add(chars); |
| 13067 } | 13067 } |
| 13068 | 13068 |
| 13069 // Now concatentate the frame descriptions into a single C string. | 13069 // Now concatentate the frame descriptions into a single C string. |
| 13070 chars = isolate->current_zone()->Alloc<char>(total_len + 1); | 13070 chars = isolate->current_zone()->Alloc<char>(total_len + 1); |
| 13071 intptr_t index = 0; | 13071 intptr_t index = 0; |
| 13072 for (intptr_t i = 0; i < frame_strings.length(); i++) { | 13072 for (intptr_t i = 0; i < frame_strings.length(); i++) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13190 } | 13190 } |
| 13191 return result.raw(); | 13191 return result.raw(); |
| 13192 } | 13192 } |
| 13193 | 13193 |
| 13194 | 13194 |
| 13195 const char* WeakProperty::ToCString() const { | 13195 const char* WeakProperty::ToCString() const { |
| 13196 return "_WeakProperty"; | 13196 return "_WeakProperty"; |
| 13197 } | 13197 } |
| 13198 | 13198 |
| 13199 } // namespace dart | 13199 } // namespace dart |
| OLD | NEW |