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
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@
],
"type": "node"
},
{
"name": "Start: addon:windows",
"request": "launch",
"runtimeArgs": [
"run-script",
"start:addon:windows",
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{
"name": "Test",
"request": "launch",
Expand All @@ -109,5 +122,6 @@
],
"type": "node"
},

]
}
47 changes: 33 additions & 14 deletions bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
argDefinitions,
usageDefinitions,
} from './command-line-definitions';
import firstline from 'firstline';
import type { dumpSyms } from 'node-dump-syms';

(async () => {
let {
Expand All @@ -36,7 +38,7 @@ import {
remove,
files,
directory,
dumpSyms,
dumpSyms: shouldRunDumpSyms,
} = await getCommandLineOptions(argDefinitions);

if (help) {
Expand Down Expand Up @@ -110,18 +112,18 @@ import {

const globPattern = `${directory}/${files}`;

let symbolFilePaths = await glob(globPattern);
let foundFilePaths = await glob(globPattern);

if (!symbolFilePaths.length) {
if (!foundFilePaths.length) {
throw new Error(
`Could not find any files to upload using glob ${globPattern}!`
);
}

console.log(`Found files:\n ${symbolFilePaths.join('\n')}`);
console.log(`Found files:\n ${foundFilePaths.join('\n')}`);

if (dumpSyms) {
let nodeDumpSyms;
if (shouldRunDumpSyms) {
let nodeDumpSyms: typeof dumpSyms;

try {
nodeDumpSyms = (await importNodeDumpSyms()).dumpSyms;
Expand All @@ -132,21 +134,19 @@ import {
);
}

symbolFilePaths = symbolFilePaths.map((file) => {
console.log(`Dumping syms for ${file}...`);
const symFile = join(tmpDir, randomUUID(), getNormalizedSymFileName(basename(file)));
mkdirSync(dirname(symFile), { recursive: true });
nodeDumpSyms(file, symFile);
return symFile;
});
const newSymFilePaths: Array<string> = [];

for (const file of foundFilePaths) {
newSymFilePaths.push(await runDumpSyms(nodeDumpSyms, file));
}
}

await uploadSymbolFiles(
bugsplat,
database,
application,
version,
symbolFilePaths
foundFilePaths
);
await safeRemoveTmp();
process.exit(0);
Expand Down Expand Up @@ -235,6 +235,25 @@ function normalizeDirectory(directory: string): string {
return directory.replace(/\\/g, '/');
}

async function runDumpSyms(
nodeDumpSyms: typeof dumpSyms,
inputFilePath: string
) {
console.log(`Dumping syms for ${inputFilePath}...`);

const uuid = randomUUID();
const tmpSymFile = join(tmpDir, randomUUID(), `${uuid}.sym`);

mkdirSync(dirname(tmpSymFile), { recursive: true });
nodeDumpSyms(inputFilePath, tmpSymFile);

const symFirstLine = await firstline(tmpSymFile);
const moduleName = 'todo bg';
const outputFilePath = 'todo bg';

return outputFilePath;
}

function validAuthenticationArguments({
user,
password,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"start:dump_syms": "ts-node -r dotenv/config ./bin/index.ts -d ./spec -f \"**/*.dSYM\" -m",
"start:dump_syms_invalid": "ts-node -r dotenv/config ./bin/index.ts -d ./spec -f \"**/myQtCrasher.vc.pdb\" -m",
"start:symsrv": "ts-node -r dotenv/config ./bin/index.ts -d ./spec -f \"**/*.dll\"",
"start:addon:windows": "ts-node -r dotenv/config ./bin/index.ts -d ./spec -f \"**/addon-windows.node\" -m",
"test": "ts-node node_modules/jasmine/bin/jasmine",
"help": "ts-node ./bin/index.ts -h",
"clean": "rimraf ./dist",
Expand Down
Binary file added spec/support/addon-macos.node
Binary file not shown.
Binary file added spec/support/addon-windows.node
Binary file not shown.
16 changes: 16 additions & 0 deletions spec/sym.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ describe('sym', () => {
expect(normalizedSymModuleName).toBe(expected);
});

it('should get normalized sym module name for file with .node extension', () => {
const expected = 'liba.node';

const normalizedSymModuleName = getNormalizedSymModuleName('liba.node');

expect(normalizedSymModuleName).toBe(expected);
});

it('should get normalized sym module name for file with .so extension', () => {
const expected = 'liba.so';

Expand Down Expand Up @@ -126,6 +134,14 @@ describe('sym', () => {
expect(normalizedSymFileName).toBe(expected);
});

it('should get normalized sym file name for file with .node extension', () => {
const expected = 'liba.node.sym';

const normalizedSymFileName = getNormalizedSymFileName('liba.node');

expect(normalizedSymFileName).toBe(expected);
});

it('should get normalized sym file name for file with .so extension', () => {
const expected = 'liba.so.sym';

Expand Down
11 changes: 5 additions & 6 deletions src/sym.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

export async function getSymFileInfo(
path: string
): Promise<{ dbgId: string; moduleName: string }> {
): Promise<{ dbgId: string; moduleName: string, fileName: string }> {
try {
const firstLine = await firstline(path);
const matches = Array.from(
Expand All @@ -12,13 +12,13 @@
const dbgId = matches?.at(0)?.at(1) || '';
const moduleNameWithExt = matches?.at(0)?.at(2) || '';
const moduleName = getNormalizedSymModuleName(moduleNameWithExt);
return {

Check failure on line 15 in src/sym.ts

View workflow job for this annotation

GitHub Actions / test

Property 'fileName' is missing in type '{ dbgId: string; moduleName: string; }' but required in type '{ dbgId: string; moduleName: string; fileName: string; }'.
dbgId,
moduleName,
};
} catch {
console.log(`Could not get first line for ${path}, skipping...`);
return {

Check failure on line 21 in src/sym.ts

View workflow job for this annotation

GitHub Actions / test

Property 'fileName' is missing in type '{ dbgId: string; moduleName: string; }' but required in type '{ dbgId: string; moduleName: string; fileName: string; }'.
dbgId: '',
moduleName: '',
};
Expand All @@ -38,8 +38,8 @@
}
}

// We've seen .pdb, .so, .so.0, and .so.6 in the module lookup, leave them alone
const ignoredExtensions = [/\.pdb$/gm, /\.so\.?.*$/gm, /\.dylib$/gm];
// We've seen .node, .pdb, .so, .so.0, and .so.6 in the module lookup, leave them alone
const ignoredExtensions = [/\.node$/gm, /\.pdb$/gm, /\.so\.?.*$/gm, /\.dylib$/gm];
if (ignoredExtensions.some((regex) => regex.test(moduleName))) {
return moduleName;
}
Expand All @@ -57,7 +57,6 @@
// This is a bit of a mystery and is subject to change when we learn more about how it works.
// For now, normalize some sym file names to satisfy the minidump-stackwalker symbol lookup.
// When building the path, the pattern is module/GUID/file.sym

export function getNormalizedSymFileName(path: string): string {
let normalizedFileName = basename(path);

Expand All @@ -69,8 +68,8 @@
}
}

// We've seen .dylib.sym, .so.sym, .so.0.sym, and .so.6.sym in the sym file lookup, leave them alone
const ignoredExtensions = [/\.dylib$/gm, /\.so\.?.*$/gm];
// We've seen .node.sym, .dylib.sym, .so.sym, .so.0.sym, and .so.6.sym in the sym file lookup, leave them alone
const ignoredExtensions = [/\.node$/gm, /\.dylib$/gm, /\.so\.?.*$/gm];
if (ignoredExtensions.some((regex) => regex.test(normalizedFileName))) {
return `${normalizedFileName}.sym`;
}
Expand Down
Loading