Skip to content

Commit

Permalink
Properly parse native-code V8 frames.
Browse files Browse the repository at this point in the history
Fixes dart-lang/test#316.

R=rnystrom@google.com

Review URL: https://codereview.chromium.org//1288573002 .
  • Loading branch information
nex3 committed Aug 12, 2015
1 parent 761540c commit 9985476
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.pub/
build/
packages
.packages

# Or the files created by dart2js.
*.dart.js
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.3.6

* Properly parse native-code V8 frames.

## 1.3.5

* Properly shorten library names for pathnames of folded frames on Windows.
Expand Down
7 changes: 6 additions & 1 deletion lib/src/frame.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'trace.dart';
// #1 Foo._bar (file:///home/nweiz/code/stuff.dart)
final _vmFrame = new RegExp(r'^#\d+\s+(\S.*) \((.+?)((?::\d+){0,2})\)$');

// at Object.stringify (native)
// 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)
Expand All @@ -21,7 +22,7 @@ final _v8Frame = new RegExp(
r'^\s*at (?:(\S.*?)(?: \[as [^\]]+\])? \((.*)\)|(.*))$');

// http://pub.dartlang.org/stuff.dart.js:560:28
final _v8UrlLocation = new RegExp(r'^(.*):(\d+):(\d+)$');
final _v8UrlLocation = new RegExp(r'^(.*):(\d+):(\d+)|native$');

// 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)
Expand Down Expand Up @@ -166,6 +167,10 @@ class Frame {
evalMatch = _v8EvalLocation.firstMatch(location);
}

if (location == 'native') {
return new Frame(Uri.parse('native'), null, null, member);
}

var urlMatch = _v8UrlLocation.firstMatch(location);
if (urlMatch == null) {
throw new FormatException(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: stack_trace
#
# When the major version is upgraded, you *must* update that version constraint
# in pub to stay in sync with this.
version: 1.3.5
version: 1.3.6-dev
author: "Dart Team <misc@dartlang.org>"
homepage: http://github.com/dart-lang/stack_trace
description: >
Expand Down
9 changes: 9 additions & 0 deletions test/frame_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ void main() {
expect(frame.member, equals('<fn>'));
});

test('parses a native stack frame correctly', () {
var frame = new Frame.parseV8(
" at Object.stringify (native)");
expect(frame.uri, Uri.parse('native'));
expect(frame.line, isNull);
expect(frame.column, isNull);
expect(frame.member, equals('Object.stringify'));
});

test('parses a stack frame with [as ...] correctly', () {
// Ignore "[as ...]", since other stack trace formats don't support a
// similar construct.
Expand Down

0 comments on commit 9985476

Please sign in to comment.