Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions packages/metro-symbolicate/src/Symbolication.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class SymbolicationContext<ModuleIdsT> {
// IOS: foo.js:57:foo, Android: bar.js:75:bar
symbolicate(stackTrace: string): string {
return stackTrace.replace(
/(?:([^@: \n(]+)(@|:))?(?:(?:([^@: \n(]+):)?(\d+):(\d+)|\[native code\])/g,
/(?:([^@: \n(]+)(@|:))?(?:(?:([^@: \n(]+):)?(\d+):(\d+)|\[native code\](?::\d+:\d+)?)/g,
(match, func, delimiter, fileName, line, column) => {
if (delimiter === ':' && func && !fileName) {
fileName = func;
Expand Down Expand Up @@ -694,10 +694,25 @@ class SingleMapSymbolicationContext extends SymbolicationContext<SingleMapModule
}
moduleLineOffset = moduleOffsets[localId];
}
const original = metadata.consumer.originalPositionFor({
line: Number(lineNumber) + moduleLineOffset,
column: Number(columnNumber),
});
const line = Number(lineNumber) + moduleLineOffset;
const column = Number(columnNumber);

// Crash reporters normalise frames that have no JS location - native
// frames in particular - to line 0, column 0. `originalPositionFor` throws
// on an out-of-range position, so report these as unresolved instead,
// matching what we already do for a bare `[native code]` frame.
if (line <= 0 || column < 0) {
return {
line: null,
column: null,
source: null,
functionName: null,
name: null,
isIgnored: false,
};
}

const original = metadata.consumer.originalPositionFor({line, column});
if (metadata.sourceFunctionsConsumer) {
original.functionName =
metadata.sourceFunctionsConsumer.functionNameFor(original) || null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Non-fatal Exception: JavaScriptError
0 ??? 0x0 <unknown> (some message with no frame)
1 ??? 0x0 throws6 + 1 (thrower.min.js:1:161)
2 ??? 0x0 o + 1 (thrower.min.js:1:464)
3 ??? 0x0 <unknown> ([native code]:0:0)
4 ??? 0x0 <unknown> ([native code]:0:0)
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ Array [
]
`;

exports[`symbolicating a crash reporter stack trace with 0:0 native frames 1`] = `
"Non-fatal Exception: JavaScriptError
0 ??? 0x0 <unknown> (some message with no frame)
1 ??? 0x0 throws6 + 1 (thrower.js:18:null)
2 ??? 0x0 o + 1 (thrower.js:30:arguments)
3 ??? 0x0 <unknown> (null:null:null)
4 ??? 0x0 <unknown> (null:null:null)
"
`;

exports[`symbolicating a profiler map 1`] = `
"JS_0000_xxxxxxxxxxxxxxxxxxxxxx throws0::thrower.js:48:11
JS_0001_xxxxxxxxxxxxxxxxxxxxxx throws6::thrower.js:35:38
Expand Down
5 changes: 5 additions & 0 deletions packages/metro-symbolicate/src/__tests__/symbolicate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ test('symbolicating a stack trace in Node format', async () =>
execute([TESTFILE_MAP], read('testfile.node.stack')),
).resolves.toMatchSnapshot());

test('symbolicating a crash reporter stack trace with 0:0 native frames', async () =>
await expect(
execute([TESTFILE_MAP], read('testfile.crashreporter.stack')),
).resolves.toMatchSnapshot());

test('symbolicating a single entry', async () =>
await expect(execute([TESTFILE_MAP, '1', '161'])).resolves.toEqual(
'thrower.js:18:null\n',
Expand Down
Loading