Commit graph

2 commits

Author SHA1 Message Date
Stephen Dennis
0f3e22df28 fix(dbt): overflow-safe guest instruction-fetch bounds (#1864)
pc + 4 > memory_size wraps for a guest-controlled PC near UINT64_MAX, so
the fetch guard passes and memcpy reads outside the guest image.  Same
class as interpreter mem_check (#1292).

Add dbt_guest_range_ok (subtract form) and use it for fetch, look-ahead,
pretranslate scans, and dbt_run/dbt_resume dispatch.  Unit-test wrap
cases in test_cache.
2026-07-31 08:59:14 -06:00
Stephen Dennis
f760f8b57a test(dbt): consolidate the DBT test islands into tests/dbt
Three directories accumulated in a day -- tests/dbt_chain (#1152),
tests/dbt_cache (#1153) and tests/dbt_exec (the RV64 execution harness) --
each with its own Makefile, .gitignore and root-level make target.  The
boilerplate was three copies of the same six variables, and `make test`
carried three lines where one will do.

Now one directory, one Makefile, one `make test-dbt`.

Still three binaries, because each genuinely needs a different link and
they cannot coexist in one image:

  chain  all three backends at once with their colliding strong symbols
         renamed via -D.  Inspects emitted bytes only, so it needs no host
         that can run them -- which is the point, since #1152 was a decode
         bug in a backend nobody compiled.  Links no dbt.cpp.
  cache  dbt.cpp against backend stubs that abort if called.  Cannot merge
         with chain, whose backends are renamed away, nor with exec, which
         links the real ones.
  exec   interpreter and DBT, host backend only, because this one runs
         what it translates.

Individually runnable as `make -C tests/dbt chain|cache|exec`, so
collapsing the root targets costs nothing.

Sources moved with git mv so history follows them.  The two driver
programs are renamed to test_chain/test_cache, matching their binaries;
their internal abort messages are updated to match.

No behaviour change: same three suites, same assertions, same results
(48 + 14 + 172 + 2 ELF legs).

tests/dbt_interp from PR #1299 is deliberately untouched -- that branch is
open and moving its files would only hand its author a conflict.  It
should fold into tests/dbt when it lands; the Makefile has room for a
fourth binary and adding one is a five-line change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-25 20:41:04 -06:00
Renamed from tests/dbt_cache/test_dbt_cache.cpp (Browse further)