diff options
| author | nova-aryan <81568644+nova-aryan@users.noreply.github.com> | 2026-11-24 02:56:31 +0530 |
|---|---|---|
| committer | nova-aryan <81568644+nova-aryan@users.noreply.github.com> | 2026-11-24 02:56:33 +0530 |
| commit | c6ef64e2f79bd6348b399a3ee8a75ab3d0124fd7 (patch) | |
| tree | 632d8f30072e0219fd2486e90de0a9dba8db48d2 /tools/boot_trace.py | |
| parent | 5d74c272363f2703265d44e6aaab1a1df8ddfaf3 (diff) | |
Add a counts-only JSON mode for boot reports
Diffstat (limited to 'tools/boot_trace.py')
| -rw-r--r-- | tools/boot_trace.py | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/tools/boot_trace.py b/tools/boot_trace.py index 24bafbe47..4895ebf72 100644 --- a/tools/boot_trace.py +++ b/tools/boot_trace.py | |||
| @@ -12,9 +12,10 @@ a native program in an error record (`program.exe : [d3d12-trace] #1 ...`), so a | |||
| 12 | tag is accepted too. The reader accepts UTF-8 and BOM-marked UTF-16, including PowerShell 5.1 stderr redirection. | 12 | tag is accepted too. The reader accepts UTF-8 and BOM-marked UTF-16, including PowerShell 5.1 stderr redirection. |
| 13 | 13 | ||
| 14 | Usage: | 14 | Usage: |
| 15 | python -I boot_trace.py boot.jsonl [--d3d12 d3d12.log] [--json] [--limit N] | 15 | python -I boot_trace.py boot.jsonl [--d3d12 d3d12.log] [--json] [--counts-only] [--limit N] |
| 16 | 16 | ||
| 17 | The traces can quote what the game prints, so they stay on the player's machine: the text report counts debug | 17 | Use --counts-only for an aggregate JSON report to share. The traces can quote what the game prints, so they |
| 18 | stay on the player's machine. The text report counts debug | ||
| 18 | strings instead of printing them, and only the tests' synthetic fixtures go into the repository. Share counts and | 19 | strings instead of printing them, and only the tests' synthetic fixtures go into the repository. Share counts and |
| 19 | error classes from a real run, not its trace (AGENTS.md, "No game data"). | 20 | error classes from a real run, not its trace (AGENTS.md, "No game data"). |
| 20 | 21 | ||
| @@ -222,6 +223,35 @@ def summarize(startup: dict | None, d3d12: dict | None) -> dict: | |||
| 222 | return {"startup": startup, "d3d12": d3d12} | 223 | return {"startup": startup, "d3d12": d3d12} |
| 223 | 224 | ||
| 224 | 225 | ||
| 226 | def counts_only(summary: dict) -> dict: | ||
| 227 | """Project only fixed counters into the summary intended for sharing.""" | ||
| 228 | counters = summarize(None, None) | ||
| 229 | if startup := summary["startup"]: | ||
| 230 | counters["startup"] = { | ||
| 231 | name: startup[name] for name in ("events", "bad_lines", "tls_callbacks", "debug_strings", | ||
| 232 | "file_open_failed_count", "exception_count") | ||
| 233 | } | ||
| 234 | counters["startup"].update( | ||
| 235 | modules=len(startup["modules"]), | ||
| 236 | dllmain_failed=startup["dllmain"]["failed"], | ||
| 237 | unimplemented_imports=len(startup["unimplemented"]), | ||
| 238 | int3_skipped=len(startup["int3_skipped"]), | ||
| 239 | exit_observed=startup["exit"] is not None, | ||
| 240 | ) | ||
| 241 | if d3d12 := summary["d3d12"]: | ||
| 242 | outcomes = {} | ||
| 243 | for outcome, count in d3d12["outcomes"].items(): | ||
| 244 | key = outcome if outcome in ("failed", "unsupported", "refused", "partial", "ok", "called", "ignored") else "other" | ||
| 245 | outcomes[key] = outcomes.get(key, 0) + count | ||
| 246 | counters["d3d12"] = { | ||
| 247 | "calls": d3d12["calls"], | ||
| 248 | "ignored_lines": d3d12["ignored_lines"], | ||
| 249 | "sequence_break_count": d3d12["sequence_break_count"], | ||
| 250 | "outcomes": outcomes, | ||
| 251 | } | ||
| 252 | return counters | ||
| 253 | |||
| 254 | |||
| 225 | def _tail(items, limit: int) -> str: | 255 | def _tail(items, limit: int) -> str: |
| 226 | shown = ", ".join(str(x) for x in items[:limit]) | 256 | shown = ", ".join(str(x) for x in items[:limit]) |
| 227 | return shown + (f", ... {len(items) - limit} more" if len(items) > limit else "") | 257 | return shown + (f", ... {len(items) - limit} more" if len(items) > limit else "") |
| @@ -331,6 +361,7 @@ def main(argv=None) -> int: | |||
| 331 | ap.add_argument("startup", nargs="?", help="the JSONL written by gta6rt --trace") | 361 | ap.add_argument("startup", nargs="?", help="the JSONL written by gta6rt --trace") |
| 332 | ap.add_argument("--d3d12", help="the stderr log written with --trace-d3d12") | 362 | ap.add_argument("--d3d12", help="the stderr log written with --trace-d3d12") |
| 333 | ap.add_argument("--json", action="store_true", help="print the summary as JSON") | 363 | ap.add_argument("--json", action="store_true", help="print the summary as JSON") |
| 364 | ap.add_argument("--counts-only", action="store_true", help="print aggregate JSON without paths or event details") | ||
| 334 | ap.add_argument( | 365 | ap.add_argument( |
| 335 | "--limit", type=int, default=10, help="items listed per section (default 10)" | 366 | "--limit", type=int, default=10, help="items listed per section (default 10)" |
| 336 | ) | 367 | ) |
| @@ -348,11 +379,13 @@ def main(argv=None) -> int: | |||
| 348 | try: | 379 | try: |
| 349 | summary[section] = parse(path, a.limit) | 380 | summary[section] = parse(path, a.limit) |
| 350 | except TraceError as e: | 381 | except TraceError as e: |
| 351 | print(f"error: {e}", file=sys.stderr) | 382 | print(f"error: {section} trace unavailable" if a.counts_only else f"error: {e}", file=sys.stderr) |
| 352 | exit_code = 2 | 383 | exit_code = 2 |
| 353 | if not any(summary.values()): | 384 | if not any(summary.values()): |
| 354 | return 2 | 385 | return 2 |
| 355 | if a.json: | 386 | if a.counts_only: |
| 387 | print(json.dumps(counts_only(summary), indent=1)) | ||
| 388 | elif a.json: | ||
| 356 | print(json.dumps(summary, indent=1)) | 389 | print(json.dumps(summary, indent=1)) |
| 357 | else: | 390 | else: |
| 358 | print(format_text(summary, a.limit)) | 391 | print(format_text(summary, a.limit)) |