Skip to content

Commit

Permalink
fix: include extension in windows module name (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyg603 authored Apr 14, 2024
1 parent 42d4027 commit cf41a74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion spec/sym.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('getSymFileInfo', () => {
});

it('should get module name for file with line feeds and carriage returns', async () => {
const expected = 'windows';
const expected = 'windows.pdb';

const { moduleName } = await getSymFileInfo('./spec/support/windows.sym');

Expand Down
15 changes: 13 additions & 2 deletions src/sym.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import firstline from "firstline";
export async function getSymFileInfo(path: string): Promise<{ dbgId: string, moduleName: string }> {
try {
const firstLine = await firstline(path);
const matches = Array.from(firstLine?.matchAll(/([0-9a-fA-F]{33,34})\s+([^\.]*).*$/gm));
const matches = Array.from(firstLine?.matchAll(/([0-9a-fA-F]{33,34})\s+(.*)$/gm));
const dbgId = matches?.at(0)?.at(1) || '';
const moduleName = matches?.at(0)?.at(2) || '';
const moduleNameWithExt = matches?.at(0)?.at(2) || '';
const moduleName = removeNonWindowsExtensions(moduleNameWithExt);
return {
dbgId,
moduleName
Expand All @@ -17,4 +18,14 @@ export async function getSymFileInfo(path: string): Promise<{ dbgId: string, mod
moduleName: ''
};
}
}

function removeNonWindowsExtensions(moduleName: string): string {
const windowsExtensions = ['.dll', '.pdb', '.exe'];

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

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

0 comments on commit cf41a74

Please sign in to comment.