tooling: audit GDK export coverage #3286
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3286
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3284"
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?
@lambirou on GitHub · 2026-11-28 05:16 UTC · original
lambirou:gdk/export-coverage→main· +755 −0 · 5 files · 6 commits · merged 2026-11-28 11:15 UTCThe GDK knowledge plan needs an exhaustive export inventory and a matrix of which names the Xbox2Windows shims provide. This adds both, with the libraries and the full inventory kept outside the repository.
tools/gdk_exports.py parses captured dumpbin /exports text for a LIB or DLL, or reads a PE DLL through pefile. It records the module, file, SHA-256, ordinal and RVA. tools/gdk_shim_coverage.py compares the inventory with the .def files, separates functions from IID_/WKPDID_ data, lists local x2w_* extras, and prints the ordinals seen in the GDK file. When a module has both a .lib and a .dll, the tool merges their exports and deduplicates names.
Measured on the 261000 set (89 modules, 8,035 export names):
The largest gaps remain xg_xs (layout, DCC, tile shape and descriptor helpers) and xmem (statistics, tags, Win32 heaps and configuration). d3d12_xs lacks the desktop entry points and several DXGIX helpers.
Commands:
python -B tests/gdk_exports_check.py
python -B tools/gdk_exports.py parse-dumpbin D:\gdk-oracle\dumpbin\xg_xs.txt --json out\xg_xs.json --kind dll
python -B tools/gdk_shim_coverage.py --exports D:\gdk-oracle\knowledge\exports-all.json --repo . --json out\coverage.json --markdown out\coverage.md
The check passed on Windows and runs on Linux without the GDK. The real matrix was regenerated from the existing 261000 inventory; the JSON and Markdown stay in D:\gdk-oracle\knowledge.
These are names, not signatures and not tests. A covered name can still be untested at runtime, and an ordinal import still needs the matching import library and a runtime check. Xbox One gen8 libraries are outside this table.
@JohnConnorNPC on GitHub · 2026-11-28 07:59 UTC · original
Thanks for this. I reviewed head
0edc189cand a trial merge of it into currentmain(c3204a9c).git merge-tree --write-tree origin/main 0edc189cexits 0, and on the merged treetests/gdk_exports_check.pyprintsgdk_exports_check: all checks passed, as it does in the Linux CI job.read_defon the seven default .def files gives the shim column ingdk-exports.md(xmem 27, d3d12_xs 5, acphal 10, xapu 6, chad 5, xg_xs 2, xcrdapi 3). Nothing gates on these tools, so I think this can merge. The points below would make the coverage numbers easier to trust, either here or in a follow-up:.defordinals are never recorded. The repo writesXMemAlloc @1with a space, butread_deftests"@" in nameaftersplit()[0], so the ordinal never reaches it. Onsrc/xmem_shim.defit returns 27 names and 0 ordinals, whilegrep -cE '\s@[0-9]+'counts 27 ordinal lines. A C++-decorated name such as?f@@YAXXZwould also be cut at the first@. The test still passes withif "@" in name:changed toif False:. Parsing the@Ntoken and adding one ordinal to the fixture would pin it.>redirection) parses to 0 exports, and the report then showsgdk_functions=0 missing=0with--fail-on-missingexiting 0. A .def module with no inventory entry drops out of the table, again with exit 0. So do captures namedd3d12_xs.lib.txtord3d12_xs.dll.txt, because the merge keys on the file stem and not on themodulefield. dumpbin forwarder,[NONAME]andname = internalrows are skipped without a count. Counting unparsed rows per module, reporting 0-export and absent modules as unmeasured, and having--fail-on-missingfail on them would close this.entry["exports"].extend(...)replaced by an assignment. Of the 8 mutants I ran on copies of the PR files, 3 fail the test:is_datareturning False, the DLL ordinal set to None, and--fail-on-missingignored.Smaller things:
report --exports …usage fails witherror: unrecognized arguments: report.parse-dumpbinhashes the.txtcapture and stores that path asfile, so the SHA-256 doesn't identify the LIB or DLL. The test checks onlylen(...) == 64, and it still passes with a constant hash."sdk": "261000"is hardcoded incollect_dumpbin,scan_peandwrite_document.scan_pehas no test, and the LIB ordinal column and the stop at Summary or "Dump of file" are unpinned.DEFAULT_DEFSleaves outsrc/xgameruntime_shim.defandsrc/startup_stubs/gameinput.def. Is that intended?789ee573("ci: retry the Windows smoke test") is empty. Squashing it on merge would drop it.Environment: Linux, git objects, a trial merge, and pure-Python probes and mutants on copies of the PR files. I didn't run Windows, Wine, a GPU or a real GDK inventory, so the GDK columns are unmeasured, though each row's arithmetic adds up (GDK − covered = missing).
This comment was AI-assisted.
@pigalot on GitHub · 2026-11-28 08:18 UTC · original · requested changes
Independently reviewed
0edc189cintegrated overmain1f07b2c1(treed2d58f50). The trial merge is clean andgit diff --checkis clean.I read both tools against the repository's own
.deffiles and against captures that fail to parse.python -B tests/gdk_exports_check.pypasses (exit 0) on the trial merge on Windows. I can confirm the first three points JohnConnorNPC raised, with my own runs below. Two of them make a coverage matrix that looks complete when it isn't, and that matrix is what this PR is for.1.
read_defnever records an ordinal from this repository's.deffiles.src/xmem_shim.defwritesXMemAlloc @1, with a space.name = text.split("=", 1)[0].split()[0]keeps onlyXMemAlloc, so the"@" in namebranch never runs.DEFAULT_DEFSfiles,read_defreturns 0 ordinals for every module.src/xmem_shim.defhas 27@Nlines.def_ordinalsin the JSON is always empty.@would also cut a decorated name such as?f@@YAXXZ.@Ntoken from the whitespace-split fields, and add one@Nline to the test's.deffixture.2. A failed or partial read counts as "nothing missing", and
--fail-on-missingstill exits 0. I used a synthetic DLL capture, written as UTF-16 the way Windows PowerShell 5.1>writes it:parse_dumpbin_textreturns 0 exports. The row for that module then reads| xg_xs | 0 | 1 | 0 | 0 |..deffile but no inventory entry (xmem) is left out of the table.d3d12_xs.lib.txt.load_exportskeys onPath(file).stem, which isd3d12_xs.lib, and not on themodulefield.--fail-on-missingexits 0.--fail-on-missingfail on those rows too;3. The lib+dll merge the body describes is untested. No fixture module has both a
.liband a.dll. The d3d12_xs row indocs/experiments/gdk-exports.mddepends on that union.Mutants. Each was applied alone to a copy of the three PR files, then
tests/gdk_exports_check.pywas run:is_datareturnsFalsexg functions 3--fail-on-missingignored (return 0)fail-on-missing exitNone.defordinal branch disabled (if False:)entry["exports"].extend(...)replaced by an assignmentsha256returns a constantSummary/Dump of fileSmaller points, none of them blocking:
gdk_shim_coverage.pydocstring showsreport --exports …, which exits 2 withunrecognized arguments: report.parse-dumpbinhashes the.txtcapture and stores the capture path asfile, so the SHA-256 doesn't identify the LIB or DLL. The doc says the inventory records the SHA-256 without saying which file it is of."sdk": "261000"is hardcoded in three places, andscan_pehas no test.Environment: Windows 11 25H2 build 26200.9974, Python 3.12.10. These are pure-Python tools: no build, no GPU and no real GDK inventory, so I couldn't measure the GDK columns in the doc.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on0edc189c.This reply was AI-assisted.
@lambirou on GitHub · 2026-11-28 10:13 UTC · original
Fixed at
f6d3396f..defordinals:read_defnow parses an@Ntoken from the whitespace fields, soXMemAlloc @1records ordinal 1. A decorated name such as?XMemInternal@@YAXXZis left intact. The fixture now pins both.modulefield, with a.lib/.dllsuffix stripped from file-stem fallbacks. A fixture with bothd3d12_xs.lib.txtandd3d12_xs.dll.txtchecks the union, deduplication and coverage.unmeasuredin the JSON and the Markdown table.--fail-on-missingnow fails on those rows too. The fixtures cover an empty capture and an absent module..txtforparse-dumpbinand the DLL forscan-pe; the matrix has a Status column.Validation:
python -B tests/gdk_exports_check.pypasses (DLL/LIB parsing, ordinals, decorated names, LIB+DLL union, empty/absent rows and exit codes), andtests/docs_links_check.pypasses on 143 files / 661 links.scan_pestill has no fixture because it needs a PE and pefile; I left that as the non-blocking follow-up.DEFAULT_DEFSremains the seven measured modules.@lambirou on GitHub · 2026-11-28 10:17 UTC · original
CI is green on
f6d3396f: Windows build/test, Linux Python checks and gfx1013 fixtures passed;/O2and the coverage chart are skipped as usual. Ready for re-review.@lambirou on GitHub · 2026-11-28 10:22 UTC · original
One more non-blocking point:
f75d806aadds--sdktoparse-dumpbinandscan-peinstead of hardcoding 261000, with a fixture assertion. CI is green on this head (Windows build/test, Linux Python, gfx1013). Ready for re-review.@lambirou on GitHub · 2026-11-28 10:27 UTC · original
The DEFAULT_DEFS question is now answered in
e759b2fc:gameinputis included (1 GDK function, 1 shim, 1 covered).xgameruntimestays out intentionally: its.defis fixture-only and its exported thunk names are generated fromXGAMERUNTIME_THUNK_TABLE, so a name comparison would report every GDK runtime export as missing. A missing inventory entry is reported as unmeasured rather than covered. CI is rerunning on this head.@romn4rch on GitHub · 2026-11-28 10:52 UTC · original
Could you please add the focused regression assertions from local commit
a5f70cea932f7436b49de641059c50c4818328a0to this branch? They cover partial dumpbin captures,.lib.txtfallback module normalization, parser section boundaries, and exact SHA-256 verification. My account cannot push to the PR head repository (GitHub returned 403), so I could not publish the commit.@pigalot on GitHub · 2026-11-28 11:14 UTC · original · approved these changes
Retested
e759b2fcintegrated overmainbc1da08d(tree987377f3). The trial merge is clean andgit diff --checkis clean. This supersedes my changes-requested review on0edc189c.python -B tests/gdk_exports_check.pypasses (exit 0) on the trial merge on Windows.Earlier findings
.defordinals: addressed.read_defnow returns 27 ordinals forsrc/xmem_shim.def(27@Nlines) and 1 forsrc/startup_stubs/gameinput.def. A decorated name such as?XMemInternal@@YAXXZstays whole. Both are pinned: disabling the@Ntoken loop failsxmem def ordinals {}, and cutting the name at the first@failsdecorated name ['?XMemInternal'].parse-dumpbinand then the coverage tool with--fail-on-missing:| xg_xs | ? | 2 | ? | ? | no exports parsed |, exit 1;.defmodule with no inventory entry gives| xmem | ? | 1 | ? | ? | no inventory entry |, exit 1;d3d12_xs.lib.txtandd3d12_xs.dll.txtboth get moduled3d12_xsand merge into one row (| d3d12_xs | 3 | 3 | 3 | 0 | ok |);[NONAME]row gives2 unparsed export line(s), an unmeasured row and exit 1.check_mergehas a module with both files. Replacingextendwith an assignment now failsmerged exports.The smaller points are addressed too: the
reportusage line is gone from the docstring, the doc says which file the SHA-256 is of, and--sdkreplaces the hardcoded value (pinned for the module and the document). The shim column indocs/experiments/gdk-exports.mdmatchesread_defon the eightDEFAULT_DEFSfiles (27, 5, 10, 6, 5, 2, 3, 1).Mutants. Each was applied alone to a copy of the three PR files, then
tests/gdk_exports_check.pywas run. 26 mutants: 17 killed, 9 survive, none equivalent.Killed (17):
.def@Ntoken loop disabled;.defname cut at the first@;DATAkeyword ignored;extendreplaced by an assignment;load_exportskeyed on the raw file name;--fail-on-missingignoring unmeasured rows;--fail-on-missingignoring missing names;None;sdkignored; documentsdkignored;is_datareturnsFalse; GDK ordinals dropped from the row; extras dropped.Survive (9), none blocking. My runs above show the code does the right thing in each case; the fixtures just don't pin it:
.lib/.dllsuffix kept bymodule_name, and bynormalize_module(the merge fixture sets themodulefield, so the file-name fallback never runs);Summary/Dump of file;sha256returns a constant (the test checks only the length);?for an unmeasured row, and the Status column always saysok(the test reads only theUnmeasured:line);gameinputremoved fromDEFAULT_DEFS(--repohas no test).The first six are the cases romn4rch asked to have pinned in the comment at 10:52Z. I agree they are worth adding, here or in a follow-up; I don't see them as blocking, because the tool behaves correctly on each.
One more note, not blocking:
read_defreads a name with a trailing@Nand no space, such as_Foo@8, as name_Foowith ordinal 8. That would misread an x86 stdcall name. No.deffile in the repository has one.scan_pestill has no test, as the author said. I couldn't measure the GDK columns in the doc: I have no GDK inventory.Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10. Pure-Python tools: no build and no GPU.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass one759b2fc.This reply was AI-assisted.