Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(gpu): accept percent-prefixed PTX entry names
morluto2dfcc6463b87
diff --git a/src/gpu/PtxKernels.ts b/src/gpu/PtxKernels.tsindex 0acac9a03..008f52942 100644--- a/src/gpu/PtxKernels.ts+++ b/src/gpu/PtxKernels.ts@@ -75,11 +75,11 @@ const sizeOf = (type: string | undefined): number | null => {const match = /^\.(?:b|u|s|f)(8|16|32|64|128)$/u.exec(type ?? "");return match === null ? null : Number(match[1]) / 8;};+const identifier = /^%?[A-Za-z_$][\w$@.]*$/u;/** Stream register names/ranges without retaining the declaration token list. */const registerDeclaration = (next: () => Token,): { type: string; count: number | null } => {- const identifier = /^%?[A-Za-z_$][\w$@.]*$/u;let type = "";let t = next();while (!identifier.test(t.value)) {@@ -146,9 +146,7 @@ const declaration = (unit = sizeOf(scalar),candidate = values[at++];const name =- candidate !== undefined && /^[A-Za-z_$][\w$@.]*$/u.test(candidate)- ? candidate- : null;+ candidate !== undefined && identifier.test(candidate) ? candidate : null;let size = unit === null ? null : unit * vector;const type =scalar === undefined@@ -211,7 +209,7 @@ export function* readPtxKernels(}if (outerDepth !== 0 || token.value !== ".entry") continue;const name = next();- if (!/^[A-Za-z_$][\w$@.]*$/u.test(name.value))+ if (!identifier.test(name.value))rejectGpu("Malformed PTX entry name or parameters");const parameters: GpuKernel["parameters"] = [];let part: string[] = [],diff --git a/tests/acceptance/gpuCodeObjectsCli.test.ts b/tests/acceptance/gpuCodeObjectsCli.test.tsindex 088a683ff..1579d6ad0 100644--- a/tests/acceptance/gpuCodeObjectsCli.test.ts+++ b/tests/acceptance/gpuCodeObjectsCli.test.ts@@ -63,6 +63,54 @@ cliTest(},);+cliTest(+ "preserves PTX target spelling and percent-prefixed entry names",+ async ({ cli }) => {+ const root = await createTestTempDirectory("rea-ptx-identifiers-cli-");+ const text = `.version 8.8\n.target sm_80\n.address_size 64\n.entry %kernel(.param .u32 input) {\nret;\n}\n`;+ const path = join(root, "identifiers.ptx");+ await writeFile(path, text);+ const response = await cli.run({+ arguments: [+ "inspect-gpu-code-objects",+ path,+ "--analysis",+ "kernels",+ "--detail",+ "complete",+ "--json",+ ],+ });+ expect(response.exitCode, response.stderr).toBe(0);+ const evidence = parseEvidence(+ toolContract("inspect_gpu_code_objects").outputSchema.parse(+ response.json,+ ),+ );+ const report = gpuCodeObjectsSchema.parse(evidence.normalized_result);+ expect(report.objects[0]!.target).toBe("sm_80");+ expect(report.kernels).toEqual([+ expect.objectContaining({+ name: "%kernel",+ parameter_count: 1,+ parameter_bytes: 4,+ parameters: [+ expect.objectContaining({+ ordinal: 0,+ name: "input",+ offset: 0,+ size: 4,+ type: ".u32",+ }),+ ],+ }),+ ]);+ expect(report.ptx_artifacts[0]!.sha256).toBe(+ createHash("sha256").update(text).digest("hex"),+ );+ },+);+cliTest("attributes malformed selector JSON to its actual CLI option",async ({ cli }) => {