| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 if (level < 0) { | 90 if (level < 0) { |
| 91 throw new ArgumentError("Argument [level] must be greater than or equal " | 91 throw new ArgumentError("Argument [level] must be greater than or equal " |
| 92 "to 0."); | 92 "to 0."); |
| 93 } | 93 } |
| 94 | 94 |
| 95 return new Trace.current(level + 1).frames.first; | 95 return new Trace.current(level + 1).frames.first; |
| 96 } | 96 } |
| 97 | 97 |
| 98 /// Parses a string representation of a Dart VM stack frame. | 98 /// Parses a string representation of a Dart VM stack frame. |
| 99 factory Frame.parseVM(String frame) { | 99 factory Frame.parseVM(String frame) { |
| 100 // The VM sometimes folds multiple stack frames together and replaces them |
| 101 // with "...". |
| 102 if (frame == '...') { |
| 103 return new Frame(new Uri(), null, null, '...'); |
| 104 } |
| 105 |
| 100 var match = _vmFrame.firstMatch(frame); | 106 var match = _vmFrame.firstMatch(frame); |
| 101 if (match == null) { | 107 if (match == null) { |
| 102 throw new FormatException("Couldn't parse VM stack trace line '$frame'."); | 108 throw new FormatException("Couldn't parse VM stack trace line '$frame'."); |
| 103 } | 109 } |
| 104 | 110 |
| 105 var uri = Uri.parse(match[2]); | 111 var uri = Uri.parse(match[2]); |
| 106 var member = match[1].replaceAll("<anonymous closure>", "<fn>"); | 112 var member = match[1].replaceAll("<anonymous closure>", "<fn>"); |
| 107 return new Frame(uri, int.parse(match[3]), int.parse(match[4]), member); | 113 return new Frame(uri, int.parse(match[3]), int.parse(match[4]), member); |
| 108 } | 114 } |
| 109 | 115 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 172 |
| 167 var line = match[2] == null ? null : int.parse(match[2]); | 173 var line = match[2] == null ? null : int.parse(match[2]); |
| 168 var column = match[3] == null ? null : int.parse(match[3]); | 174 var column = match[3] == null ? null : int.parse(match[3]); |
| 169 return new Frame(uri, line, column, match[4]); | 175 return new Frame(uri, line, column, match[4]); |
| 170 } | 176 } |
| 171 | 177 |
| 172 Frame(this.uri, this.line, this.column, this.member); | 178 Frame(this.uri, this.line, this.column, this.member); |
| 173 | 179 |
| 174 String toString() => '$location in $member'; | 180 String toString() => '$location in $member'; |
| 175 } | 181 } |
| OLD | NEW |