paavohtl Claude Opus 4.6 (1M context) commited on
Commit
a5c1336
Β·
1 Parent(s): 5107860

docs: add debug CLI section to CLAUDE.md

Browse files

Documents the debug server, CLI commands, frame breakpoints,
snapshot system, and key env vars (OPENWA_DEBUG_SERVER,
OPENWA_BREAK_FRAME, OPENWA_USE_ORIG_CTOR, OPENWA_WATCH_FRAME).
Also adds openwa-debug-cli and openwa-debug-proto to crate list.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

.claude/settings.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(target/i686-pc-windows-msvc/release/openwa-debug resume:*)",
5
+ "Bash(taskkill /f /im WA.exe)"
6
+ ]
7
+ }
8
+ }
CLAUDE.md CHANGED
@@ -59,11 +59,40 @@ Environment variables:
59
  - `OPENWA_VALIDATE=1` β€” Enable validation module (struct checks, vtable validation, memory dumps)
60
  - `OPENWA_REPLAY_TEST=1` β€” Fast-forward mode: hooks TurnManager_ProcessFrame and sets DDGame+0x98B0=1 each frame (50x speed). Restores window at 2s, runs validation at 5s, 120s safety timeout. Without this, validation runs interactively with hotkeys (F9=team blocks, F10=landscape)
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  ## Crate Architecture
63
 
64
  - **`openwa-core`** β€” Types, addresses, parsers, ASLR rebasing, and typed WA function wrappers. The source of truth for all reverse-engineered type layouts and known addresses (`address.rs`). Contains `rebase` (ASLR delta), `wa_call` (calling convention helpers), and `wa/` (typed handle wrappers like `DDGameWrapperHandle`, `CWndHandle`).
65
  - **`openwa-wormkit`** β€” Unified WormKit cdylib that replaces WA functions with Rust and optionally validates types against live memory. Logs to `OpenWA.log` (hooks) and `OpenWA_validation.log` (validation). Uses MinHook for inline hooking. Validation is enabled via `OPENWA_VALIDATE=1` env var.
66
  - **`openwa-harness`** β€” Offline test harness that loads WA.exe into process memory via `LoadLibraryExA(DONT_RESOLVE_DLL_REFERENCES)` for testing without running the game.
 
 
67
 
68
  ## ASLR Rebasing
69
 
 
59
  - `OPENWA_VALIDATE=1` β€” Enable validation module (struct checks, vtable validation, memory dumps)
60
  - `OPENWA_REPLAY_TEST=1` β€” Fast-forward mode: hooks TurnManager_ProcessFrame and sets DDGame+0x98B0=1 each frame (50x speed). Restores window at 2s, runs validation at 5s, 120s safety timeout. Without this, validation runs interactively with hotkeys (F9=team blocks, F10=landscape)
61
 
62
+ ## Debug CLI
63
+
64
+ Use the `/debug-cli` skill to inspect live game memory, set frame breakpoints, and capture game state snapshots. The debug server runs inside the DLL; the CLI is a separate binary that connects over TCP.
65
+
66
+ ```bash
67
+ # Start game in debug mode:
68
+ powershell -ExecutionPolicy Bypass -File start-debug.ps1
69
+
70
+ # Or with headless replay + frame breakpoint:
71
+ OPENWA_BREAK_FRAME=1350 OPENWA_DEBUG_SERVER=1 \
72
+ powershell -File replay-test.ps1 -Headless testdata/replays/longbow.WAgame
73
+ ```
74
+
75
+ Key commands:
76
+ - `openwa-debug read "0x7A0884->0xA0->0x488" 0x100` β€” read memory via pointer chains
77
+ - `openwa-debug suspend` / `resume` / `step N` β€” frame-level control
78
+ - `openwa-debug snapshot` β€” canonicalized game state dump (for diffing)
79
+ - `openwa-debug break 1350` β€” set frame breakpoint
80
+
81
+ Address syntax: Ghidra VAs (auto-rebased), `abs:` prefix for absolute, `+offset` / `[offset]`, `->` for pointer chains. **Always quote chain addresses** (`"0x7A0884->0xA0->0x488"`).
82
+
83
+ Key env vars:
84
+ - `OPENWA_DEBUG_SERVER=1` β€” enable TCP debug server (port 19840)
85
+ - `OPENWA_BREAK_FRAME=N` β€” auto-pause at frame N
86
+ - `OPENWA_USE_ORIG_CTOR=1` β€” use original WA DDGame constructor (for A/B testing)
87
+ - `OPENWA_WATCH_FRAME=N` β€” arm hardware watchpoint on DDGame at frame N
88
+
89
  ## Crate Architecture
90
 
91
  - **`openwa-core`** β€” Types, addresses, parsers, ASLR rebasing, and typed WA function wrappers. The source of truth for all reverse-engineered type layouts and known addresses (`address.rs`). Contains `rebase` (ASLR delta), `wa_call` (calling convention helpers), and `wa/` (typed handle wrappers like `DDGameWrapperHandle`, `CWndHandle`).
92
  - **`openwa-wormkit`** β€” Unified WormKit cdylib that replaces WA functions with Rust and optionally validates types against live memory. Logs to `OpenWA.log` (hooks) and `OpenWA_validation.log` (validation). Uses MinHook for inline hooking. Validation is enabled via `OPENWA_VALIDATE=1` env var.
93
  - **`openwa-harness`** β€” Offline test harness that loads WA.exe into process memory via `LoadLibraryExA(DONT_RESOLVE_DLL_REFERENCES)` for testing without running the game.
94
+ - **`openwa-debug-cli`** β€” CLI tool for live memory inspection (`openwa-debug` binary). Connects to the debug server in the DLL.
95
+ - **`openwa-debug-proto`** β€” Shared protocol types (Request/Response enums, MessagePack framing) between CLI and server.
96
 
97
  ## ASLR Rebasing
98
 
testdata/replays/longbow.log DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ea3e9bd84be7013b537cfb232385aa1b9af67fa22dd0c393503b9163461b5c33
3
- size 1590