Skip to content

Commit 170d85d

Browse files
kjkclaude
andcommitted
pdb: Fix isPureVirtualMethod to recognize PureIntroducingVirtual
Port of getsentry/pdb#135. Add FieldAttributes helper functions (isStaticMethod, isVirtualMethod, isPureVirtualMethod, isIntroVirtualMethod) matching the Rust FieldAttributes methods. isPureVirtualMethod correctly returns true for both PureVirtual and PureIntroducingVirtual method kinds. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c25084f commit 170d85d

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

pdb/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ export {
9595
CallingConvention,
9696
PointerKind,
9797
PointerMode,
98+
isStaticMethod,
99+
isVirtualMethod,
100+
isPureVirtualMethod,
101+
isIntroVirtualMethod,
98102
} from "./tpi/types.js";
99103
export type { RawItem, TypeInformation } from "./tpi/parser.js";
100104
export { ItemFinder } from "./tpi/parser.js";

pdb/src/tpi/parser.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import type {
1313
import {
1414
parseTypeProperties,
1515
parseFieldAttributes,
16+
isIntroVirtualMethod,
1617
parsePointerAttributes,
1718
parseFunctionAttributes,
1819
PointerMode,
19-
MethodKind,
2020
} from "./types.js";
2121

2222
/** Header of the TPI/IPI stream. */
@@ -361,8 +361,7 @@ function parseTypeRecord(buf: ParseBuffer, kind: number): TypeData {
361361
const methodType: TypeIndex = buf.readU32();
362362
let vtableOffset: number | null = null;
363363
if (
364-
attributes.mprop === MethodKind.IntroducingVirtual ||
365-
attributes.mprop === MethodKind.PureIntroducingVirtual
364+
isIntroVirtualMethod(attributes)
366365
) {
367366
vtableOffset = buf.readU32();
368367
}
@@ -465,10 +464,7 @@ function parseFieldRecord(buf: ParseBuffer, kind: number): TypeData | null {
465464
const attributes = parseFieldAttributes(attrRaw);
466465
const methodType: TypeIndex = buf.readU32();
467466
let vtableOffset: number | null = null;
468-
if (
469-
attributes.mprop === MethodKind.IntroducingVirtual ||
470-
attributes.mprop === MethodKind.PureIntroducingVirtual
471-
) {
467+
if (isIntroVirtualMethod(attributes)) {
472468
vtableOffset = buf.readU32();
473469
}
474470
const name = readTypeName(buf, kind);

pdb/src/tpi/types.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ export function parseFieldAttributes(raw: number): FieldAttributes {
7676
};
7777
}
7878

79+
/** Returns true if the method is static. */
80+
export function isStaticMethod(attr: FieldAttributes): boolean {
81+
return attr.mprop === MethodKind.Static;
82+
}
83+
84+
/** Returns true if the method is virtual. */
85+
export function isVirtualMethod(attr: FieldAttributes): boolean {
86+
return attr.mprop === MethodKind.Virtual;
87+
}
88+
89+
/** Returns true if the method is pure virtual (includes pure introducing virtual). */
90+
export function isPureVirtualMethod(attr: FieldAttributes): boolean {
91+
return attr.mprop === MethodKind.PureVirtual ||
92+
attr.mprop === MethodKind.PureIntroducingVirtual;
93+
}
94+
95+
/** Returns true if the method is an introducing virtual (includes pure introducing virtual). */
96+
export function isIntroVirtualMethod(attr: FieldAttributes): boolean {
97+
return attr.mprop === MethodKind.IntroducingVirtual ||
98+
attr.mprop === MethodKind.PureIntroducingVirtual;
99+
}
100+
79101
/** The kind of a PointerType. */
80102
export enum PointerKind {
81103
Near16 = 0x00,

0 commit comments

Comments
 (0)