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

Unified Diff: pkg/stack_trace/lib/src/frame.dart

Issue 130443002: Properly parse V8 lines involving eval in pkg/stack_trace. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/stack_trace/test/frame_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/stack_trace/lib/src/frame.dart
diff --git a/pkg/stack_trace/lib/src/frame.dart b/pkg/stack_trace/lib/src/frame.dart
index 74aafcda319f767b59f0ad4dec4552d965115a54..8544c786fe33f56ca2504acd045f98f52d61ee30 100644
--- a/pkg/stack_trace/lib/src/frame.dart
+++ b/pkg/stack_trace/lib/src/frame.dart
@@ -14,13 +14,24 @@ final _vmFrame = new RegExp(
r'^#\d+\s+([^\s].*) \((.+?):(\d+)(?::(\d+))?\)$');
// at VW.call$0 (http://pub.dartlang.org/stuff.dart.js:560:28)
+// at VW.call$0 (eval as fn
+// (http://pub.dartlang.org/stuff.dart.js:560:28), efn:3:28)
// at http://pub.dartlang.org/stuff.dart.js:560:28
final _v8Frame = new RegExp(
- r'^\s*at (?:([^\s].*?)(?: \[as [^\]]+\])? '
- r'\((.+):(\d+):(\d+)\)|(.+):(\d+):(\d+))$');
+ r'^\s*at (?:([^\s].*?)(?: \[as [^\]]+\])? \((.*)\)|(.*))$');
Bob Nystrom 2014/01/09 17:22:00 You can use "\S" instead of "[^\s]", I think. Here
nweiz 2014/01/09 21:12:35 Done.
-/// foo$bar$0@http://pub.dartlang.org/stuff.dart.js:560:28
-/// http://pub.dartlang.org/stuff.dart.js:560:28
+// http://pub.dartlang.org/stuff.dart.js:560:28
+final _v8UrlLocation = new RegExp(r'^(.*):(\d+):(\d+)$');
+
+// eval as function (http://pub.dartlang.org/stuff.dart.js:560:28), efn:3:28
+// eval as function (http://pub.dartlang.org/stuff.dart.js:560:28)
+// eval as function (eval as otherFunction
+// (http://pub.dartlang.org/stuff.dart.js:560:28))
+final _v8EvalLocation = new RegExp(
+ r'^eval at (?:[^\s].*?) \((.*)\)(?:, .*?:\d+:\d+)?$');
+
+// foo$bar$0@http://pub.dartlang.org/stuff.dart.js:560:28
+// http://pub.dartlang.org/stuff.dart.js:560:28
final _safariFrame = new RegExp(r"^(?:([0-9A-Za-z_$]*)@)?(.*):(\d*):(\d*)$");
// .VW.call$0@http://pub.dartlang.org/stuff.dart.js:560
@@ -139,20 +150,35 @@ class Frame {
throw new FormatException("Couldn't parse V8 stack trace line '$frame'.");
}
+ // v8 location strings can be arbitrarily-nested, since it adds a layer of
+ // nesting for each eval performed on that line.
+ parseLocation(location, member) {
+ var evalMatch = _v8EvalLocation.firstMatch(location);
+ if (evalMatch != null) return parseLocation(evalMatch[1], member);
Bob Nystrom 2014/01/09 17:22:00 I'd prefer iteration over recursion here.
nweiz 2014/01/09 21:12:35 Done.
+
+
+ var urlMatch = _v8UrlLocation.firstMatch(location);
+ if (urlMatch == null) {
+ throw new FormatException(
+ "Couldn't parse V8 stack trace line '$frame'.");
+ }
+
+ return new Frame(
+ _uriOrPathToUri(urlMatch[1]),
+ int.parse(urlMatch[2]),
+ int.parse(urlMatch[3]),
+ member);
+ }
+
// V8 stack frames can be in two forms.
if (match[2] != null) {
- // The first form looks like " at FUNCTION (PATH:LINE:COL)". PATH is
- // usually an absolute URL, but it can be a path if the stack frame came
- // from d8.
- var uri = _uriOrPathToUri(match[2]);
- var member = match[1].replaceAll("<anonymous>", "<fn>");
- return new Frame(uri, int.parse(match[3]), int.parse(match[4]), member);
+ // The first form looks like " at FUNCTION (LOCATION)".
+ return parseLocation(
+ match[2], match[1].replaceAll("<anonymous>", "<fn>"));
} else {
- // The second form looks like " at PATH:LINE:COL", and is used for
- // anonymous functions. PATH is usually an absolute URL, but it can be a
- // path if the stack frame came from d8.
- var uri = _uriOrPathToUri(match[5]);
- return new Frame(uri, int.parse(match[6]), int.parse(match[7]), "<fn>");
+ // The second form looks like " at LOCATION", and is used for anonymous
+ // functions.
+ return parseLocation(match[3], "<fn>");
}
}
« no previous file with comments | « no previous file | pkg/stack_trace/test/frame_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698