From e4995a49d3ce34a6916c2cd834a7873083a09c20 Mon Sep 17 00:00:00 2001 From: Bobby Galli Date: Mon, 15 Apr 2024 23:49:45 -0400 Subject: [PATCH] fix: sym file lookup (#107) * fix: sym file lookup * fix: shared object matching bug --- bin/index.ts | 11 +++++++++-- spec/sym.spec.ts | 2 +- src/sym.ts | 14 +++++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/bin/index.ts b/bin/index.ts index f0e5ce6..2f74932 100644 --- a/bin/index.ts +++ b/bin/index.ts @@ -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; }); @@ -179,6 +178,14 @@ async function getCommandLineOptions(argDefinitions: Array { }); it('should get module name for file with line feeds', async () => { - const expected = 'libc++_shared'; + const expected = 'libc++_shared.so'; const { moduleName } = await getSymFileInfo('./spec/support/android.sym'); diff --git a/src/sym.ts b/src/sym.ts index f097651..ab996a3 100644 --- a/src/sym.ts +++ b/src/sym.ts @@ -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 @@ -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]; } \ No newline at end of file