| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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/stack_trace.h" |
| 5 #include "vm/stack_frame.h" | 6 #include "vm/stack_frame.h" |
| 6 #include "vm/stack_trace.h" | |
| 7 | 7 |
| 8 namespace dart { | 8 namespace dart { |
| 9 | 9 |
| 10 // Count the number of frames that are on the stack. | 10 // Count the number of frames that are on the stack. |
| 11 intptr_t StackTraceUtils::CountFrames(Thread* thread, | 11 intptr_t StackTraceUtils::CountFrames(Thread* thread, |
| 12 int skip_frames, | 12 int skip_frames, |
| 13 const Function& async_function) { | 13 const Function& async_function) { |
| 14 Zone* zone = thread->zone(); | 14 Zone* zone = thread->zone(); |
| 15 intptr_t frame_count = 0; | 15 intptr_t frame_count = 0; |
| 16 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, thread, | 16 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, thread, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 frame = frames.NextFrame(); | 37 frame = frames.NextFrame(); |
| 38 } | 38 } |
| 39 // We hit the sentinel. | 39 // We hit the sentinel. |
| 40 ASSERT(async_function_is_null); | 40 ASSERT(async_function_is_null); |
| 41 return frame_count; | 41 return frame_count; |
| 42 } | 42 } |
| 43 | 43 |
| 44 | |
| 45 intptr_t StackTraceUtils::CollectFrames(Thread* thread, | 44 intptr_t StackTraceUtils::CollectFrames(Thread* thread, |
| 46 const Array& code_array, | 45 const Array& code_array, |
| 47 const Array& pc_offset_array, | 46 const Array& pc_offset_array, |
| 48 intptr_t array_offset, | 47 intptr_t array_offset, |
| 49 intptr_t count, | 48 intptr_t count, |
| 50 int skip_frames) { | 49 int skip_frames) { |
| 51 Zone* zone = thread->zone(); | 50 Zone* zone = thread->zone(); |
| 52 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, thread, | 51 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, thread, |
| 53 StackFrameIterator::kNoCrossThreadIteration); | 52 StackFrameIterator::kNoCrossThreadIteration); |
| 54 StackFrame* frame = frames.NextFrame(); | 53 StackFrame* frame = frames.NextFrame(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 69 pc_offset_array.SetAt(array_offset, offset); | 68 pc_offset_array.SetAt(array_offset, offset); |
| 70 array_offset++; | 69 array_offset++; |
| 71 collected_frames_count++; | 70 collected_frames_count++; |
| 72 } | 71 } |
| 73 } | 72 } |
| 74 frame = frames.NextFrame(); | 73 frame = frames.NextFrame(); |
| 75 } | 74 } |
| 76 return collected_frames_count; | 75 return collected_frames_count; |
| 77 } | 76 } |
| 78 | 77 |
| 79 | |
| 80 intptr_t StackTraceUtils::ExtractAsyncStackTraceInfo( | 78 intptr_t StackTraceUtils::ExtractAsyncStackTraceInfo( |
| 81 Thread* thread, | 79 Thread* thread, |
| 82 Function* async_function, | 80 Function* async_function, |
| 83 StackTrace* async_stack_trace_out, | 81 StackTrace* async_stack_trace_out, |
| 84 Array* async_code_array, | 82 Array* async_code_array, |
| 85 Array* async_pc_offset_array) { | 83 Array* async_pc_offset_array) { |
| 86 if (thread->async_stack_trace() == StackTrace::null()) { | 84 if (thread->async_stack_trace() == StackTrace::null()) { |
| 87 return 0; | 85 return 0; |
| 88 } | 86 } |
| 89 *async_stack_trace_out = thread->async_stack_trace(); | 87 *async_stack_trace_out = thread->async_stack_trace(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 104 StubCode::AsynchronousGapMarker_entry()->code()); | 102 StubCode::AsynchronousGapMarker_entry()->code()); |
| 105 const Code& code = Code::Handle(Code::RawCast(async_code_array->At(1))); | 103 const Code& code = Code::Handle(Code::RawCast(async_code_array->At(1))); |
| 106 *async_function = code.function(); | 104 *async_function = code.function(); |
| 107 ASSERT(!async_function->IsNull()); | 105 ASSERT(!async_function->IsNull()); |
| 108 ASSERT(async_function->IsAsyncFunction() || | 106 ASSERT(async_function->IsAsyncFunction() || |
| 109 async_function->IsAsyncGenerator()); | 107 async_function->IsAsyncGenerator()); |
| 110 return async_stack_trace_length; | 108 return async_stack_trace_length; |
| 111 } | 109 } |
| 112 | 110 |
| 113 } // namespace dart | 111 } // namespace dart |
| OLD | NEW |