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 'frame.dart'; | 10 import 'frame.dart'; |
(...skipping 18 matching lines...) Expand all Loading... |
29 final _v8TraceLine = new RegExp(r" ?at "); | 29 final _v8TraceLine = new RegExp(r" ?at "); |
30 | 30 |
31 /// A RegExp to match Firefox's stack traces. | 31 /// A RegExp to match Firefox's stack traces. |
32 /// | 32 /// |
33 /// Firefox's trace frames start with the name of the function in which the | 33 /// Firefox's trace frames start with the name of the function in which the |
34 /// error occurred, possibly including its parameters inside `()`. For example, | 34 /// error occurred, possibly including its parameters inside `()`. For example, |
35 /// `.VW.call$0("arg")@http://pub.dartlang.org/stuff.dart.js:560`. | 35 /// `.VW.call$0("arg")@http://pub.dartlang.org/stuff.dart.js:560`. |
36 final _firefoxTrace = new RegExp(r"^([.0-9A-Za-z_$/<]|\(.*\))*@"); | 36 final _firefoxTrace = new RegExp(r"^([.0-9A-Za-z_$/<]|\(.*\))*@"); |
37 | 37 |
38 /// A RegExp to match this package's stack traces. | 38 /// A RegExp to match this package's stack traces. |
39 final _friendlyTrace = new RegExp(r"^[^\s]+( \d+:\d+)?\s+[^\s]+($|\n)"); | 39 final _friendlyTrace = new RegExp(r"^[^\s]+( \d+(:\d+)?)?\s+[^\s]+($|\n)"); |
40 | 40 |
41 /// A stack trace, comprised of a list of stack frames. | 41 /// A stack trace, comprised of a list of stack frames. |
42 class Trace implements StackTrace { | 42 class Trace implements StackTrace { |
43 /// The stack frames that comprise this stack trace. | 43 /// The stack frames that comprise this stack trace. |
44 final List<Frame> frames; | 44 final List<Frame> frames; |
45 | 45 |
46 /// Returns a human-readable representation of [stackTrace]. If [terse] is | 46 /// Returns a human-readable representation of [stackTrace]. If [terse] is |
47 /// set, this folds together multiple stack frames from the Dart core | 47 /// set, this folds together multiple stack frames from the Dart core |
48 /// libraries, so that only the core library method directly called from user | 48 /// libraries, so that only the core library method directly called from user |
49 /// code is visible (see [Trace.terse]). | 49 /// code is visible (see [Trace.terse]). |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // Figure out the longest path so we know how much to pad. | 193 // Figure out the longest path so we know how much to pad. |
194 var longest = frames.map((frame) => frame.location.length) | 194 var longest = frames.map((frame) => frame.location.length) |
195 .fold(0, math.max); | 195 .fold(0, math.max); |
196 | 196 |
197 // Print out the stack trace nicely formatted. | 197 // Print out the stack trace nicely formatted. |
198 return frames.map((frame) { | 198 return frames.map((frame) { |
199 return '${padRight(frame.location, longest)} ${frame.member}\n'; | 199 return '${padRight(frame.location, longest)} ${frame.member}\n'; |
200 }).join(); | 200 }).join(); |
201 } | 201 } |
202 } | 202 } |
OLD | NEW |