Skip to content

Commit

Permalink
Handle whitespace in member names in V8 parser, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
osa1 committed Sep 18, 2024
1 parent 357e011 commit 817b966
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/frame.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final _v8JsUrlLocation = RegExp(r'^(.*?):(\d+)(?::(\d+))?$|native$');
// - "uri": `wasm://wasm/0006d966`.
// - "index": `119`.
// - "offset": (hex number) `bb13`.
final _v8WasmFrame = RegExp(r'^\s*at (?:(?<member>\S+) )?'
final _v8WasmFrame = RegExp(r'^\s*at (?:(?<member>.+) )?'
r'(?:\(?(?:(?<uri>wasm:\S+):wasm-function\[(?<index>\d+)\]'
r'\:0x(?<offset>[0-9 a-f A-F]+))\)?)$');

Expand Down
27 changes: 27 additions & 0 deletions test/frame_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,15 @@ baz@https://pub.dev/buz.js:56355:55
expect(frame.member, 'Error._throwWithCurrentStackTrace');
});

test('parses a V8 Wasm frame with a name with spaces', () {
var frame = Frame.parseV8(' at main tear-off trampoline '
'(wasm://wasm/0017fbea:wasm-function[863]:0x23cc8)');
expect(frame.uri, Uri.parse('wasm://wasm/0017fbea'));
expect(frame.line, 0);
expect(frame.column, 0x23cc8);
expect(frame.member, 'main tear-off trampoline');
});

test('parses a V8 Wasm frame without a name', () {
var frame =
Frame.parseV8(' at wasm://wasm/0006d966:wasm-function[119]:0xbb13');
Expand All @@ -660,6 +669,15 @@ baz@https://pub.dev/buz.js:56355:55
expect(frame.member, 'g');
});

test('parses a Firefox Wasm frame with a name with spaces', () {
var frame = Frame.parseFirefox(
'main tear-off trampoline@http://localhost:8080/test.wasm:wasm-function[794]:0x14387');
expect(frame.uri, Uri.parse('http://localhost:8080/test.wasm'));
expect(frame.line, 0);
expect(frame.column, 0x14387);
expect(frame.member, 'main tear-off trampoline');
});

test('parses a Firefox Wasm frame without a name', () {
var frame = Frame.parseFirefox(
'@http://localhost:8080/test.wasm:wasm-function[796]:0x143b4');
Expand All @@ -677,6 +695,15 @@ baz@https://pub.dev/buz.js:56355:55
expect(frame.member, 'g');
});

test('parses a Safari Wasm frame with a name', () {
var frame = Frame.parseSafari(
'<?>.wasm-function[main tear-off trampoline]@[wasm code]');
expect(frame.uri, Uri.parse('wasm code'));
expect(frame.line, null);
expect(frame.column, null);
expect(frame.member, 'main tear-off trampoline');
});

test('parses a Safari Wasm frame without a name', () {
var frame = Frame.parseSafari('<?>.wasm-function[796]@[wasm code]');
expect(frame.uri, Uri.parse('wasm code'));
Expand Down

0 comments on commit 817b966

Please sign in to comment.