Skip to content

Commit

Permalink
fix: sym file lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyg603 committed Apr 15, 2024
1 parent 04148ee commit 54f63aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
11 changes: 9 additions & 2 deletions bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ import { CommandLineDefinition, argDefinitions, usageDefinitions } from './comma
const nodeDumpSyms = (await import('node-dump-syms')).dumpSyms;
symbolFilePaths = symbolFilePaths.map(file => {
console.log(`Dumping syms for ${file}...`);
const fileNoExt = file.split('.')[0]; // Handle macos .app.dSYM etc.
const symFile = join(tmpDir, `${basename(fileNoExt)}.sym`);
const symFile = join(tmpDir, `${getSymFileBaseName(file)}.sym`);
nodeDumpSyms(file, symFile);
return symFile;
});
Expand Down Expand Up @@ -179,6 +178,14 @@ async function getCommandLineOptions(argDefinitions: Array<CommandLineDefinition
version
}
}
// The rust-minidump-stackwalker symbol lookup implementation removes some extensions from the sym file name for symbol lookups.
// This is a bit of a mystery and is subject to change when we learn more about how it works.
// For now, remove any non .so extension in the sym file's base name to satisfy the minidump-stackwalker symbol lookup.
function getSymFileBaseName(file: string): string {
const linuxSoExtensionPattern = /\.so\.+.*$/gm;
const fileNoExt = file.split('.')[0];
return linuxSoExtensionPattern.test(file) ? basename(file) : basename(fileNoExt);
}

function logHelpAndExit() {
const help = commandLineUsage(usageDefinitions);
Expand Down
14 changes: 9 additions & 5 deletions src/sym.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export async function getSymFileInfo(path: string): Promise<{ dbgId: string, mod
const matches = Array.from(firstLine?.matchAll(/([0-9a-fA-F]{33,34})\s+(.*)$/gm));
const dbgId = matches?.at(0)?.at(1) || '';
const moduleNameWithExt = matches?.at(0)?.at(2) || '';
const moduleName = removeNonWindowsExtensions(moduleNameWithExt);
const moduleName = removeIgnoredExtensions(moduleNameWithExt);
return {
dbgId,
moduleName
Expand All @@ -20,12 +20,16 @@ export async function getSymFileInfo(path: string): Promise<{ dbgId: string, mod
}
}

function removeNonWindowsExtensions(moduleName: string): string {
const windowsExtensions = ['.dll', '.pdb', '.exe'];
// The rust-minidump-stackwalker symbol lookup implementation removes some extensions from the module name for symbol lookups.
// This is a bit of a mystery and is subject to change when we learn more about how it works.
// For now, remove some module name extensions to satisfy the minidump-stackwalker symbol lookup.
function removeIgnoredExtensions(moduleName: string): string {
// We've seen .pdb, .so, .so.0, and .so.6 in the module lookup
const ignoredExtensions = [/\.pdb$/gm, /\.so\.+.*$/gm];

if (windowsExtensions.some(ext => moduleName.endsWith(ext))) {
if (ignoredExtensions.some((regex) => regex.test(moduleName))) {
return moduleName;
}

return moduleName.split('.')[0];
}

0 comments on commit 54f63aa

Please sign in to comment.