CLI extension only — no schema change. Adds symbolic resolution for --pc-probe / --branch-probe / --ctor-probe tokens: - `0xADDR` / `2186674160` — numeric (current behavior, no DB load). - `Class::method` — joins classes × methods × demangled_names. - `Class::*` — joins classes × methods (all slots). - `function_name` — falls back to functions.name for free functions / saverestore stubs / labels. New `xenia_analysis::lookup::resolve_probe_token(db_path, token)` opens the DB read-only ONLY when a token is non-numeric, so legacy numeric flows pay no IO. New `--probe-db PATH` flag (or `XENIA_PROBE_DB` env / default `sylpheed.db` next to the .iso) selects the DB. Symbolic resolution happens BEFORE any guest exec, so it cannot affect the lockstep digest. Verified deterministic across two reruns at -n 2M (instructions=2000005 identical). End-to-end smoke test on Sylpheed: `--pc-probe='ANON_Class_6B674251::*'` resolves to all 45 method PCs of that anonymous class (matching the methods-table row count for that vtable). Tests 621→626 (+5 lookup unit tests covering numeric passthrough, symbolic-without-DB error, Class::method resolution, Class::* expansion, and functions.name fallback). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8.2 KiB
xenia-analysis schema reference
Authoritative documentation for the DuckDB tables and SQL views produced by
xenia-rs dis --db sylpheed.db. Track schema changes here alongside any
update to the db_schema_golden test fixture.
The base + disasm tables (metadata, sections, imports, functions,
labels, instructions, xrefs, opt-in exec_trace / import_calls /
branch_trace) are documented inline in src/db.rs doc comment. This file
collects layered analysis additions and forward-work notes.
Layer M1 — .pdata boundary correction (landed)
Schema additions
functions.pdata_validated BOOLEAN NOT NULL—truewhen the row'saddressmatches aRUNTIME_FUNCTION.BeginAddressfrom.pdata. Linker ground truth.functions.pdata_length BIGINT NULL—function_length(bytes) from the matching pdata entry;NULLwhen the row is prologue-only.- New table
pdata_entries(begin_address BIGINT PRIMARY KEY, end_address BIGINT, function_length BIGINT, prolog_length BIGINT, flags BIGINT)— every parsed.pdataRUNTIME_FUNCTIONentry (raw, before any merge with prologue analysis). - Index
idx_functions_pdata_validatedonfunctions(pdata_validated).
What this layer does
- Parses
.pdata8-byteRUNTIME_FUNCTIONentries (PowerPC PE32 layout): word 0BeginAddress(absolute VA), word 1 packed{prolog_length:8, function_length:22, flags:2}, both big-endian. - Unions pdata
BeginAddressvalues into the function-candidate set fed to the prologue walker, so functions our prologue heuristic missed still get rows. - When pdata supplies a longer
function_lengththan the prologue walk found, extendsend_addressto the pdata-implied end (catches mis-split where the walker stopped at an earlyblr). - After the walker, performs a forward pass that trims
function.endto the next start when they overlap (catches mis-merge where one row spanned two prologues — the audit-031sub_824D23B0/sub_824D29F0case).
What this layer does NOT do
- Does not adjust prolog-derived
frame_size/saved_gprsfrom.pdata'sprolog_lengthfield — those remain prologue-only inferences. - Does not classify functions further than the existing
is_leaf/is_saverestorecolumns. Class membership is M3. - Does not detect functions whose entries are missing from BOTH
.pdataand the bl-target scan (extremely rare; would require executable-byte linear sweep).
Reference docs
- Microsoft PE32+ exception data spec for PowerPC RUNTIME_FUNCTION.
- xenia-canary
src/xenia/cpu/xex_module.cc:1570-1587— canary's reference parser (extractsBeginAddressonly; we additionally decode word 1).
Validation queries
-- All pdata entries found
SELECT COUNT(*) FROM pdata_entries; -- ~23073 for Sylpheed
-- Functions cross-validated against pdata
SELECT COUNT(*) FROM functions WHERE pdata_validated;
-- Functions detected ONLY by prologue (orphans of pdata)
SELECT COUNT(*) FROM functions WHERE NOT pdata_validated;
-- Pdata orphans NOT yet in functions (should be 0 after this layer)
SELECT COUNT(*) FROM pdata_entries p
LEFT JOIN functions f ON f.address = p.begin_address
WHERE f.address IS NULL;
-- Audit-031 mis-merge resolved: 0x824D29F0 should have its own row
SELECT name FROM functions WHERE address = 2186674160; -- 0x824D29F0
Layer M2 — MSVC C++ name demangler (landed)
Schema additions
- New table
demangled_names(address BIGINT NULL, mangled VARCHAR NOT NULL, raw_demangled VARCHAR NOT NULL, namespace_path VARCHAR NULL, class_name VARCHAR NULL, method_name VARCHAR NULL, params_signature VARCHAR NULL). - Indices on
address,class_name,method_name.
What this layer does
- Wraps
msvc_demangler::demangle(a Rust port of LLVM'sMicrosoftDemangle.cpp) and splits the formatted output into structured fields via a heuristic top-level parser (handles templates and nested parens correctly). - Populates
demangled_namesfrom any label whose name starts with?plus any import name that happens to be mangled (defensive — typical kernel imports use C names).
What this layer does NOT do
- Does not parse the AST returned by
msvc_demangler::parse— uses the formatted string and a heuristic split. Adequate for typical class member functions and RTTI strings; exotic template / lambda forms still getraw_demangledpopulated but may have NULL structured fields. - Does not yet ingest RTTI strings discovered in
.rdata— that's M3's job; M3 will append rows to this table at the addresses where it finds RTTI TypeDescriptors.
Reference docs
msvc-demanglercrate (https://docs.rs/msvc-demangler/0.11).- LLVM
MicrosoftDemangle.cpp(the parser this crate ports).
Layer M3 — Vtable + RTTI detection (landed)
Schema additions
vtables(address PK, length, col_address NULL, class_name, rtti_present, base_classes_json NULL)— every detected static vtable.methods(vtable_address, slot, function_address, mangled_name NULL, demangled_name NULL, PRIMARY KEY (vtable_address, slot))— one row per method slot.classes(name PK, vtable_address, rtti_present, base_classes_json NULL)— deduped by class name (first-detected vtable wins).- Indices:
methods.function_address,classes.rtti_present.
What this layer does
- Walks
.rdataand.datalooking for runs of ≥3 consecutive 4-byte BE values where each value is a known function start (from M1's correctedfunctionstable). Single-2-method vtables are intentionally rejected to control false-positive rate. - Attempts the MSVC RTTI walk
vtable[-1] → CompleteObjectLocator → TypeDescriptorfor each candidate. When successful, the demangledclass ClassNamestring fillsclass_nameand a best-effortRTTIClassHierarchyDescriptorwalk fillsbase_classes_json(JSON array of base class names). - Falls back to
ANON_Class_<8-hex>keyed by FNV-1a hash of the sorted method-PC tuple when RTTI is absent (typical for shipped game binaries). Identical vtables across the binary (multiple instances) collapse to the same anonymous name.
What this layer does NOT do
- Vtables built at runtime in heap-allocated memory (e.g. by ctors copying
static templates) are out of scope — only static
.rdata/.datacontent. - Multiple-inheritance "extra" vftables (one per base subobject) are detected as independent vtables with no link between them.
- Inheritance-tree walking beyond
RTTIClassHierarchyDescriptor's direct base list is not attempted.
Reference docs
- openrce.org "Reversing Microsoft Visual C++" — RTTI layout articles (CompleteObjectLocator at vtable[-1]; TypeDescriptor at COL+0xC; mangled name at TD+0x8).
Layer M4 — Class-aware probe targeting (landed)
CLI extension only — no schema changes. The probe-token grammar adds three
symbolic forms on top of the existing 0xADDR literal:
Class::method— joinsclasses×methods×demangled_namesto find every PC whose vtable belongs to that class and whose demangledmethod_namematches.Class::*— joinsclasses×methodsto find every method PC of that class.function_name— falls back tofunctions.namelookup for free functions / saverestore stubs / labels.
Numeric tokens never touch the DB (preserves zero-IO fast path; lockstep
digest unaffected). Symbolic tokens require the DuckDB at --probe-db PATH
or XENIA_PROBE_DB; default is sylpheed.db next to the .iso when present.
Resolution happens BEFORE guest exec begins, so it cannot affect the lockstep digest.
See crates/xenia-analysis/src/lookup.rs.
Forward work (M5–M12, not yet landed)
- M5 — indirect-dispatch reachability via vtable+CTR dataflow.
- M6 — extended
xrefs.kind='write'for indexed/byte-reverse/multiword/VMX/DCBZ/atomic stores withaddr_modecolumn. - M7 —
.rdataASCII / UTF-16 string pool detection cross-referenced with PCs. - M8 — dispatch-table heuristics beyond vtables (e.g. function-pointer arrays in
.data). - M9 —
__CxxFrameHandlerexception scope-table parsing. - M10 —
.tlssection / TLS slot tracking. - M11 —
__xc_a/__xc_zstatic-initializer driver detection. - M12 — comparative-PC-trace mode for canary diff (runtime side, not analyzer).