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

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

Issue 23445005: Fixing stack traces on IE10. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | no next file » | 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 trace; 5 library trace;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'frame.dart'; 10 import 'frame.dart';
11 import 'lazy_trace.dart'; 11 import 'lazy_trace.dart';
12 import 'utils.dart'; 12 import 'utils.dart';
13 import 'vm_trace.dart'; 13 import 'vm_trace.dart';
14 14
15 final _terseRegExp = new RegExp(r"(-patch)?(/.*)?$"); 15 final _terseRegExp = new RegExp(r"(-patch)?(/.*)?$");
16 16
17 /// A RegExp to match V8's stack traces. 17 /// A RegExp to match V8's stack traces.
18 /// 18 ///
19 /// V8's traces start with a line that's either just "Error" or else is a 19 /// V8's traces start with a line that's either just "Error" or else is a
20 /// description of the exception that occurred. That description can be multiple 20 /// description of the exception that occurred. That description can be multiple
21 /// lines, so we just look for any line other than the first that begins with 21 /// lines, so we just look for any line other than the first that begins with
22 /// four spaces and "at". 22 /// three or four spaces and "at".
23 final _v8Trace = new RegExp(r"\n at "); 23 final _v8Trace = new RegExp(r"\n ?at ");
24
25 /// A RegExp to match indidual lines of V8's stack traces.
26 ///
27 /// This is intended to filter out the leading exception details of the trace
28 /// though it is possible for the message to match this as well.
29 final _v8TraceLine = new RegExp(r" ?at ");
24 30
25 /// A RegExp to match Firefox's stack traces. 31 /// A RegExp to match Firefox's stack traces.
26 /// 32 ///
27 /// Firefox's trace frames start with the name of the function in which the 33 /// Firefox's trace frames start with the name of the function in which the
28 /// error occurred, possibly including its parameters inside `()`. For example, 34 /// error occurred, possibly including its parameters inside `()`. For example,
29 /// `.VW.call$0("arg")@http://pub.dartlang.org/stuff.dart.js:560`. 35 /// `.VW.call$0("arg")@http://pub.dartlang.org/stuff.dart.js:560`.
30 final _firefoxTrace = new RegExp(r"^([.0-9A-Za-z_$/<]|\(.*\))*@"); 36 final _firefoxTrace = new RegExp(r"^([.0-9A-Za-z_$/<]|\(.*\))*@");
31 37
32 /// A RegExp to match this package's stack traces. 38 /// A RegExp to match this package's stack traces.
33 final _friendlyTrace = new RegExp(r"^[^\s]+( \d+:\d+)?\s+[^\s]+($|\n)"); 39 final _friendlyTrace = new RegExp(r"^[^\s]+( \d+:\d+)?\s+[^\s]+($|\n)");
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 /// Parses a string representation of a Dart VM stack trace. 105 /// Parses a string representation of a Dart VM stack trace.
100 Trace.parseVM(String trace) 106 Trace.parseVM(String trace)
101 : this(trace.trim().split("\n").map((line) => new Frame.parseVM(line))); 107 : this(trace.trim().split("\n").map((line) => new Frame.parseVM(line)));
102 108
103 /// Parses a string representation of a Chrome/V8 stack trace. 109 /// Parses a string representation of a Chrome/V8 stack trace.
104 Trace.parseV8(String trace) 110 Trace.parseV8(String trace)
105 : this(trace.split("\n").skip(1) 111 : this(trace.split("\n").skip(1)
106 // It's possible that an Exception's description contains a line that 112 // It's possible that an Exception's description contains a line that
107 // looks like a V8 trace line, which will screw this up. 113 // looks like a V8 trace line, which will screw this up.
108 // Unfortunately, that's impossible to detect. 114 // Unfortunately, that's impossible to detect.
109 .skipWhile((line) => !line.startsWith(" at ")) 115 .skipWhile((line) => !line.startsWith(_v8TraceLine))
110 .map((line) => new Frame.parseV8(line))); 116 .map((line) => new Frame.parseV8(line)));
111 117
112 /// Parses a string representation of an Internet Explorer stack trace. 118 /// Parses a string representation of an Internet Explorer stack trace.
113 /// 119 ///
114 /// IE10+ traces look just like V8 traces. Prior to IE10, stack traces can't 120 /// IE10+ traces look just like V8 traces. Prior to IE10, stack traces can't
115 /// be retrieved. 121 /// be retrieved.
116 Trace.parseIE(String trace) 122 Trace.parseIE(String trace)
117 : this.parseV8(trace); 123 : this.parseV8(trace);
118 124
119 /// Parses a string representation of a Firefox stack trace. 125 /// Parses a string representation of a Firefox stack trace.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // Figure out the longest path so we know how much to pad. 193 // Figure out the longest path so we know how much to pad.
188 var longest = frames.map((frame) => frame.location.length) 194 var longest = frames.map((frame) => frame.location.length)
189 .fold(0, math.max); 195 .fold(0, math.max);
190 196
191 // Print out the stack trace nicely formatted. 197 // Print out the stack trace nicely formatted.
192 return frames.map((frame) { 198 return frames.map((frame) {
193 return '${padRight(frame.location, longest)} ${frame.member}\n'; 199 return '${padRight(frame.location, longest)} ${frame.member}\n';
194 }).join(); 200 }).join();
195 } 201 }
196 } 202 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698