fix(tools): count function-try-block definitions in nid_names.py #811
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/811"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-06T06:02:02Z.
What
Accurate tooling prevents the duplicate-PR churn and reviewer time burn: a bad
rename-readylabel becomes a duplicate definition, which becomes another PR fixing the collision.tools/nid_names.pymisses function-try-block definitions (name(args) try { ... }): itsDEFINITIONregex has notryclause.tools/progress.pygained one infix(tools): count function-try-block exports in progress.py, but the sibling scanner was never updated. 26 implemented exports (mostly libSceVideoOut) are invisible tocollect_real_names, so a validated NID suggestion whose name is one of those 26 is labelledrename-ready; renaming such a stub creates a duplicate definition. This aligns the regex withtools/progress.py. Measured before/after overcore/libs: 3303 -> 3329 definitions recognized (26 recovered).Recovered names:
sceVideoOutRegisterBuffers2,sceVideoOutSubmitChangeBufferAttribute2,sceVideoOutUnregisterBuffers,sceVideoOutSubmitFlip,sceVideoOutAddFlipEvent,sceVideoOutAddVblankEvent,sceVideoOutAddPreVblankStartEvent,sceVideoOutAddOutputModeEvent,sceVideoOutDeleteFlipEvent,sceVideoOutDeleteVblankEvent,sceVideoOutDeletePreVblankStartEvent,sceVideoOutDeleteOutputModeEvent,sceVideoOutOpen,sceVideoOutClose,sceVideoOutAllowOutputResolutionWqhdDetection,sceVideoOutSetFlipRate, and 10 more in libSceVideoOut/libSceLibcInternal.Tested
Windows 11, Python 3.14 (no build):
core/libsbefore/after: 3303 -> 3329 definitions recognized (26 recovered).collect_real_names()covers every definition shapetools/progress.pyaccepts, and thatcompute_nidmatches the independent base64 encoder incore/libs/tests/run_exception_tests.py(5 known symbols): passes.tools/nid_names.py --jsonagainst zecoxao/sce_symbols (159,034 rows): 115 unknown rows, 0 MISMATCH, 102 rename-ready. On today's tree no row flips status -- the bug is latent and bites as soon as a suggestion resolves to one of the 26 names above.Exact reproducers (run at
96499c8; onmainwithout the fix the count assert sees 0 recovered):Definition counts -- unique names, old
noexcept-only pattern vs the fix:git checkout
96499c8python - <<'PYEOF'
import re, sys
sys.path.insert(0, 'tools')
import nid_names
from pathlib import Path
OLD = re.compile(r"\bAPS5_VABI\s+(\w+)\s*([^;{])\s(?:noexcept\s*)?{")
texts = [p.read_text(errors="replace") for p in sorted((nid_names.ROOT / "core" / "libs").rglob("*.cpp"))]
old_u = {m for t in texts for m in OLD.findall(t)}
new_u = {m for t in texts for m in nid_names.DEFINITION.findall(t)}
print("unique definition names: %d -> %d (recovered %d)" % (len(old_u), len(new_u), len(new_u - old_u)))
print("recovered sample:", sorted(new_u - old_u)[:8])
assert len(new_u - old_u) == 26 and 'sceVideoOutOpen' in new_u - old_u
print("assert exactly 26 function-try-block definitions recovered, incl. sceVideoOutOpen: yes")
PYEOF
unique definition names: 3303 -> 3329 (recovered 26)
recovered sample: ['sceVideoOutAddFlipEvent', 'sceVideoOutAddOutputModeEvent', 'sceVideoOutAddPreVblankStartEvent', 'sceVideoOutAddVblankEvent', 'sceVideoOutAdjustColor', 'sceVideoOutAllowOutputResolutionWqhdDetection', 'sceVideoOutClose', 'sceVideoOutConfigureOutput']
assert exactly 26 function-try-block definitions recovered, incl. sceVideoOutOpen: yes
compute_nidvs the independent encoder incore/libs/tests/run_exception_tests.py(5 known symbols):python - <<'PYEOF'
import base64, hashlib, sys
sys.path.insert(0, 'tools')
import nid_names
def ref_nid(symbol):
digest = hashlib.sha1(symbol.encode() + bytes.fromhex('518d64a635ded8c1e6b039b1c3e55230')).digest()
return base64.b64encode(digest[:8][::-1]).decode().rstrip('=').replace('/', '-')
syms = ['sceVideoOutOpen', 'sceVideoOutClose', 'sceVideoOutSubmitFlip', 'sceVideoOutAddFlipEvent', 'sceVideoOutSetFlipRate']
assert all(nid_names.compute_nid(s) == ref_nid(s) for s in syms)
print("assert compute_nid == run_exception_tests.nid for 5 known symbols: PASS 5/5")
PYEOF
assert compute_nid == run_exception_tests.nid for 5 known symbols: PASS 5/5
Full
--jsonrun + status tally:python tools/nid_names.py --json > rows.json
python - <<'PYEOF'
import json, collections
rows = json.load(open("rows.json"))["rows"]
tally = collections.Counter(r["status"] for r in rows)
assert len(rows) == 115 and tally["MISMATCH"] == 0 and tally["rename-ready"] == 102
print("rows: %d, statuses: %s, db_entries: %d" % (len(rows), dict(tally), json.load(open("rows.json"))["db_entries"]))
PYEOF
rows: 115, statuses: {'rename-ready': 102, 'unknown': 12, 'already-implemented': 1}, db_entries: 159034
Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryThe
DEFINITIONregex is now duplicated intools/progress.pyandtools/nid_names.py(the drift that caused this). Happy to extract a shared constant if you want that hardened -- separate PR.