fix(ghidra): preserve function references and snapshot boundaries
Collect references from the complete owned function body and exact entry, including instruction-interior destinations and embedded-data sources. Bind the corrected semantics to the analysis profile so legacy snapshots cannot replay incomplete results. Preserve snapshot mismatch reasons and recovery advice through CLI and MCP without disturbing live sessions. Return exact entry candidates for ambiguous function names. Expand the real-provider regression workflow and replace redundant parser assertions with malformed-output coverage through the pinned MCP client. Verified with Ghidra 12.1.4 on macOS arm64: full host-native lane, real CLI/MCP boundary probes, 30 focused tests, and typecheck/lint.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { jsonValueSchema } from "../../../src/domain/jsonValue.js";
|
||||
import { ok } from "../../../src/domain/result.js";
|
||||
import { ghidraFunctionIdentity } from "../../../src/domain/ghidraValues.fixture.js";
|
||||
import { connectGhidraMcp } from "./ghidraMcpHarness.js";
|
||||
|
||||
it("rejects contradictory provider memory and inventory data before emitting MCP Evidence", async () => {
|
||||
it("rejects contradictory provider output before emitting MCP Evidence", async () => {
|
||||
const bytes = {
|
||||
address: "0x401000",
|
||||
requested_bytes: 4,
|
||||
@@ -57,6 +58,15 @@ it("rejects contradictory provider memory and inventory data before emitting MCP
|
||||
arguments: { pattern: "needle" },
|
||||
output: [{ address: "0x401000" }],
|
||||
},
|
||||
{
|
||||
name: "read_function_instructions",
|
||||
arguments: { procedure: "fixture_main" },
|
||||
output: {
|
||||
procedure: { ...ghidraFunctionIdentity(), address: "0X401000" },
|
||||
instructions: ["0x401000: push rbp"],
|
||||
limitations: ["Ghidra-specific instruction text."],
|
||||
},
|
||||
},
|
||||
];
|
||||
for (const probe of cases) {
|
||||
output = jsonValueSchema.parse(probe.output);
|
||||
|
||||
@@ -17,6 +17,10 @@ __attribute__((noinline, used)) int rea_ghidra_inventory_leaf(int value) {
|
||||
return value + rea_ghidra_inventory_global;
|
||||
}
|
||||
|
||||
// A reference into the function body can land inside an instruction.
|
||||
__attribute__((used)) const unsigned char *volatile rea_ghidra_interior_pointer =
|
||||
(const unsigned char *)(void *)rea_ghidra_inventory_leaf + 1;
|
||||
|
||||
__attribute__((noinline, used)) int rea_ghidra_inventory_branch(int value) {
|
||||
if (value > 10) {
|
||||
return rea_ghidra_inventory_leaf(value);
|
||||
|
||||
Reference in New Issue
Block a user