Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: pkg/stack_trace/lib/src/frame.dart

Issue 23068019: Support IE and Safari stack traces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/stack_trace/lib/src/trace.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 var member = match[1].replaceAll("<anonymous>", "<fn>"); 127 var member = match[1].replaceAll("<anonymous>", "<fn>");
128 return new Frame(uri, int.parse(match[3]), int.parse(match[4]), member); 128 return new Frame(uri, int.parse(match[3]), int.parse(match[4]), member);
129 } else { 129 } else {
130 // The second form looks like " at URI:LINE:COL", and is used for 130 // The second form looks like " at URI:LINE:COL", and is used for
131 // anonymous functions. 131 // anonymous functions.
132 var uri = Uri.parse(match[5]); 132 var uri = Uri.parse(match[5]);
133 return new Frame(uri, int.parse(match[6]), int.parse(match[7]), "<fn>"); 133 return new Frame(uri, int.parse(match[6]), int.parse(match[7]), "<fn>");
134 } 134 }
135 } 135 }
136 136
137 /// Parses a string representation of an IE stack frame.
138 ///
139 /// IE10+ frames look just like V8 frames. Prior to IE10, stack traces can't
140 /// be retrieved.
141 factory Frame.parseIE(String frame) => new Frame.parseV8(frame);
142
137 /// Parses a string representation of a Firefox stack frame. 143 /// Parses a string representation of a Firefox stack frame.
138 factory Frame.parseFirefox(String frame) { 144 factory Frame.parseFirefox(String frame) {
139 var match = _firefoxFrame.firstMatch(frame); 145 var match = _firefoxFrame.firstMatch(frame);
140 if (match == null) { 146 if (match == null) {
141 throw new FormatException( 147 throw new FormatException(
142 "Couldn't parse Firefox stack trace line '$frame'."); 148 "Couldn't parse Firefox stack trace line '$frame'.");
143 } 149 }
144 150
145 var uri = Uri.parse(match[3]); 151 var uri = Uri.parse(match[3]);
146 var member = match[1]; 152 var member = match[1];
147 if (member == "") { 153 if (member == "") {
148 member = "<fn>"; 154 member = "<fn>";
149 } else if (match[2] != null) { 155 } else if (match[2] != null) {
150 member = "$member.<fn>"; 156 member = "$member.<fn>";
151 } 157 }
152 // Some Firefox members have initial dots. We remove them for consistency 158 // Some Firefox members have initial dots. We remove them for consistency
153 // with other platforms. 159 // with other platforms.
154 member = member.replaceFirst(_initialDot, ''); 160 member = member.replaceFirst(_initialDot, '');
155 return new Frame(uri, int.parse(match[4]), null, member); 161 return new Frame(uri, int.parse(match[4]), null, member);
156 } 162 }
157 163
164 /// Parses a string representation of a Safari stack frame.
165 ///
166 /// Safari 6+ frames look just like Firefox frames. Prior to Safari 6, stack
167 /// traces can't be retrieved.
168 factory Frame.parseSafari(String frame) => new Frame.parseFirefox(frame);
169
158 /// Parses this package's string representation of a stack frame. 170 /// Parses this package's string representation of a stack frame.
159 factory Frame.parseFriendly(String frame) { 171 factory Frame.parseFriendly(String frame) {
160 var match = _friendlyFrame.firstMatch(frame); 172 var match = _friendlyFrame.firstMatch(frame);
161 if (match == null) { 173 if (match == null) {
162 throw new FormatException( 174 throw new FormatException(
163 "Couldn't parse package:stack_trace stack trace line '$frame'."); 175 "Couldn't parse package:stack_trace stack trace line '$frame'.");
164 } 176 }
165 177
166 var uri = Uri.parse(match[1]); 178 var uri = Uri.parse(match[1]);
167 // If there's no scheme, this is a relative URI. We should interpret it as 179 // If there's no scheme, this is a relative URI. We should interpret it as
168 // relative to the current working directory. 180 // relative to the current working directory.
169 if (uri.scheme == '') { 181 if (uri.scheme == '') {
170 uri = path.toUri(path.absolute(path.fromUri(uri))); 182 uri = path.toUri(path.absolute(path.fromUri(uri)));
171 } 183 }
172 184
173 var line = match[2] == null ? null : int.parse(match[2]); 185 var line = match[2] == null ? null : int.parse(match[2]);
174 var column = match[3] == null ? null : int.parse(match[3]); 186 var column = match[3] == null ? null : int.parse(match[3]);
175 return new Frame(uri, line, column, match[4]); 187 return new Frame(uri, line, column, match[4]);
176 } 188 }
177 189
178 Frame(this.uri, this.line, this.column, this.member); 190 Frame(this.uri, this.line, this.column, this.member);
179 191
180 String toString() => '$location in $member'; 192 String toString() => '$location in $member';
181 } 193 }
OLDNEW
« no previous file with comments | « no previous file | pkg/stack_trace/lib/src/trace.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698