| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 #include "vm/exceptions.h" | 6 #include "vm/exceptions.h" |
| 7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
| 8 #include "vm/runtime_entry.h" | 8 #include "vm/runtime_entry.h" |
| 9 #include "vm/stack_frame.h" | 9 #include "vm/stack_frame.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 // Get a full stack trace. | |
| 14 // Arg0: stack trace object. | |
| 15 // Return value: String that represents the full stack trace. | |
| 16 DEFINE_NATIVE_ENTRY(Stacktrace_getFullStacktrace, 1) { | |
| 17 const Stacktrace& trace = | |
| 18 Stacktrace::CheckedHandle(arguments->NativeArgAt(0)); | |
| 19 return trace.FullStacktrace(); | |
| 20 } | |
| 21 | |
| 22 | |
| 23 // Get a concise and pertinent stack trace. | |
| 24 // Arg0: stack trace object. | |
| 25 // Return value: String that represents the concise and pertinent stack trace. | |
| 26 DEFINE_NATIVE_ENTRY(Stacktrace_getStacktrace, 1) { | |
| 27 const Stacktrace& trace = | |
| 28 Stacktrace::CheckedHandle(arguments->NativeArgAt(0)); | |
| 29 intptr_t frame_index = 0; | |
| 30 return String::New(trace.ToCStringInternal(&frame_index)); | |
| 31 } | |
| 32 | |
| 33 | |
| 34 static void IterateFrames(const GrowableObjectArray& code_list, | 13 static void IterateFrames(const GrowableObjectArray& code_list, |
| 35 const GrowableObjectArray& pc_offset_list) { | 14 const GrowableObjectArray& pc_offset_list) { |
| 36 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); | 15 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); |
| 37 StackFrame* frame = frames.NextFrame(); | 16 StackFrame* frame = frames.NextFrame(); |
| 38 ASSERT(frame != NULL); // We expect to find a dart invocation frame. | 17 ASSERT(frame != NULL); // We expect to find a dart invocation frame. |
| 39 Code& code = Code::Handle(); | 18 Code& code = Code::Handle(); |
| 40 Smi& offset = Smi::Handle(); | 19 Smi& offset = Smi::Handle(); |
| 41 intptr_t frames_to_skip = 2; // _setupFullStackTrace and the catch frame. | 20 intptr_t frames_to_skip = 2; // _setupFullStackTrace and the catch frame. |
| 42 while (frame != NULL) { | 21 while (frame != NULL) { |
| 43 if (frame->IsDartFrame()) { | 22 if (frame->IsDartFrame()) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 IterateFrames(code_list, pc_offset_list); | 66 IterateFrames(code_list, pc_offset_list); |
| 88 const Array& code_array = Array::Handle(Array::MakeArray(code_list)); | 67 const Array& code_array = Array::Handle(Array::MakeArray(code_list)); |
| 89 const Array& pc_offset_array = | 68 const Array& pc_offset_array = |
| 90 Array::Handle(Array::MakeArray(pc_offset_list)); | 69 Array::Handle(Array::MakeArray(pc_offset_list)); |
| 91 const Stacktrace& stacktrace = Stacktrace::Handle( | 70 const Stacktrace& stacktrace = Stacktrace::Handle( |
| 92 Stacktrace::New(code_array, pc_offset_array)); | 71 Stacktrace::New(code_array, pc_offset_array)); |
| 93 OS::Print("%s\n", stacktrace.ToCString()); | 72 OS::Print("%s\n", stacktrace.ToCString()); |
| 94 } | 73 } |
| 95 | 74 |
| 96 } // namespace dart | 75 } // namespace dart |
| OLD | NEW |