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 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 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 // with "...". | 102 // with "...". |
| 103 if (frame == '...') { | 103 if (frame == '...') { |
| 104 return new Frame(new Uri(), null, null, '...'); | 104 return new Frame(new Uri(), null, null, '...'); |
| 105 } | 105 } |
| 106 | 106 |
| 107 var match = _vmFrame.firstMatch(frame); | 107 var match = _vmFrame.firstMatch(frame); |
| 108 if (match == null) { | 108 if (match == null) { |
| 109 throw new FormatException("Couldn't parse VM stack trace line '$frame'."); | 109 throw new FormatException("Couldn't parse VM stack trace line '$frame'."); |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Get the pieces out of the regexp match. Function, URI and line should | |
| 113 // always be found. The column is optional. | |
| 114 var member = match[1].replaceAll("<anonymous closure>", "<fn>"); | |
| 112 var uri = Uri.parse(match[2]); | 115 var uri = Uri.parse(match[2]); |
| 113 var member = match[1].replaceAll("<anonymous closure>", "<fn>"); | 116 var line = int.parse(match[3]); |
| 114 return new Frame(uri, int.parse(match[3]), int.parse(match[4]), member); | 117 var col = null; |
|
Bob Nystrom
2013/09/24 17:53:56
"col" -> "column".
Ivan Posva
2013/09/24 20:55:11
Done.
| |
| 118 var col_match = match[4]; | |
|
Bob Nystrom
2013/09/24 17:53:56
"col_match" -> "columnMatch".
nweiz
2013/09/24 20:16:03
This variable seems superfluous. Just use match[4]
Ivan Posva
2013/09/24 20:55:11
Done.
Ivan Posva
2013/09/24 20:55:11
Every time you access that same array element, you
nweiz
2013/09/24 20:57:11
I care about that a couple orders of magnitude les
| |
| 119 if (col_match != null) { | |
| 120 col = int.parse(col_match); | |
| 121 } | |
| 122 return new Frame(uri, line, col, member); | |
| 115 } | 123 } |
| 116 | 124 |
| 117 /// Parses a string representation of a Chrome/V8 stack frame. | 125 /// Parses a string representation of a Chrome/V8 stack frame. |
| 118 factory Frame.parseV8(String frame) { | 126 factory Frame.parseV8(String frame) { |
| 119 var match = _v8Frame.firstMatch(frame); | 127 var match = _v8Frame.firstMatch(frame); |
| 120 if (match == null) { | 128 if (match == null) { |
| 121 throw new FormatException("Couldn't parse V8 stack trace line '$frame'."); | 129 throw new FormatException("Couldn't parse V8 stack trace line '$frame'."); |
| 122 } | 130 } |
| 123 | 131 |
| 124 // V8 stack frames can be in two forms. | 132 // V8 stack frames can be in two forms. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 | 193 |
| 186 var line = match[2] == null ? null : int.parse(match[2]); | 194 var line = match[2] == null ? null : int.parse(match[2]); |
| 187 var column = match[3] == null ? null : int.parse(match[3]); | 195 var column = match[3] == null ? null : int.parse(match[3]); |
| 188 return new Frame(uri, line, column, match[4]); | 196 return new Frame(uri, line, column, match[4]); |
| 189 } | 197 } |
| 190 | 198 |
| 191 Frame(this.uri, this.line, this.column, this.member); | 199 Frame(this.uri, this.line, this.column, this.member); |
| 192 | 200 |
| 193 String toString() => '$location in $member'; | 201 String toString() => '$location in $member'; |
| 194 } | 202 } |
| OLD | NEW |