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 library trace; | 5 library trace; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
9 | 9 |
10 import 'chain.dart'; | 10 import 'chain.dart'; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 StackTrace get vmTrace => new VMTrace(frames); | 198 StackTrace get vmTrace => new VMTrace(frames); |
199 | 199 |
200 /// Returns a terser version of [this]. | 200 /// Returns a terser version of [this]. |
201 /// | 201 /// |
202 /// This is accomplished by folding together multiple stack frames from the | 202 /// This is accomplished by folding together multiple stack frames from the |
203 /// core library or from this package, as in [foldFrames]. Remaining core | 203 /// core library or from this package, as in [foldFrames]. Remaining core |
204 /// library frames have their libraries, "-patch" suffixes, and line numbers | 204 /// library frames have their libraries, "-patch" suffixes, and line numbers |
205 /// removed. | 205 /// removed. |
206 Trace get terse { | 206 Trace get terse { |
207 return new Trace(foldFrames((frame) { | 207 return new Trace(foldFrames((frame) { |
208 return frame.isCore || frame.package == 'stack_trace'; | 208 if (frame.isCore) return true; |
209 if (frame.package == 'stack_trace') return true; | |
210 | |
211 // Ignore async stack frames without any line or column information. These | |
Bob Nystrom
2015/02/12 19:31:45
Do you know if the VM intends to always have these
nweiz
2015/02/12 19:57:01
Done.
| |
212 // come from the VM's async/await implementation and represent internal | |
213 // frames. They only ever show up in stack chains and are always | |
214 // surrounded by other traces that are actually useful, so we can just get | |
215 // rid of them. | |
216 if (!frame.member.contains('<async>')) return false; | |
217 return frame.line == null; | |
209 }).frames.map((frame) { | 218 }).frames.map((frame) { |
210 if (!frame.isCore) return frame; | 219 if (!frame.isCore) return frame; |
211 var library = frame.library.replaceAll(_terseRegExp, ''); | 220 var library = frame.library.replaceAll(_terseRegExp, ''); |
212 return new Frame(Uri.parse(library), null, null, frame.member); | 221 return new Frame(Uri.parse(library), null, null, frame.member); |
213 })); | 222 })); |
214 } | 223 } |
215 | 224 |
216 /// Returns a new [Trace] based on [this] where multiple stack frames matching | 225 /// Returns a new [Trace] based on [this] where multiple stack frames matching |
217 /// [predicate] are folded together. This means that whenever there are | 226 /// [predicate] are folded together. This means that whenever there are |
218 /// multiple frames in a row that match [predicate], only the last one is | 227 /// multiple frames in a row that match [predicate], only the last one is |
(...skipping 20 matching lines...) Expand all Loading... | |
239 // Figure out the longest path so we know how much to pad. | 248 // Figure out the longest path so we know how much to pad. |
240 var longest = frames.map((frame) => frame.location.length) | 249 var longest = frames.map((frame) => frame.location.length) |
241 .fold(0, math.max); | 250 .fold(0, math.max); |
242 | 251 |
243 // Print out the stack trace nicely formatted. | 252 // Print out the stack trace nicely formatted. |
244 return frames.map((frame) { | 253 return frames.map((frame) { |
245 return '${padRight(frame.location, longest)} ${frame.member}\n'; | 254 return '${padRight(frame.location, longest)} ${frame.member}\n'; |
246 }).join(); | 255 }).join(); |
247 } | 256 } |
248 } | 257 } |
OLD | NEW |