# SPDX-License-Identifier: MIT """Deterministic boundary traces of the W65C816: write, read and compare them. 6502-python's trace functions (its docs/trace-schema.md, version 1) with this core's record type: one JSON object per boundary, with ``kind`` one of :class:`~w65c816.debug.BoundaryKind`'s values, ``before`` and ``after`` :class:`~w65c816.state.CPUState`'s fields, ``instruction.address`` 24-bit, and ``accesses`` ``[kind, address, value]`` with the kinds of :mod:`w65c816.debug` (``"rdp"``, ``"rd"``, ``"wd"``, ``"i"``, ...), one per cycle. A trace written here is read back equal, and two cores' traces are compared with :func:`first_trace_divergence`. """ from __future__ import annotations from collections.abc import Iterator from typing import TextIO from sixfiveohtwo.trace import ( TRACE_SCHEMA_VERSION, TraceDifference, TraceDivergence, compare_step_records, first_session_divergence, first_trace_divergence, iter_session_steps, iter_trace_divergences, step_record_to_dict, write_trace, ) from sixfiveohtwo.trace import read_trace as _read_trace from sixfiveohtwo.trace import step_record_from_dict as _step_record_from_dict from w65c816.debug import W65C816Record def step_record_from_dict(value: object) -> W65C816Record: """Reconstruct one strictly validated W65C816 record.""" return _step_record_from_dict(value, record_type=W65C816Record) def read_trace(stream: TextIO) -> Iterator[W65C816Record]: """Yield strictly validated W65C816 records lazily from a JSON Lines stream.""" return _read_trace(stream, record_type=W65C816Record) __all__ = [ "TRACE_SCHEMA_VERSION", "TraceDifference", "TraceDivergence", "compare_step_records", "first_session_divergence", "first_trace_divergence", "iter_session_steps", "iter_trace_divergences", "read_trace", "step_record_from_dict", "step_record_to_dict", "write_trace", ]