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

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

Issue 132223003: Code review changes for r31644. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 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 VW.call$0 (eval as fn 17 // at VW.call$0 (eval as fn
18 // (http://pub.dartlang.org/stuff.dart.js:560:28), efn:3:28) 18 // (http://pub.dartlang.org/stuff.dart.js:560:28), efn:3:28)
19 // at http://pub.dartlang.org/stuff.dart.js:560:28 19 // at http://pub.dartlang.org/stuff.dart.js:560:28
20 final _v8Frame = new RegExp( 20 final _v8Frame = new RegExp(
21 r'^\s*at (?:([^\s].*?)(?: \[as [^\]]+\])? \((.*)\)|(.*))$'); 21 r'^\s*at (?:(\S.*?)(?: \[as [^\]]+\])? \((.*)\)|(.*))$');
22 22
23 // http://pub.dartlang.org/stuff.dart.js:560:28 23 // http://pub.dartlang.org/stuff.dart.js:560:28
24 final _v8UrlLocation = new RegExp(r'^(.*):(\d+):(\d+)$'); 24 final _v8UrlLocation = new RegExp(r'^(.*):(\d+):(\d+)$');
25 25
26 // eval as function (http://pub.dartlang.org/stuff.dart.js:560:28), efn:3:28 26 // eval as function (http://pub.dartlang.org/stuff.dart.js:560:28), efn:3:28
27 // eval as function (http://pub.dartlang.org/stuff.dart.js:560:28) 27 // eval as function (http://pub.dartlang.org/stuff.dart.js:560:28)
28 // eval as function (eval as otherFunction 28 // eval as function (eval as otherFunction
29 // (http://pub.dartlang.org/stuff.dart.js:560:28)) 29 // (http://pub.dartlang.org/stuff.dart.js:560:28))
30 final _v8EvalLocation = new RegExp( 30 final _v8EvalLocation = new RegExp(
31 r'^eval at (?:[^\s].*?) \((.*)\)(?:, .*?:\d+:\d+)?$'); 31 r'^eval at (?:\S.*?) \((.*)\)(?:, .*?:\d+:\d+)?$');
32 32
33 // foo$bar$0@http://pub.dartlang.org/stuff.dart.js:560:28 33 // foo$bar$0@http://pub.dartlang.org/stuff.dart.js:560:28
34 // http://pub.dartlang.org/stuff.dart.js:560:28 34 // http://pub.dartlang.org/stuff.dart.js:560:28
35 final _safariFrame = new RegExp(r"^(?:([0-9A-Za-z_$]*)@)?(.*):(\d*):(\d*)$"); 35 final _safariFrame = new RegExp(r"^(?:([0-9A-Za-z_$]*)@)?(.*):(\d*):(\d*)$");
36 36
37 // .VW.call$0@http://pub.dartlang.org/stuff.dart.js:560 37 // .VW.call$0@http://pub.dartlang.org/stuff.dart.js:560
38 // .VW.call$0("arg")@http://pub.dartlang.org/stuff.dart.js:560 38 // .VW.call$0("arg")@http://pub.dartlang.org/stuff.dart.js:560
39 // .VW.call$0/name<@http://pub.dartlang.org/stuff.dart.js:560 39 // .VW.call$0/name<@http://pub.dartlang.org/stuff.dart.js:560
40 final _firefoxFrame = new RegExp( 40 final _firefoxFrame = new RegExp(
41 r'^([^@(/]*)(?:\(.*\))?((?:/[^/]*)*)(?:\(.*\))?@(.*):(\d+)$'); 41 r'^([^@(/]*)(?:\(.*\))?((?:/[^/]*)*)(?:\(.*\))?@(.*):(\d+)$');
42 42
43 // foo/bar.dart 10:11 in Foo._bar 43 // foo/bar.dart 10:11 in Foo._bar
44 // http://dartlang.org/foo/bar.dart in Foo._bar 44 // http://dartlang.org/foo/bar.dart in Foo._bar
45 final _friendlyFrame = new RegExp( 45 final _friendlyFrame = new RegExp(
46 r'^([^\s]+)(?: (\d+)(?::(\d+))?)?\s+([^\d][^\s]*)$'); 46 r'^(\S+)(?: (\d+)(?::(\d+))?)?\s+([^\d]\S*)$');
47 47
48 final _initialDot = new RegExp(r"^\."); 48 final _initialDot = new RegExp(r"^\.");
49 49
50 /// A single stack frame. Each frame points to a precise location in Dart code. 50 /// A single stack frame. Each frame points to a precise location in Dart code.
51 class Frame { 51 class Frame {
52 /// The URI of the file in which the code is located. 52 /// The URI of the file in which the code is located.
53 /// 53 ///
54 /// This URI will usually have the scheme `dart`, `file`, `http`, or `https`. 54 /// This URI will usually have the scheme `dart`, `file`, `http`, or `https`.
55 final Uri uri; 55 final Uri uri;
56 56
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 factory Frame.parseV8(String frame) { 147 factory Frame.parseV8(String frame) {
148 var match = _v8Frame.firstMatch(frame); 148 var match = _v8Frame.firstMatch(frame);
149 if (match == null) { 149 if (match == null) {
150 throw new FormatException("Couldn't parse V8 stack trace line '$frame'."); 150 throw new FormatException("Couldn't parse V8 stack trace line '$frame'.");
151 } 151 }
152 152
153 // v8 location strings can be arbitrarily-nested, since it adds a layer of 153 // v8 location strings can be arbitrarily-nested, since it adds a layer of
154 // nesting for each eval performed on that line. 154 // nesting for each eval performed on that line.
155 parseLocation(location, member) { 155 parseLocation(location, member) {
156 var evalMatch = _v8EvalLocation.firstMatch(location); 156 var evalMatch = _v8EvalLocation.firstMatch(location);
157 if (evalMatch != null) return parseLocation(evalMatch[1], member); 157 while (evalMatch != null) {
158 158 location = evalMatch[1];
159 evalMatch = _v8EvalLocation.firstMatch(location);
160 }
159 161
160 var urlMatch = _v8UrlLocation.firstMatch(location); 162 var urlMatch = _v8UrlLocation.firstMatch(location);
161 if (urlMatch == null) { 163 if (urlMatch == null) {
162 throw new FormatException( 164 throw new FormatException(
163 "Couldn't parse V8 stack trace line '$frame'."); 165 "Couldn't parse V8 stack trace line '$frame'.");
164 } 166 }
165 167
166 return new Frame( 168 return new Frame(
167 _uriOrPathToUri(urlMatch[1]), 169 _uriOrPathToUri(urlMatch[1]),
168 int.parse(urlMatch[2]), 170 int.parse(urlMatch[2]),
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // their stack frames. However, if we do get a relative path, we should 273 // their stack frames. However, if we do get a relative path, we should
272 // handle it gracefully. 274 // handle it gracefully.
273 if (uriOrPath.contains('\\')) return path.windows.toUri(uriOrPath); 275 if (uriOrPath.contains('\\')) return path.windows.toUri(uriOrPath);
274 return Uri.parse(uriOrPath); 276 return Uri.parse(uriOrPath);
275 } 277 }
276 278
277 Frame(this.uri, this.line, this.column, this.member); 279 Frame(this.uri, this.line, this.column, this.member);
278 280
279 String toString() => '$location in $member'; 281 String toString() => '$location in $member';
280 } 282 }
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