102 lines
3.2 KiB
Python
102 lines
3.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Capture the TurnEvents get/create bridge boundary from the pinned executable."""
|
|
|
|
import hashlib
|
|
import json
|
|
import pathlib
|
|
import subprocess
|
|
|
|
|
|
ROOT = pathlib.Path("/home/alex/sots-re")
|
|
OUT = ROOT / "verify/results/research-live-record-bridge/run-472955e277202c411388c66b"
|
|
EXE = ROOT / "dumps/sots.exe"
|
|
OBJDUMP = pathlib.Path("/usr/bin/objdump")
|
|
SESSION = "run-472955e277202c411388c66b"
|
|
|
|
WINDOWS = [
|
|
("turn-get-create", "D", 0x00885380, 0x0088544A),
|
|
("turn-append", "D", 0x00884CB0, 0x00884D8F),
|
|
("turn-grow", "D", 0x008841A0, 0x00884440),
|
|
("nested-copy", "D", 0x00779850, 0x00779A20),
|
|
("nested-dtor", "D", 0x00629580, 0x006295CA),
|
|
("turn-dtor", "D", 0x0062E120, 0x0062E190),
|
|
("turn-alloc", "D", 0x006E8F50, 0x006E8FB0),
|
|
("turn-range-copy", "D", 0x0077FED0, 0x00780040),
|
|
("turn-vtable", "s", 0x00A0F070, 0x00A0F0A0),
|
|
]
|
|
|
|
|
|
def sha256(data: bytes) -> str:
|
|
return hashlib.sha256(data).hexdigest()
|
|
|
|
|
|
records = []
|
|
for name, mode, start, stop in WINDOWS:
|
|
argv = [str(OBJDUMP), f"-{mode}"]
|
|
if mode == "D":
|
|
argv.append("-Mintel")
|
|
argv += [
|
|
f"--start-address=0x{start:08x}",
|
|
f"--stop-address=0x{stop:08x}",
|
|
str(EXE),
|
|
]
|
|
proc = subprocess.run(
|
|
argv, cwd=ROOT, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False
|
|
)
|
|
(OUT / f"{name}.stdout.txt").write_bytes(proc.stdout)
|
|
(OUT / f"{name}.stderr.txt").write_bytes(proc.stderr)
|
|
records.append(
|
|
{
|
|
"name": name,
|
|
"argv": argv,
|
|
"start": f"0x{start:08x}",
|
|
"stop": f"0x{stop:08x}",
|
|
"returncode": proc.returncode,
|
|
"stdout_bytes": len(proc.stdout),
|
|
"stdout_sha256": sha256(proc.stdout),
|
|
"stderr_bytes": len(proc.stderr),
|
|
"stderr_sha256": sha256(proc.stderr),
|
|
"instruction_lines": sum(
|
|
1
|
|
for line in proc.stdout.splitlines()
|
|
if line.lstrip()[:1].isdigit() and b":" in line
|
|
),
|
|
}
|
|
)
|
|
|
|
manifest = {
|
|
"schema": "sots-live-record-static-capture/1",
|
|
"session": SESSION,
|
|
"scope": "Read-only TurnEvents get/create and directly required lifetime helpers; static planning evidence only.",
|
|
"cwd": str(ROOT),
|
|
"source_identity": {
|
|
"engine": {
|
|
"path": "/tmp/opencode/sots-final-research-engine",
|
|
"commit": "7741d42fc5e4e761e6449bdaf0e4a61d00036a23",
|
|
"sha256": "ccd8e02083e8d2e2b3e97976ace2273c8f924dfc02a39e919004eaf3544c50fd",
|
|
},
|
|
"re": {
|
|
"path": "/tmp/opencode/sots-final-research-re",
|
|
"commit": "3bfde5a70d874a723e797a695bbd847fd82c0aa7",
|
|
"sha256": "6696fd5201e144843617cbf6d78b41b5287ad5dcc9fa1e8aaa861d52b64e72e8",
|
|
},
|
|
},
|
|
"input": {"path": str(EXE), "sha256": sha256(EXE.read_bytes())},
|
|
"tool": {
|
|
"path": str(OBJDUMP),
|
|
"version": "GNU Binutils 2.38",
|
|
"sha256": sha256(OBJDUMP.read_bytes()),
|
|
},
|
|
"windows": records,
|
|
}
|
|
(OUT / "manifest.json").write_text(
|
|
json.dumps(manifest, indent=2) + "\n", encoding="utf-8"
|
|
)
|
|
|
|
if any(
|
|
record["returncode"] != 0
|
|
or record["stdout_bytes"] == 0
|
|
or record["stderr_bytes"] != 0
|
|
for record in records
|
|
):
|
|
raise SystemExit(1)
|