Chromium Code Reviews| 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'; | 
| 11 import 'lazy_trace.dart'; | 11 import 'lazy_trace.dart'; | 
| 12 import 'utils.dart'; | 12 import 'utils.dart'; | 
| 13 import 'vm_trace.dart'; | 13 import 'vm_trace.dart'; | 
| 14 | 14 | 
| 15 final _terseRegExp = new RegExp(r"(-patch)?(/.*)?$"); | 15 final _terseRegExp = new RegExp(r"(-patch)?(/.*)?$"); | 
| 16 | 16 | 
| 17 /// A RegExp to match Firefox's stack traces. | 17 /// A RegExp to match Firefox's stack traces. | 
| 18 /// | 18 /// | 
| 19 /// Firefox's trace frames start with the name of the function in which the | 19 /// Firefox's trace frames start with the name of the function in which the | 
| 20 /// error occurred, possibly including its parameters inside `()`. For example, | 20 /// error occurred, possibly including its parameters inside `()`. For example, | 
| 21 /// `.VW.call$0("arg")@http://pub.dartlang.org/stuff.dart.js:560`. | 21 /// `.VW.call$0("arg")@http://pub.dartlang.org/stuff.dart.js:560`. | 
| 22 final _firefoxTrace = new RegExp(r"^([.0-9A-Za-z_$/<]*|\(.*\))*@"); | 22 final _firefoxTrace = new RegExp(r"^([.0-9A-Za-z_$/<]|\(.*\))*@"); | 
| 
 
Bob Nystrom
2013/07/08 22:02:27
I think this would handle this poorly:
.VW.call$0
 
nweiz
2013/07/08 22:24:49
The ".*" in "\(.*\)" is greedy; it'll match until
 
 | |
| 23 | 23 | 
| 24 /// A RegExp to match this package's stack traces. | 24 /// A RegExp to match this package's stack traces. | 
| 25 final _friendlyTrace = new RegExp(r"^[^\s]+( \d+:\d+)?\s+[^\s]+($|\n)"); | 25 final _friendlyTrace = new RegExp(r"^[^\s]+( \d+:\d+)?\s+[^\s]+($|\n)"); | 
| 26 | 26 | 
| 27 /// A stack trace, comprised of a list of stack frames. | 27 /// A stack trace, comprised of a list of stack frames. | 
| 28 class Trace implements StackTrace { | 28 class Trace implements StackTrace { | 
| 29 /// The stack frames that comprise this stack trace. | 29 /// The stack frames that comprise this stack trace. | 
| 30 final List<Frame> frames; | 30 final List<Frame> frames; | 
| 31 | 31 | 
| 32 /// Returns a human-readable representation of [stackTrace]. If [terse] is | 32 /// Returns a human-readable representation of [stackTrace]. If [terse] is | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 // Figure out the longest path so we know how much to pad. | 150 // Figure out the longest path so we know how much to pad. | 
| 151 var longest = frames.map((frame) => frame.location.length) | 151 var longest = frames.map((frame) => frame.location.length) | 
| 152 .fold(0, math.max); | 152 .fold(0, math.max); | 
| 153 | 153 | 
| 154 // Print out the stack trace nicely formatted. | 154 // Print out the stack trace nicely formatted. | 
| 155 return frames.map((frame) { | 155 return frames.map((frame) { | 
| 156 return '${padRight(frame.location, longest)} ${frame.member}\n'; | 156 return '${padRight(frame.location, longest)} ${frame.member}\n'; | 
| 157 }).join(); | 157 }).join(); | 
| 158 } | 158 } | 
| 159 } | 159 } | 
| OLD | NEW |