Skip to content

tooling: add --assert-sites to the startup debugger - #2916

Merged
R0Y00 merged 6 commits into
R0Y00:mainfrom
pigalot:tooling/assert-sites
Nov 28, 2026
Merged

R0Y00 merged 6 commits into
R0Y00:mainfrom
pigalot:tooling/assert-sites

Conversation

@pigalot

@pigalot pigalot commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

--continue-asserts N steps over the first N main-image int3 hits in total. A soft assert that repeats uses that budget up, so a long run needs an ever larger number (runs on #870 pass -ContinueAsserts 200000), and once the budget runs out the next repeat of a known site stops the run.

--assert-sites N (run.ps1 -AssertSites N, run.sh --assert-sites N) counts distinct sites instead. Every hit at up to N distinct main-image int3 sites is stepped over, however long the run is. The first hit at one more site still stops the run, so a new assert is still caught, and X2W_STOP_AT sites still stop. A hit is stepped over when either budget allows it, and each budget counts only the hits it covers: the site budget keeps its own set of admitted sites (the first N distinct ones), and --continue-asserts counts the hits at other sites. Used alone, --continue-asserts keeps its meaning. run.ps1 and run.sh pass --assert-sites 0 by default, so their behavior does not change.

Refs #870

Tests

tests/startup_debug_check.py (core group), on startup_debug_probe with its third site repeated 20 times:

  • --assert-sites 3 exits 0 and logs all 20 hits at the repeated site.
  • Control: --continue-asserts 3 stops at the repeated site's second hit.
  • --assert-sites 2 stops at the first hit of the third site.
  • X2W_STOP_AT on the second site still stops there under --assert-sites 3.
  • --assert-sites -1 is rejected.
  • Both budgets (STARTUP_DEBUG_PROBE_REVISIT=1, so the hits are A, B, A): --assert-sites 1 --continue-asserts 2 exits 0 with the breakpoints logged in that order. Control: --continue-asserts 2 alone stops at A's second hit.

startup_run_ps1_check.py and startup_run_sh_check.py check that -AssertSites / --assert-sites reach the debugger.

cmake --preset dev
cmake --build --preset dev --target startup_debug_probe startup_debug_calls
ctest --preset dev --no-tests=error -R '^(startup_debug|startup_run_ps1|startup_run_sh|docs_links)'
100% tests passed, 0 tests failed out of 7

At 3d4460f (on fa754b0), rebased on main 98007de after cpp-migration merged (#3039). The one conflict, in tests/startup_run_ps1_check.py, kept main's new -NativeShaders lines and added -AssertSites 2 to the shared command. Windows 11 Pro 10.0.26200.

startup_run_sh skipped on this host (no wine).

Negative control: with the site rule in debug_launch.py disabled, startup_debug fails at the --assert-sites 3 case, because the run stops at the repeated site instead of exiting 0. With the predicate from the first commit (fa754b0) (both budgets reading asserts_seen), startup_debug fails at the combined case: the run stops at A's second hit (startup_debug_probe.exe+0x199c).

This change was AI-assisted.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tooling: add --assert-sites to the startup debugger

This is a clean, well-structured addition. The new --assert-sites N flag is a practical complement to --continue-asserts N — counting distinct sites instead of total hits will save users from running out of budget on repeat-hit assert paths like texture streaming.

Minor typo fix needed

File: tools/startup/debug_launch.py

The error message string on the continuation of the print call has a missing leading space:

print("expected numeric --timeout and --memory-gib values and integer --continue-asserts and "
      "--assert-sites values")

Consider ensuring the second line starts with a space for consistent formatting.

Everything looks good

  • ✅ Validation: assert_sites < 0 properly guarded
  • ✅ Error messages updated to cover both flags
  • ✅ PowerShell + shell + Python test harness all propagate the flag consistently
  • ✅ Tests cover negative input, multiple sites, zero-site, and interaction with X2W_STOP_AT
  • ✅ Documentation matches the implementation
  • ✅ New flag added to usage() in both run.ps1 and run.sh

Verdict: LGTM once the minor typo is addressed. Ready to merge.

@pigalot

pigalot commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. The first string already ends with a space ("... --continue-asserts and "), so the two parts join as ... integer --continue-asserts and --assert-sites values. I have left the line as it is.

This reply was AI-assisted.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #2916 by @pigalot -- tooling: add --assert-sites to the startup debugger

What works

  • Solid foundational work establishing the 0x100 linear layout in gfx10_layout.h with careful derivation from AMD addrlib
  • The linear_mode = 0 constant elegantly extends block_log2() to accept mode 0 without changing the tiled modes switch logic
  • supports() check is correct: mode == linear_mode bypasses the block_log2 >= 12 requirement since linear has no tail
  • Test infrastructure is excellent -- linear_order_control (expected failure with largest mip first), linear_addrlib (338K element addresses), and the unpadded negative control all add strong coverage
  • Documentation accurately restates addrlib's linear mode algorithm in clear, testable terms

Issues

  • supports() currently allows block-compressed formats (BC1-BC7) in linear mode via the fallthrough -- BC formats are block-based and don't have linear row semantics; consider gating them out explicitly like 1D does in #2929
  • The check script in startup_address_console_check.py builds linear backing bytes from addrlib equations. This is correct but the linear path could break if the hardcoded equations drift from addrlib; a comment linking to the Mesa commit that derives these equations would help

Recommendations

  • Good discipline in including the negative control (unpadded rows test) to verify the 256-byte pitch requirement
  • Consider adding a TODO or assert in supports() that blocks linear mode for BC formats until explicitly validated against addrlib

Overall

A well-researched, well-tested implementation. The linear layout extension is cleanly separated from tiled modes. Minor concern about BC format handling in linear mode, but the existing refusal behavior is safe. Ready for merge.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two budgets share asserts_seen, so the total-hit allowance can revoke a site that the distinct-site allowance already covers. I evaluated the exact predicate from 06b3df15 with sites A, B, A and --assert-sites 1 --continue-asserts 2. It continued A, continued B, then stopped at A. A is the first admitted site and should keep continuing under the stated rule that either budget can permit a hit.

Please keep the sites admitted by the site budget separately from the total-hit bookkeeping and add a combined-budget fixture that revisits A after using the total-hit allowance on B. The existing tests cover each allowance on its own.

@pigalot

pigalot commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks, confirmed. B went into asserts_seen through the hit budget, so at A's second hit the site count was already 2.

9de3826 keeps the two budgets apart: the site budget has its own set of admitted sites, and --continue-asserts counts only the hits at other sites. Either option on its own behaves as before.

The probe can now revisit its first breakpoint (STARTUP_DEBUG_PROBE_REVISIT=1). The new assert-sites-combined case checks that A, B, A with --assert-sites 1 --continue-asserts 2 runs to exit 0 with the breakpoints in that order. Its control, --continue-asserts 2 alone, stops at A's second hit.

ctest --preset dev --no-tests=error -R '^(startup_debug|startup_run_ps1|startup_run_sh|docs_links)': 7 of 7 passed (startup_run_sh skipped, no wine). With the old predicate and the new test, startup_debug stops at A's second hit.

This reply was AI-assisted.

--continue-asserts N counts hits, so a soft assert that repeats runs the budget out and long runs need ever larger values. --assert-sites N steps over every hit at up to N distinct main-image int3 sites and stops at the first hit of one more site. run.ps1 -AssertSites and run.sh --assert-sites pass it through with 0 as the default.
Both budgets read asserts_seen, so a site the hit budget continued also
filled a slot of the site budget. With hits A, B, A and --assert-sites 1
--continue-asserts 2, A and B continued and A's second hit stopped the
run. Keep the sites the site budget admits in their own set and count
only the hits the hit budget covers.

Test: the probe can revisit its first breakpoint
(STARTUP_DEBUG_PROBE_REVISIT=1); A, B, A with both budgets now runs to
the end, and the control with the hit budget alone stops at A's second
hit.
@pigalot
pigalot force-pushed the tooling/assert-sites branch from 9de3826 to 3d4460f Compare November 27, 2026 10:53
@tedin7

tedin7 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

This PR no longer merges cleanly with main. Conflicting files: tools/startup/debug_launch.py, tools/startup/run.ps1, tools/startup/run.sh. Please merge main into the branch.

R0Y00's change request (the two budgets sharing asserts_seen) looks addressed by 9de3826 (site budget kept apart, combined-budget fixture). It still shows CHANGES_REQUESTED, so R0Y00 needs to re-review after the merge of main.

AI-assisted; commands listed were executed locally. (Trial merge against origin/main.)

Keeps main's capture options next to --assert-sites in the usage line, the
PowerShell and shell launchers and the debugger command.
@tedin7

tedin7 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Merged main into this branch (merge commit 1b87eb2, no rebase); the launcher and debugger conflicts were resolved by keeping main's capture options next to --assert-sites. R0Y00: the combined-budget point from your review looks fixed by 9de3826 (site budget kept apart from the hit count, A, B, A with --assert-sites 1 --continue-asserts 2 now continues all three, with a control run). Please re-review when you can; I will not merge while the change request is open.

AI-assisted; commands listed were executed locally.

Conflict resolved in tools/startup/run.ps1: main's script-block call
that keeps Windows PowerShell 5.1 stderr records from aborting the
launcher, with this branch's --assert-sites argument added.
@pigalot

pigalot commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator Author

I merged main (0637fced) into this branch as 43b02d08. It's a plain merge commit; I didn't rebase or force-push. It was needed because main changed the same debug_launch.py call in tools/startup/run.ps1 again after the earlier merge at 1b87eb23.

Conflict. main now runs that call inside a script block with $ErrorActionPreference = "Continue", so Windows PowerShell 5.1 no longer stops the launcher on redirected stderr. I kept main's block and added this branch's --assert-sites $AssertSites after --continue-asserts $ContinueAsserts. tests/startup_run_ps1_check.py and docs/startup-runtime.md merged without conflicts. git diff --check origin/main...HEAD reports no problems.

Testing on 43b02d08:

  • Built dev and release.
  • In each preset, ran ctest --no-tests=error -j 4 -E '(_hardware$|startup_audio_)' -R '^(startup_run_ps1|startup_debug.*|startup_assert.*|startup_triage.*|startup_run_sh)$'. All 8 tests pass, including startup_run_ps1 and startup_debug.
  • Ran the full non-hardware suite in dev (-j 6 -E '(_hardware$|startup_audio_)'). All 2000 tests pass.

main has moved on to bf1bc769, but none of the new commits touch this PR's files, and the branch still merges cleanly. R0Y00's changes request still stands and needs a re-review.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10.

This reply was AI-assisted.

Conflict resolved in tools/startup/run.ps1: main's --map-drive
arguments (R0Y00#1251) and this branch's --assert-sites argument both
pass through the launcher call.
@pigalot

pigalot commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator Author

I merged main (fbef6381) into this branch again, as b2b40747. It's a plain merge commit; I didn't rebase or force-push. After #1251 merged, main adds @mapArgs to the same debug_launch.py call in tools/startup/run.ps1 that this branch extends with --assert-sites.

Conflict. The resolution passes both arguments: --continue-asserts $ContinueAsserts --assert-sites $AssertSites @mapArgs @traceArgs @captureArgs, still inside main's script block. In tools/startup/debug_launch.py, --assert-sites and --map-drive merged without a conflict, and each is read on its own. git diff --check origin/main...HEAD reports no problems.

Testing on b2b40747:

  • Built dev and release.
  • In each preset, ran ctest --no-tests=error -j 4 -E '(_hardware$|startup_audio_)' -R '^(startup_run_ps1|startup_debug.*|startup_map_drive.*|startup_hook.*|startup_launch.*|startup_host_cpu_debug.*|startup_triage.*|startup_run_sh)$'. All 15 tests pass, including startup_run_ps1, startup_debug, startup_map_drive and startup_map_drive_overlap.
  • Ran the full non-hardware suite in dev (-j 6 -E '(_hardware$|startup_audio_)'). All 2020 tests pass.

main is now at 240e0fb9. None of its new commits touch this PR's files, and the branch still merges cleanly. R0Y00's changes request still stands and needs a re-review.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10.

This reply was AI-assisted.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed b2b40747. Admitted sites and counted hits now have independent state. The source-built A, B, A probe exits successfully with the combined budgets, while the hit-only control stops on the returning A. The PowerShell merge keeps --assert-sites and the separate drive-map, trace and capture arguments in the guarded debugger invocation.

On Windows 11 build 26200, MSVC 19.51, I built startup_debug_probe in Debug and Release and ran ctest --preset <preset> --no-tests=error --output-on-failure -R '^(startup_debug|startup_debug_launch_args|startup_run_ps1|startup_run_sh)$'. Debug and Release each reported three passes and the expected Windows skip for the POSIX launcher check. The hosted Linux Python check is green. The requested change is resolved.

@R0Y00
R0Y00 merged commit fd7ce57 into R0Y00:main Nov 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants