Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include extension in windows module name #106

Merged
merged 1 commit into from
Apr 14, 2024
Merged
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
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];
}
Loading