Add parse-crash-reports script
This commit is contained in:
parent
bd562eeab8
commit
96e63964b9
4 changed files with 130 additions and 2 deletions
|
@ -200,6 +200,7 @@
|
|||
"@babel/preset-typescript": "7.23.0",
|
||||
"@electron/fuses": "1.5.0",
|
||||
"@electron/notarize": "2.1.0",
|
||||
"@electron/symbolicate-mac": "2.0.2",
|
||||
"@formatjs/intl": "2.6.7",
|
||||
"@indutny/rezip-electron": "1.3.1",
|
||||
"@mixer/parallel-prettier": "2.0.3",
|
||||
|
|
103
ts/scripts/symbolicate-crash-report.ts
Normal file
103
ts/scripts/symbolicate-crash-report.ts
Normal file
|
@ -0,0 +1,103 @@
|
|||
// Copyright 2024 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { tmpdir } from 'os';
|
||||
import { readFile, writeFile, mkdtemp } from 'fs/promises';
|
||||
import { gunzip as gunzipCb } from 'zlib';
|
||||
import { join, basename } from 'path';
|
||||
import { promisify } from 'util';
|
||||
import { symbolicate } from '@electron/symbolicate-mac';
|
||||
import pMap from 'p-map';
|
||||
|
||||
const gunzip = promisify(gunzipCb);
|
||||
|
||||
const INPUT_FILE = process.argv[2];
|
||||
|
||||
if (!INPUT_FILE) {
|
||||
throw new Error('Usage: node symbolicate-crash-report.js <input>');
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
let file = await readFile(INPUT_FILE);
|
||||
try {
|
||||
file = await gunzip(file);
|
||||
} catch (error) {
|
||||
console.error('Failed to decompress, perhaps file is a plaintext?');
|
||||
}
|
||||
|
||||
const matches = file
|
||||
.toString()
|
||||
.matchAll(
|
||||
/WARN[^\n]*crashReports:\s+dump=\[REDACTED\]([0-9a-z]+).dmp\s+mtime="([\d\-T:.Z]+)"\s+({(\n|.)*?\n})/g
|
||||
);
|
||||
|
||||
function moduleName(filename: string | undefined): string {
|
||||
if (!filename) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (filename.startsWith('signal-desktop-')) {
|
||||
return 'electron';
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
const dumps = new Array<string>();
|
||||
for (const [, dump, mtime, json] of matches) {
|
||||
const out = [];
|
||||
|
||||
let info;
|
||||
try {
|
||||
info = JSON.parse(json);
|
||||
} catch (error) {
|
||||
console.error('Failed to parse JSON, ignoring', dump, mtime, error);
|
||||
continue;
|
||||
}
|
||||
|
||||
out.push(`## dump=${dump} mtime=${mtime}`);
|
||||
out.push('');
|
||||
out.push('```');
|
||||
|
||||
for (const [index, frame] of info.crashing_thread.frames.entries()) {
|
||||
out.push(`${index} ${moduleName(frame.module)} ${frame.offset} () + 0`);
|
||||
}
|
||||
|
||||
out.push('');
|
||||
|
||||
for (const m of info.modules) {
|
||||
const filename = moduleName(m.filename);
|
||||
|
||||
out.push(
|
||||
`${m.base_addr} - ${m.end_addr} ` +
|
||||
`${filename.replace(/\s+/g, '-')} (${m.version}) ` +
|
||||
`<${m.debug_id.slice(0, -1)}> ${filename}`
|
||||
);
|
||||
}
|
||||
out.push('```');
|
||||
|
||||
dumps.push(out.join('\n'));
|
||||
}
|
||||
|
||||
const tmpFolder = await mkdtemp(join(tmpdir(), 'parse-crash-reports'));
|
||||
|
||||
const result = await pMap(
|
||||
dumps,
|
||||
async (text, i) => {
|
||||
const tmpFile = join(tmpFolder, `${i}.txt`);
|
||||
await writeFile(tmpFile, text);
|
||||
|
||||
console.error(`Symbolicating: ${tmpFile}`);
|
||||
return symbolicate({ file: tmpFile });
|
||||
},
|
||||
{ concurrency: 1 }
|
||||
);
|
||||
|
||||
console.log(`# Crash Report ${basename(INPUT_FILE)}`);
|
||||
console.log('');
|
||||
console.log(result.join('\n'));
|
||||
}
|
||||
|
||||
main().catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
9
ts/scripts/symbolicate-mac.d.ts
vendored
Normal file
9
ts/scripts/symbolicate-mac.d.ts
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Copyright 2024 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
declare module '@electron/symbolicate-mac' {
|
||||
export function symbolicate(options: {
|
||||
file: string;
|
||||
force?: boolean;
|
||||
}): Promise<string>;
|
||||
}
|
19
yarn.lock
19
yarn.lock
|
@ -1359,6 +1359,16 @@
|
|||
minimist "^1.2.6"
|
||||
plist "^3.0.5"
|
||||
|
||||
"@electron/symbolicate-mac@2.0.2":
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@electron/symbolicate-mac/-/symbolicate-mac-2.0.2.tgz#e3df3a62d3d48444c97f251fdd5cede1bfeef546"
|
||||
integrity sha512-ysQQk1XrTILQXCoi7l4pa3J8qA5RMfcRNjow1tFdZGEwmV6FK6X3hpGbo94Gsv4z+6m+gTspdrVANFbpT2Tx2w==
|
||||
dependencies:
|
||||
got "^11.8.2"
|
||||
mkdirp "^1.0.4"
|
||||
parse-breakpad "^0.1.0"
|
||||
yargs "^17.0.1"
|
||||
|
||||
"@electron/universal@1.3.4":
|
||||
version "1.3.4"
|
||||
resolved "https://registry.yarnpkg.com/@electron/universal/-/universal-1.3.4.tgz#bccd94b635d7c85eeed5eabba457eb4ed2be2777"
|
||||
|
@ -11143,7 +11153,7 @@ got@11.8.5:
|
|||
p-cancelable "^2.0.0"
|
||||
responselike "^2.0.0"
|
||||
|
||||
got@^11.8.5:
|
||||
got@^11.8.2, got@^11.8.5:
|
||||
version "11.8.6"
|
||||
resolved "https://registry.yarnpkg.com/got/-/got-11.8.6.tgz#276e827ead8772eddbcfc97170590b841823233a"
|
||||
integrity sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==
|
||||
|
@ -15527,6 +15537,11 @@ parent-module@^1.0.0:
|
|||
dependencies:
|
||||
callsites "^3.0.0"
|
||||
|
||||
parse-breakpad@^0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/parse-breakpad/-/parse-breakpad-0.1.0.tgz#6d3c80c856d35550b6adea374b93ec41d758ee8b"
|
||||
integrity sha512-xF9F9+LnMzPhXZSExrvyhzormvlR0Co9LJ9Un8SPDMiMNm3PqIwfYiB4UcqG50yc9g42H2Fndpx/5gfNqdgowQ==
|
||||
|
||||
parse-diff@^0.7.0:
|
||||
version "0.7.1"
|
||||
resolved "https://registry.yarnpkg.com/parse-diff/-/parse-diff-0.7.1.tgz#9b7a2451c3725baf2c87c831ba192d40ee2237d4"
|
||||
|
@ -20296,7 +20311,7 @@ yargs@^15.0.2:
|
|||
y18n "^4.0.0"
|
||||
yargs-parser "^18.1.2"
|
||||
|
||||
yargs@^17.3.1, yargs@^17.6.2, yargs@^17.7.2:
|
||||
yargs@^17.0.1, yargs@^17.3.1, yargs@^17.6.2, yargs@^17.7.2:
|
||||
version "17.7.2"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269"
|
||||
integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==
|
||||
|
|
Loading…
Reference in a new issue