Repository navigation
app, docs: add --json output to xtp inspect and xtp census - #24
Conversation
|
Other open pull requests change the same files. Check that they do not do the same work, and agree with their authors on which lands first: the other one will then need a rebase.
This comment is kept up to date automatically and removed when the overlap ends. |
simnJS
left a comment
There was a problem hiding this comment.
Thanks for this, the implementation is careful:
- it adds no dependencies and reuses
survey::quote; - the text output stays identical;
- the order is deterministic;
- logs go to stderr, so stdout is always clean JSON.
The test on hle-probe covers the issue's acceptance criteria, and I found no code from xcl.
One change before approval:
-
Document the schema in the repo. The issue asks for a stable output, but the field list is only in the PR description. Please add a short paragraph under "Commands" in
README.mdcovering:- the fields of
xtp-inspect 1andxtp-census 1and their types (e.g. "addresses, RVAs andmachineare hex strings; sizes and counts are numbers"); - the
resolutionvalues:hle,host,missing, withtitlereserved, since a static inspect cannot resolve DLLs the title ships, so those show asmissing; - that
--jsonignores--imports/--exportsand always includes the missing list for census (or reject the combination withconflicts_with); - that the
formatnumber goes up on a breaking change.
You could also mark B13 done in
docs/analysis/tooling.md. - the fields of
Optional, here or in a follow-up:
- In the test, assert
"delay": trueforxtp-probe-delayed.dlland"kind": "dll". A small unit test ofcensus::to_jsonwith empty maps would also make the[]branches run. - The test parser is not quite strict (it accepts raw control characters inside strings), so "minimal" would describe it better. It does catch trailing and missing commas, which is what matters here.
build_probeduplicates the loader test's helper and builds the fixture a second time. Moving it toxtp-testkitlater would remove both.
Process note for next time: please comment on the issue to claim it before you start (CONTRIBUTING, "Before you start"), so that nobody duplicates the work. It worked out this time, since nobody else had claimed it.
|
Addressed the review feedback:
|
simnJS
left a comment
There was a problem hiding this comment.
Thanks, all addressed: the schema is documented in the README, and the tests now cover delay, kind and the empty arrays. CI is green. Merging.
What and why
Add a stable
--jsonoutput mode toxtp inspectandxtp census(reusingsurvey::quotewith no new dependencies):xtp inspect <file> --json(format:xtp-inspect 1): emitsfile,blake3,kind,machine,subsystem,image_base,size_of_image,entry_rva, and sortedimports(including delay-load imports) with each entry'sresolution(hle,host,title, ormissing).xtp census [paths...] --json(format:xtp-census 1): emitsimages,unreadable,totals(functions,hle,host,missing), sorteddlls, andmissingpairs ordered by descending image count then(dll, symbol).Size note: 477 changed lines (slightly over 400) because the integration test includes a self-contained strict JSON parser so no new crate dependency is needed.
Fixes: #2
Depends on: none
Area
apps/xtp(main.rs,inspect.rs,census.rs,survey.rs,tests/inspect_json.rs)README.md(document--jsononxtp inspectandxtp census)Tests
cargo xtask pr-checkpasses on my machineIntegration test
apps/xtp/tests/inspect_json.rsbuildstests/fixtures/hle-probeand runs:xtp inspect --json <hle_probe.dll>: parses the output as strict JSON, checksfile,machine,image_base, verifiesxgameruntime.dllresolves ashle, and verifies the missing probe DLL resolves asmissing.xtp census --json <hle_probe.dll>: parses the output as strict JSON, checksimages == 1,totals, and verifies the missing probe DLL appears inmissing.Provenance
Written from scratch for XTP, reusing
apps/xtp/src/survey.rs'squotehelper. I did not read xcl'sinspect.rs.AI assistance: Antigravity assisted with implementation and integration tests; all changes were reviewed and verified locally with
cargo xtask pr-check.Checklist
<area>: <summary>; one topic; under 400 changed lines, or the reason is above