| 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 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 | 33 |
| 34 static void IterateFrames(const GrowableObjectArray& code_list, | 34 static void IterateFrames(const GrowableObjectArray& code_list, |
| 35 const GrowableObjectArray& pc_offset_list) { | 35 const GrowableObjectArray& pc_offset_list) { |
| 36 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); | 36 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); |
| 37 StackFrame* frame = frames.NextFrame(); | 37 StackFrame* frame = frames.NextFrame(); |
| 38 ASSERT(frame != NULL); // We expect to find a dart invocation frame. | 38 ASSERT(frame != NULL); // We expect to find a dart invocation frame. |
| 39 Code& code = Code::Handle(); | 39 Code& code = Code::Handle(); |
| 40 Smi& offset = Smi::Handle(); | 40 Smi& offset = Smi::Handle(); |
| 41 bool catch_frame_skipped = false; // Tracks if catch frame has been skipped. | 41 intptr_t frames_to_skip = 2; // _setupFullStackTrace and the catch frame. |
| 42 while (frame != NULL) { | 42 while (frame != NULL) { |
| 43 if (frame->IsDartFrame()) { | 43 if (frame->IsDartFrame()) { |
| 44 code = frame->LookupDartCode(); | 44 code = frame->LookupDartCode(); |
| 45 offset = Smi::New(frame->pc() - code.EntryPoint()); | 45 offset = Smi::New(frame->pc() - code.EntryPoint()); |
| 46 if (!catch_frame_skipped) { | 46 if (frames_to_skip > 0) { |
| 47 const Function& func = Function::Handle(code.function()); | 47 frames_to_skip--; |
| 48 // Skip over hidden native, and mark first visible frame as catch frame. | |
| 49 if (func.is_visible()) { | |
| 50 catch_frame_skipped = true; | |
| 51 } | |
| 52 } else { | 48 } else { |
| 53 code_list.Add(code); | 49 code_list.Add(code); |
| 54 pc_offset_list.Add(offset); | 50 pc_offset_list.Add(offset); |
| 55 } | 51 } |
| 56 } | 52 } |
| 57 frame = frames.NextFrame(); | 53 frame = frames.NextFrame(); |
| 58 } | 54 } |
| 59 } | 55 } |
| 60 | 56 |
| 61 | 57 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 91 IterateFrames(code_list, pc_offset_list); | 87 IterateFrames(code_list, pc_offset_list); |
| 92 const Array& code_array = Array::Handle(Array::MakeArray(code_list)); | 88 const Array& code_array = Array::Handle(Array::MakeArray(code_list)); |
| 93 const Array& pc_offset_array = | 89 const Array& pc_offset_array = |
| 94 Array::Handle(Array::MakeArray(pc_offset_list)); | 90 Array::Handle(Array::MakeArray(pc_offset_list)); |
| 95 const Stacktrace& stacktrace = Stacktrace::Handle( | 91 const Stacktrace& stacktrace = Stacktrace::Handle( |
| 96 Stacktrace::New(code_array, pc_offset_array)); | 92 Stacktrace::New(code_array, pc_offset_array)); |
| 97 OS::Print("%s\n", stacktrace.ToCString()); | 93 OS::Print("%s\n", stacktrace.ToCString()); |
| 98 } | 94 } |
| 99 | 95 |
| 100 } // namespace dart | 96 } // namespace dart |
| OLD | NEW |