| 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 frame; | 5 library frame; |
| 6 | 6 |
| 7 | 7 |
| 8 import 'package:path/path.dart' as path; | 8 import 'package:path/path.dart' as path; |
| 9 | 9 |
| 10 import 'trace.dart'; | 10 import 'trace.dart'; |
| 11 | 11 |
| 12 // #1 Foo._bar (file:///home/nweiz/code/stuff.dart:42:21) | 12 // #1 Foo._bar (file:///home/nweiz/code/stuff.dart:42:21) |
| 13 final _vmFrame = new RegExp( | 13 // #1 Foo._bar (file:///home/nweiz/code/stuff.dart:42) |
| 14 r'^#\d+\s+(\S.*) \((.+?):(\d+)(?::(\d+))?\)$'); | 14 // #1 Foo._bar (file:///home/nweiz/code/stuff.dart) |
| 15 final _vmFrame = new RegExp(r'^#\d+\s+(\S.*) \((.+?)((?::\d+){0,2})\)$'); |
| 15 | 16 |
| 16 // at VW.call$0 (http://pub.dartlang.org/stuff.dart.js:560:28) | 17 // at VW.call$0 (http://pub.dartlang.org/stuff.dart.js:560:28) |
| 17 // at VW.call$0 (eval as fn | 18 // at VW.call$0 (eval as fn |
| 18 // (http://pub.dartlang.org/stuff.dart.js:560:28), efn:3:28) | 19 // (http://pub.dartlang.org/stuff.dart.js:560:28), efn:3:28) |
| 19 // at http://pub.dartlang.org/stuff.dart.js:560:28 | 20 // at http://pub.dartlang.org/stuff.dart.js:560:28 |
| 20 final _v8Frame = new RegExp( | 21 final _v8Frame = new RegExp( |
| 21 r'^\s*at (?:(\S.*?)(?: \[as [^\]]+\])? \((.*)\)|(.*))$'); | 22 r'^\s*at (?:(\S.*?)(?: \[as [^\]]+\])? \((.*)\)|(.*))$'); |
| 22 | 23 |
| 23 // http://pub.dartlang.org/stuff.dart.js:560:28 | 24 // http://pub.dartlang.org/stuff.dart.js:560:28 |
| 24 final _v8UrlLocation = new RegExp(r'^(.*):(\d+):(\d+)$'); | 25 final _v8UrlLocation = new RegExp(r'^(.*):(\d+):(\d+)$'); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 return new Frame(new Uri(), null, null, '...'); | 129 return new Frame(new Uri(), null, null, '...'); |
| 129 } | 130 } |
| 130 | 131 |
| 131 var match = _vmFrame.firstMatch(frame); | 132 var match = _vmFrame.firstMatch(frame); |
| 132 if (match == null) { | 133 if (match == null) { |
| 133 throw new FormatException("Couldn't parse VM stack trace line '$frame'."); | 134 throw new FormatException("Couldn't parse VM stack trace line '$frame'."); |
| 134 } | 135 } |
| 135 | 136 |
| 136 // Get the pieces out of the regexp match. Function, URI and line should | 137 // Get the pieces out of the regexp match. Function, URI and line should |
| 137 // always be found. The column is optional. | 138 // always be found. The column is optional. |
| 138 var member = match[1].replaceAll("<anonymous closure>", "<fn>"); | 139 var member = match[1] |
| 140 .replaceAll("<<anonymous closure>_async_body>", "<async>") |
| 141 .replaceAll("<anonymous closure>", "<fn>"); |
| 139 var uri = Uri.parse(match[2]); | 142 var uri = Uri.parse(match[2]); |
| 140 var line = int.parse(match[3]); | 143 |
| 141 var column = null; | 144 var lineAndColumn = match[3].split(':'); |
| 142 var columnMatch = match[4]; | 145 var line = lineAndColumn.length > 1 ? int.parse(lineAndColumn[1]) : null; |
| 143 if (columnMatch != null) { | 146 var column = lineAndColumn.length > 2 ? int.parse(lineAndColumn[2]) : null; |
| 144 column = int.parse(columnMatch); | |
| 145 } | |
| 146 return new Frame(uri, line, column, member); | 147 return new Frame(uri, line, column, member); |
| 147 } | 148 } |
| 148 | 149 |
| 149 /// Parses a string representation of a Chrome/V8 stack frame. | 150 /// Parses a string representation of a Chrome/V8 stack frame. |
| 150 factory Frame.parseV8(String frame) { | 151 factory Frame.parseV8(String frame) { |
| 151 var match = _v8Frame.firstMatch(frame); | 152 var match = _v8Frame.firstMatch(frame); |
| 152 if (match == null) { | 153 if (match == null) { |
| 153 throw new FormatException("Couldn't parse V8 stack trace line '$frame'."); | 154 throw new FormatException("Couldn't parse V8 stack trace line '$frame'."); |
| 154 } | 155 } |
| 155 | 156 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 // their stack frames. However, if we do get a relative path, we should | 280 // their stack frames. However, if we do get a relative path, we should |
| 280 // handle it gracefully. | 281 // handle it gracefully. |
| 281 if (uriOrPath.contains('\\')) return path.windows.toUri(uriOrPath); | 282 if (uriOrPath.contains('\\')) return path.windows.toUri(uriOrPath); |
| 282 return Uri.parse(uriOrPath); | 283 return Uri.parse(uriOrPath); |
| 283 } | 284 } |
| 284 | 285 |
| 285 Frame(this.uri, this.line, this.column, this.member); | 286 Frame(this.uri, this.line, this.column, this.member); |
| 286 | 287 |
| 287 String toString() => '$location in $member'; | 288 String toString() => '$location in $member'; |
| 288 } | 289 } |
| OLD | NEW |