| 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 final _vmFrame = new RegExp( |
| 14 r'^#\d+\s+([^\s].*) \((.+?):(\d+)(?::(\d+))?\)$'); | 14 r'^#\d+\s+([^\s].*) \((.+?):(\d+)(?::(\d+))?\)$'); |
| 15 | 15 |
| 16 // at VW.call$0 (http://pub.dartlang.org/stuff.dart.js:560:28) | 16 // at VW.call$0 (http://pub.dartlang.org/stuff.dart.js:560:28) |
| 17 // at http://pub.dartlang.org/stuff.dart.js:560:28 | 17 // at http://pub.dartlang.org/stuff.dart.js:560:28 |
| 18 final _v8Frame = new RegExp( | 18 final _v8Frame = new RegExp( |
| 19 r'^\s*at (?:([^\s].*?)(?: \[as [^\]]+\])? ' | 19 r'^\s*at (?:([^\s].*?)(?: \[as [^\]]+\])? ' |
| 20 r'\((.+):(\d+):(\d+)\)|(.+):(\d+):(\d+))$'); | 20 r'\((.+):(\d+):(\d+)\)|(.+):(\d+):(\d+))$'); |
| 21 | 21 |
| 22 // .VW.call$0@http://pub.dartlang.org/stuff.dart.js:560 | 22 // .VW.call$0@http://pub.dartlang.org/stuff.dart.js:560 |
| 23 // .VW.call$0("arg")@http://pub.dartlang.org/stuff.dart.js:560 | 23 // .VW.call$0("arg")@http://pub.dartlang.org/stuff.dart.js:560 |
| 24 // .VW.call$0/name<@http://pub.dartlang.org/stuff.dart.js:560 | 24 // .VW.call$0/name<@http://pub.dartlang.org/stuff.dart.js:560 |
| 25 final _firefoxFrame = new RegExp( | 25 final _firefoxFrame = new RegExp( |
| 26 r'^([^@(/]*)(?:\(.*\))?(/[^<]*<?)?(?:\(.*\))?@(.*):(\d+)$'); | 26 r'^([^@(/]*)(?:\(.*\))?((?:/[^/]*)*)(?:\(.*\))?@(.*):(\d+)$'); |
| 27 | 27 |
| 28 // foo/bar.dart 10:11 in Foo._bar | 28 // foo/bar.dart 10:11 in Foo._bar |
| 29 // http://dartlang.org/foo/bar.dart in Foo._bar | 29 // http://dartlang.org/foo/bar.dart in Foo._bar |
| 30 final _friendlyFrame = new RegExp( | 30 final _friendlyFrame = new RegExp( |
| 31 r'^([^\s]+)(?: (\d+):(\d+))?\s+([^\d][^\s]*)$'); | 31 r'^([^\s]+)(?: (\d+):(\d+))?\s+([^\d][^\s]*)$'); |
| 32 | 32 |
| 33 final _initialDot = new RegExp(r"^\."); | 33 final _initialDot = new RegExp(r"^\."); |
| 34 | 34 |
| 35 /// A single stack frame. Each frame points to a precise location in Dart code. | 35 /// A single stack frame. Each frame points to a precise location in Dart code. |
| 36 class Frame { | 36 class Frame { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 /// Parses a string representation of a Firefox stack frame. | 152 /// Parses a string representation of a Firefox stack frame. |
| 153 factory Frame.parseFirefox(String frame) { | 153 factory Frame.parseFirefox(String frame) { |
| 154 var match = _firefoxFrame.firstMatch(frame); | 154 var match = _firefoxFrame.firstMatch(frame); |
| 155 if (match == null) { | 155 if (match == null) { |
| 156 throw new FormatException( | 156 throw new FormatException( |
| 157 "Couldn't parse Firefox stack trace line '$frame'."); | 157 "Couldn't parse Firefox stack trace line '$frame'."); |
| 158 } | 158 } |
| 159 | 159 |
| 160 var uri = Uri.parse(match[3]); | 160 var uri = Uri.parse(match[3]); |
| 161 var member = match[1]; | 161 var member = match[1]; |
| 162 if (member == "") { | 162 member += new List.filled('/'.allMatches(match[2]).length, ".<fn>").join(); |
| 163 member = "<fn>"; | 163 if (member == '') member = '<fn>'; |
| 164 } else if (match[2] != null) { | 164 |
| 165 member = "$member.<fn>"; | |
| 166 } | |
| 167 // Some Firefox members have initial dots. We remove them for consistency | 165 // Some Firefox members have initial dots. We remove them for consistency |
| 168 // with other platforms. | 166 // with other platforms. |
| 169 member = member.replaceFirst(_initialDot, ''); | 167 member = member.replaceFirst(_initialDot, ''); |
| 170 return new Frame(uri, int.parse(match[4]), null, member); | 168 return new Frame(uri, int.parse(match[4]), null, member); |
| 171 } | 169 } |
| 172 | 170 |
| 173 /// Parses a string representation of a Safari stack frame. | 171 /// Parses a string representation of a Safari stack frame. |
| 174 /// | 172 /// |
| 175 /// Safari 6+ frames look just like Firefox frames. Prior to Safari 6, stack | 173 /// Safari 6+ frames look just like Firefox frames. Prior to Safari 6, stack |
| 176 /// traces can't be retrieved. | 174 /// traces can't be retrieved. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 193 | 191 |
| 194 var line = match[2] == null ? null : int.parse(match[2]); | 192 var line = match[2] == null ? null : int.parse(match[2]); |
| 195 var column = match[3] == null ? null : int.parse(match[3]); | 193 var column = match[3] == null ? null : int.parse(match[3]); |
| 196 return new Frame(uri, line, column, match[4]); | 194 return new Frame(uri, line, column, match[4]); |
| 197 } | 195 } |
| 198 | 196 |
| 199 Frame(this.uri, this.line, this.column, this.member); | 197 Frame(this.uri, this.line, this.column, this.member); |
| 200 | 198 |
| 201 String toString() => '$location in $member'; | 199 String toString() => '$location in $member'; |
| 202 } | 200 } |
| OLD | NEW |