Skip to content

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

Open
pigalot wants to merge 2 commits into
R0Y00:mainfrom
pigalot:tooling/assert-sites
Open

pigalot wants to merge 2 commits into
R0Y00:mainfrom
pigalot:tooling/assert-sites

Conversation

@pigalot

@pigalot pigalot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

--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
Contributor 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
Contributor 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
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.

3 participants