| 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 /// foo$bar$0@http://pub.dartlang.org/stuff.dart.js:560:28 |
| 23 /// http://pub.dartlang.org/stuff.dart.js:560:28 |
| 24 final _safariFrame = new RegExp(r"^(?:([0-9A-Za-z_$]*)@)?(.*):(\d*):(\d*)$"); |
| 25 |
| 22 // .VW.call$0@http://pub.dartlang.org/stuff.dart.js:560 | 26 // .VW.call$0@http://pub.dartlang.org/stuff.dart.js:560 |
| 23 // .VW.call$0("arg")@http://pub.dartlang.org/stuff.dart.js:560 | 27 // .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 | 28 // .VW.call$0/name<@http://pub.dartlang.org/stuff.dart.js:560 |
| 25 final _firefoxFrame = new RegExp( | 29 final _firefoxFrame = new RegExp( |
| 26 r'^([^@(/]*)(?:\(.*\))?((?:/[^/]*)*)(?:\(.*\))?@(.*):(\d+)$'); | 30 r'^([^@(/]*)(?:\(.*\))?((?:/[^/]*)*)(?:\(.*\))?@(.*):(\d+)$'); |
| 27 | 31 |
| 28 // foo/bar.dart 10:11 in Foo._bar | 32 // foo/bar.dart 10:11 in Foo._bar |
| 29 // http://dartlang.org/foo/bar.dart in Foo._bar | 33 // http://dartlang.org/foo/bar.dart in Foo._bar |
| 30 final _friendlyFrame = new RegExp( | 34 final _friendlyFrame = new RegExp( |
| 31 r'^([^\s]+)(?: (\d+)(?::(\d+))?)?\s+([^\d][^\s]*)$'); | 35 r'^([^\s]+)(?: (\d+)(?::(\d+))?)?\s+([^\d][^\s]*)$'); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 var member = match[1]; | 166 var member = match[1]; |
| 163 member += new List.filled('/'.allMatches(match[2]).length, ".<fn>").join(); | 167 member += new List.filled('/'.allMatches(match[2]).length, ".<fn>").join(); |
| 164 if (member == '') member = '<fn>'; | 168 if (member == '') member = '<fn>'; |
| 165 | 169 |
| 166 // Some Firefox members have initial dots. We remove them for consistency | 170 // Some Firefox members have initial dots. We remove them for consistency |
| 167 // with other platforms. | 171 // with other platforms. |
| 168 member = member.replaceFirst(_initialDot, ''); | 172 member = member.replaceFirst(_initialDot, ''); |
| 169 return new Frame(uri, int.parse(match[4]), null, member); | 173 return new Frame(uri, int.parse(match[4]), null, member); |
| 170 } | 174 } |
| 171 | 175 |
| 172 /// Parses a string representation of a Safari stack frame. | 176 /// Parses a string representation of a Safari 6.0 stack frame. |
| 173 /// | 177 /// |
| 174 /// Safari 6+ frames look just like Firefox frames. Prior to Safari 6, stack | 178 /// Safari 6.0 frames look just like Firefox frames. Prior to Safari 6.0, |
| 175 /// traces can't be retrieved. | 179 /// stack traces can't be retrieved. |
| 176 factory Frame.parseSafari(String frame) => new Frame.parseFirefox(frame); | 180 factory Frame.parseSafari6_0(String frame) => new Frame.parseFirefox(frame); |
| 181 |
| 182 /// Parses a string representation of a Safari 6.1+ stack frame. |
| 183 factory Frame.parseSafari6_1(String frame) { |
| 184 var match = _safariFrame.firstMatch(frame); |
| 185 if (match == null) { |
| 186 throw new FormatException( |
| 187 "Couldn't parse Safari stack trace line '$frame'."); |
| 188 } |
| 189 |
| 190 var uri = Uri.parse(match[2]); |
| 191 var member = match[1]; |
| 192 if (member == null) member = '<fn>'; |
| 193 var line = match[3] == '' ? null : int.parse(match[3]); |
| 194 var column = match[4] == '' ? null : int.parse(match[4]); |
| 195 return new Frame(uri, line, column, member); |
| 196 } |
| 177 | 197 |
| 178 /// Parses this package's string representation of a stack frame. | 198 /// Parses this package's string representation of a stack frame. |
| 179 factory Frame.parseFriendly(String frame) { | 199 factory Frame.parseFriendly(String frame) { |
| 180 var match = _friendlyFrame.firstMatch(frame); | 200 var match = _friendlyFrame.firstMatch(frame); |
| 181 if (match == null) { | 201 if (match == null) { |
| 182 throw new FormatException( | 202 throw new FormatException( |
| 183 "Couldn't parse package:stack_trace stack trace line '$frame'."); | 203 "Couldn't parse package:stack_trace stack trace line '$frame'."); |
| 184 } | 204 } |
| 185 | 205 |
| 186 var uri = Uri.parse(match[1]); | 206 var uri = Uri.parse(match[1]); |
| 187 // If there's no scheme, this is a relative URI. We should interpret it as | 207 // If there's no scheme, this is a relative URI. We should interpret it as |
| 188 // relative to the current working directory. | 208 // relative to the current working directory. |
| 189 if (uri.scheme == '') { | 209 if (uri.scheme == '') { |
| 190 uri = path.toUri(path.absolute(path.fromUri(uri))); | 210 uri = path.toUri(path.absolute(path.fromUri(uri))); |
| 191 } | 211 } |
| 192 | 212 |
| 193 var line = match[2] == null ? null : int.parse(match[2]); | 213 var line = match[2] == null ? null : int.parse(match[2]); |
| 194 var column = match[3] == null ? null : int.parse(match[3]); | 214 var column = match[3] == null ? null : int.parse(match[3]); |
| 195 return new Frame(uri, line, column, match[4]); | 215 return new Frame(uri, line, column, match[4]); |
| 196 } | 216 } |
| 197 | 217 |
| 198 Frame(this.uri, this.line, this.column, this.member); | 218 Frame(this.uri, this.line, this.column, this.member); |
| 199 | 219 |
| 200 String toString() => '$location in $member'; | 220 String toString() => '$location in $member'; |
| 201 } | 221 } |
| OLD | NEW |