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_frame.h" | 5 #include "vm/stack_frame.h" |
6 #include "vm/stack_trace.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); | 16 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, thread, |
| 17 StackFrameIterator::kNoCrossThreadIteration); |
17 StackFrame* frame = frames.NextFrame(); | 18 StackFrame* frame = frames.NextFrame(); |
18 ASSERT(frame != NULL); // We expect to find a dart invocation frame. | 19 ASSERT(frame != NULL); // We expect to find a dart invocation frame. |
19 Code& code = Code::Handle(zone); | 20 Code& code = Code::Handle(zone); |
20 Function& function = Function::Handle(zone); | 21 Function& function = Function::Handle(zone); |
21 const bool async_function_is_null = async_function.IsNull(); | 22 const bool async_function_is_null = async_function.IsNull(); |
22 while (frame != NULL) { | 23 while (frame != NULL) { |
23 if (frame->IsDartFrame()) { | 24 if (frame->IsDartFrame()) { |
24 if (skip_frames > 0) { | 25 if (skip_frames > 0) { |
25 skip_frames--; | 26 skip_frames--; |
26 } else { | 27 } else { |
(...skipping 14 matching lines...) Expand all Loading... |
41 } | 42 } |
42 | 43 |
43 | 44 |
44 intptr_t StackTraceUtils::CollectFrames(Thread* thread, | 45 intptr_t StackTraceUtils::CollectFrames(Thread* thread, |
45 const Array& code_array, | 46 const Array& code_array, |
46 const Array& pc_offset_array, | 47 const Array& pc_offset_array, |
47 intptr_t array_offset, | 48 intptr_t array_offset, |
48 intptr_t count, | 49 intptr_t count, |
49 int skip_frames) { | 50 int skip_frames) { |
50 Zone* zone = thread->zone(); | 51 Zone* zone = thread->zone(); |
51 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); | 52 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, thread, |
| 53 StackFrameIterator::kNoCrossThreadIteration); |
52 StackFrame* frame = frames.NextFrame(); | 54 StackFrame* frame = frames.NextFrame(); |
53 ASSERT(frame != NULL); // We expect to find a dart invocation frame. | 55 ASSERT(frame != NULL); // We expect to find a dart invocation frame. |
54 Function& function = Function::Handle(zone); | 56 Function& function = Function::Handle(zone); |
55 Code& code = Code::Handle(zone); | 57 Code& code = Code::Handle(zone); |
56 Smi& offset = Smi::Handle(zone); | 58 Smi& offset = Smi::Handle(zone); |
57 intptr_t collected_frames_count = 0; | 59 intptr_t collected_frames_count = 0; |
58 while ((frame != NULL) && (collected_frames_count < count)) { | 60 while ((frame != NULL) && (collected_frames_count < count)) { |
59 if (frame->IsDartFrame()) { | 61 if (frame->IsDartFrame()) { |
60 if (skip_frames > 0) { | 62 if (skip_frames > 0) { |
61 skip_frames--; | 63 skip_frames--; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 StubCode::AsynchronousGapMarker_entry()->code()); | 104 StubCode::AsynchronousGapMarker_entry()->code()); |
103 const Code& code = Code::Handle(Code::RawCast(async_code_array->At(1))); | 105 const Code& code = Code::Handle(Code::RawCast(async_code_array->At(1))); |
104 *async_function = code.function(); | 106 *async_function = code.function(); |
105 ASSERT(!async_function->IsNull()); | 107 ASSERT(!async_function->IsNull()); |
106 ASSERT(async_function->IsAsyncFunction() || | 108 ASSERT(async_function->IsAsyncFunction() || |
107 async_function->IsAsyncGenerator()); | 109 async_function->IsAsyncGenerator()); |
108 return async_stack_trace_length; | 110 return async_stack_trace_length; |
109 } | 111 } |
110 | 112 |
111 } // namespace dart | 113 } // namespace dart |
OLD | NEW |