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 |
| 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 // TODO(nweiz): Get rid of this logic some time after issue 22009 is |
| 217 // fixed. |
| 218 if (!frame.member.contains('<async>')) return false; |
| 219 return frame.line == null; |
209 }).frames.map((frame) { | 220 }).frames.map((frame) { |
210 if (!frame.isCore) return frame; | 221 if (!frame.isCore) return frame; |
211 var library = frame.library.replaceAll(_terseRegExp, ''); | 222 var library = frame.library.replaceAll(_terseRegExp, ''); |
212 return new Frame(Uri.parse(library), null, null, frame.member); | 223 return new Frame(Uri.parse(library), null, null, frame.member); |
213 })); | 224 })); |
214 } | 225 } |
215 | 226 |
216 /// Returns a new [Trace] based on [this] where multiple stack frames matching | 227 /// Returns a new [Trace] based on [this] where multiple stack frames matching |
217 /// [predicate] are folded together. This means that whenever there are | 228 /// [predicate] are folded together. This means that whenever there are |
218 /// multiple frames in a row that match [predicate], only the last one is | 229 /// 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. | 250 // Figure out the longest path so we know how much to pad. |
240 var longest = frames.map((frame) => frame.location.length) | 251 var longest = frames.map((frame) => frame.location.length) |
241 .fold(0, math.max); | 252 .fold(0, math.max); |
242 | 253 |
243 // Print out the stack trace nicely formatted. | 254 // Print out the stack trace nicely formatted. |
244 return frames.map((frame) { | 255 return frames.map((frame) { |
245 return '${padRight(frame.location, longest)} ${frame.member}\n'; | 256 return '${padRight(frame.location, longest)} ${frame.member}\n'; |
246 }).join(); | 257 }).join(); |
247 } | 258 } |
248 } | 259 } |
OLD | NEW |