diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-13 12:18:26 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-13 12:18:26 -0300 |
| commit | 4f31aaef1338b53195f8c475db5a72d75cc1fc82 (patch) | |
| tree | f2c3c2140269a5559f60bcd9e2520f5ff7431565 /gui/test/lenses.py | |
| parent | 771e377f6db9c3aed1ab85bc36a774f4176272cc (diff) | |
| download | computeranim-4f31aaef1338b53195f8c475db5a72d75cc1fc82.tar.gz computeranim-4f31aaef1338b53195f8c475db5a72d75cc1fc82.zip | |
debugger: add refractive lenses and configurable memory values
Use disassembly lenses for executable pointers, browse surrounding segment context, and keep the reading surface opaque with GPU refraction at the edges. Route right-clicks by stack mapping and expose byte-width and numeric-format controls. Replace matching-address arrows with staggered shared-renderer highlights.
Verified GUI and renderer suites, native restart/zoom cycles, independent float-extrema and popup review, and a live wrong-map stop at Deoptimizer::New with JS origin context. Requires Sketchbook 409c1ac.
Diffstat (limited to 'gui/test/lenses.py')
| -rw-r--r-- | gui/test/lenses.py | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/gui/test/lenses.py b/gui/test/lenses.py new file mode 100644 index 0000000..c78e250 --- /dev/null +++ b/gui/test/lenses.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python3 +"""Executable/data lenses, scroll bounds, display formats and native glass rendering.""" +import argparse +from pathlib import Path +import re +import subprocess +import tempfile + +ROOT = Path(__file__).resolve().parents[2] +p = argparse.ArgumentParser(description=__doc__) +p.add_argument('--gui', type=Path, default=ROOT / 'gui/zig-out/bin/ztrace-gui') +p.add_argument('--native', action='store_true') +p.add_argument('--output', type=Path) +a = p.parse_args() +a.gui = a.gui.resolve() +with tempfile.TemporaryDirectory(prefix='ztrace-lenses-') as directory: + out = a.output.resolve() if a.output else Path(directory) + out.mkdir(parents=True, exist_ok=True) + target = out / 'segments' + subprocess.run(['cc', '-g', '-O0', '-no-pie', str(ROOT / 'gui/targets/segments.c'), '-o', str(target)], check=True) + symbols = {name: int(address, 16) for address, name in re.findall(r'^([0-9a-f]+) \w (\w+)$', subprocess.check_output(['nm', '-n', str(target)], text=True), re.M)} + head, code = symbols['head'], symbols['checkpoint'] + script = out / 'check.script' + commands = f'''console launch {target} +await stops 1 +console break checkpoint +console continue +await execution 1 +frames 40 +console lens {code} +expect lens_count 1 +expect lenses[0].first {code} +frames 40 +screenshot {out / 'code-glass.png'} +console set glass false +frames 20 +screenshot {out / 'code-opaque.png'} +expect-different-screenshot {out / 'code-glass.png'} {out / 'code-opaque.png'} 1120 175 1060 140 +console set glass true +wheel 1600 220 -1 +frames 40 +print lenses[0].first +expect execution 1 +# Right-clicking an executable lens address opens memory, not code. +console mouse-button 3 1230 161 +expect focus memory +expect nav[2].place.address {code} +key escape +# Data lens context is scrollable in both directions without altering its anchor. +console lens {head} +frames 40 +expect lenses[0].address {head} +expect lenses[0].first {(head & ~15) - 32} +wheel 1600 220 -2 +frames 40 +expect lenses[0].first {(head & ~15) + 64} +screenshot {out / 'memory-context.png'} +wheel 1600 220 2 +frames 40 +expect lenses[0].first {(head & ~15) - 32} +# Same-parent pointer recursion preserves ancestors and detects a cycle. +click 1230 161 +expect lens_count 2 +expect lenses[1].cycle true +frames 30 +click 2180 350 +expect lens_count 1 +key escape +console goto memory {head} +frames 40 +# Both controls are available directly on the memory pane. +click 1240 822 +expect unit 2 +click 1240 822 +expect unit 4 +click 1240 822 +expect unit 8 +click 1278 822 +expect number_format unsigned +click 1278 822 +expect number_format signed +click 1278 822 +expect number_format float +click 1278 822 +expect number_format hex +''' + for unit in (1, 2, 4, 8): + for fmt in ('hex', 'unsigned', 'signed') + (('float',) if unit >= 4 else ()): + commands += f'console memory-format {unit} {fmt}\nexpect unit {unit}\nexpect number_format {fmt}\nframes 2\n' + commands += f'''console memory-format 8 hex +frames 10 +screenshot {out / 'words.png'} +# Historical browsing never requests bytes from a live target. +key left_bracket +expect following false +print stops +console lens {head} +frames 30 +wheel 1600 220 -20 +frames 30 +print stops +expect execution 1 +key escape +expect-no-log CommandFailed +expect-no-log backdrop shader +''' + script.write_text(commands) + args = [str(a.gui), '--fresh', '--size', '2240x1260', '--state', str(out / 'session.state'), '--script', str(script)] + if not a.native: + args.append('--headless') + run = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + stdout, stderr = run.communicate(timeout=100) + (out / 'run.log').write_text(stdout + stderr) + assert run.returncode == 0, stderr + first = int(re.search(r'lenses\[0\].first = (\d+)', stderr)[1]) + assert first > code, (first, code) + stops = re.findall(r'stops = (\d+)', stderr) + assert len(stops) == 2 and stops[0] == stops[1], stops + for recording in Path('/tmp').glob(f'ztrace-gui-{run.pid}-*.ztrace'): + recording.unlink() + print(('Native' if a.native else 'Headless') + ': code/data lenses, context scrolling, pointer recursion, memory formats and historical isolation passed') |
