| 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'; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 r'(\d*)' // The line number. Empty in Safari if it's unknown. | 50 r'(\d*)' // The line number. Empty in Safari if it's unknown. |
| 51 r'(?::(\d*))?' // The column number. Not present in older browsers and | 51 r'(?::(\d*))?' // The column number. Not present in older browsers and |
| 52 // empty in Safari if it's unknown. | 52 // empty in Safari if it's unknown. |
| 53 r'$'); | 53 r'$'); |
| 54 | 54 |
| 55 // foo/bar.dart 10:11 in Foo._bar | 55 // foo/bar.dart 10:11 in Foo._bar |
| 56 // http://dartlang.org/foo/bar.dart in Foo._bar | 56 // http://dartlang.org/foo/bar.dart in Foo._bar |
| 57 final _friendlyFrame = new RegExp( | 57 final _friendlyFrame = new RegExp( |
| 58 r'^(\S+)(?: (\d+)(?::(\d+))?)?\s+([^\d]\S*)$'); | 58 r'^(\S+)(?: (\d+)(?::(\d+))?)?\s+([^\d]\S*)$'); |
| 59 | 59 |
| 60 /// A regular expression that matches asynchronous member names generated by the |
| 61 /// VM. |
| 62 final _asyncBody = new RegExp(r'<(<anonymous closure>|[^>]+)_async_body>'); |
| 63 |
| 60 final _initialDot = new RegExp(r"^\."); | 64 final _initialDot = new RegExp(r"^\."); |
| 61 | 65 |
| 62 /// A single stack frame. Each frame points to a precise location in Dart code. | 66 /// A single stack frame. Each frame points to a precise location in Dart code. |
| 63 class Frame { | 67 class Frame { |
| 64 /// The URI of the file in which the code is located. | 68 /// The URI of the file in which the code is located. |
| 65 /// | 69 /// |
| 66 /// This URI will usually have the scheme `dart`, `file`, `http`, or `https`. | 70 /// This URI will usually have the scheme `dart`, `file`, `http`, or `https`. |
| 67 final Uri uri; | 71 final Uri uri; |
| 68 | 72 |
| 69 /// The line number on which the code location is located. | 73 /// The line number on which the code location is located. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 134 } |
| 131 | 135 |
| 132 var match = _vmFrame.firstMatch(frame); | 136 var match = _vmFrame.firstMatch(frame); |
| 133 if (match == null) { | 137 if (match == null) { |
| 134 throw new FormatException("Couldn't parse VM stack trace line '$frame'."); | 138 throw new FormatException("Couldn't parse VM stack trace line '$frame'."); |
| 135 } | 139 } |
| 136 | 140 |
| 137 // Get the pieces out of the regexp match. Function, URI and line should | 141 // Get the pieces out of the regexp match. Function, URI and line should |
| 138 // always be found. The column is optional. | 142 // always be found. The column is optional. |
| 139 var member = match[1] | 143 var member = match[1] |
| 140 .replaceAll("<<anonymous closure>_async_body>", "<async>") | 144 .replaceAll(_asyncBody, "<async>") |
| 141 .replaceAll("<anonymous closure>", "<fn>"); | 145 .replaceAll("<anonymous closure>", "<fn>"); |
| 142 var uri = Uri.parse(match[2]); | 146 var uri = Uri.parse(match[2]); |
| 143 | 147 |
| 144 var lineAndColumn = match[3].split(':'); | 148 var lineAndColumn = match[3].split(':'); |
| 145 var line = lineAndColumn.length > 1 ? int.parse(lineAndColumn[1]) : null; | 149 var line = lineAndColumn.length > 1 ? int.parse(lineAndColumn[1]) : null; |
| 146 var column = lineAndColumn.length > 2 ? int.parse(lineAndColumn[2]) : null; | 150 var column = lineAndColumn.length > 2 ? int.parse(lineAndColumn[2]) : null; |
| 147 return new Frame(uri, line, column, member); | 151 return new Frame(uri, line, column, member); |
| 148 } | 152 } |
| 149 | 153 |
| 150 /// Parses a string representation of a Chrome/V8 stack frame. | 154 /// Parses a string representation of a Chrome/V8 stack frame. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // their stack frames. However, if we do get a relative path, we should | 284 // their stack frames. However, if we do get a relative path, we should |
| 281 // handle it gracefully. | 285 // handle it gracefully. |
| 282 if (uriOrPath.contains('\\')) return path.windows.toUri(uriOrPath); | 286 if (uriOrPath.contains('\\')) return path.windows.toUri(uriOrPath); |
| 283 return Uri.parse(uriOrPath); | 287 return Uri.parse(uriOrPath); |
| 284 } | 288 } |
| 285 | 289 |
| 286 Frame(this.uri, this.line, this.column, this.member); | 290 Frame(this.uri, this.line, this.column, this.member); |
| 287 | 291 |
| 288 String toString() => '$location in $member'; | 292 String toString() => '$location in $member'; |
| 289 } | 293 } |
| OLD | NEW |