Make the tie record relocation a command, and verify it on two levels
The relocation rule from the previous commit was established by a script that lived in a shell history, which means the next person would have had to rediscover it. It is now `gc-trace verify-tie-records <unpacked-dir> <level> <class> <lod> <src>`: resolve the class, parse the block, search the RAM image for the loaded record table, report what it found, and exit 0 only when every record's pointer has become table + word and every field byte is verbatim. Swept over every (class, lod) slot of two levels, from PCSX2 savestates: level 0: 87 slots with a block, 87 verified, 0 mismatched, 61 absent level 1: 104 slots with a block, 104 verified, 0 mismatched, 78 absent So the rule holds on every LOD block of two levels the game had loaded, which is what makes the record layout a finding rather than a reading of one block. Writing the command also caught an off-by-one in the parser it exercises: TieBlockHeader::records started its slice after the 16-byte header, but the header IS the first record -- the table runs from the block start to data_offset, and a block with data_offset 0x50 holds five records, the first being the header itself and its pointer naming where the payload begins. Found because the tool's first run relocated nothing while the same check in a script had passed; the unit test fixture was wrong in the same way and is fixed. Two operational notes now in the format doc: the live emulator is not a stable input (verifying level 1 over PINE matched 104 of 104 while the user was on that planet, and the same command minutes later found no matching copy because they had returned to level 0 -- a miss there is not a counterexample, so the report says "no copy matched" rather than "failed"), and a class index past the table count is an error rather than a mismatch, so a sweep should stop at the level's class count rather than a round number.
This commit is contained in:
@@ -64,6 +64,34 @@ fn run(args: &[String]) -> Result<i32> {
|
||||
let len = require(&rest, "--len")?;
|
||||
read(&src, &addr, &len)
|
||||
}
|
||||
"verify-tie-records" => {
|
||||
// gc-trace verify-tie-records <unpacked-dir> <level> <class> <lod> <src>
|
||||
let (src, rest) = Source::parse_with_rest(&args[1..])?;
|
||||
let (dir, level, class, lod) = match rest.as_slice() {
|
||||
[dir, level, class, lod, ..] => (
|
||||
PathBuf::from(dir),
|
||||
level.parse::<usize>().context("level")?,
|
||||
class.parse::<usize>().context("class")?,
|
||||
lod.parse::<usize>().context("lod")?,
|
||||
),
|
||||
_ => {
|
||||
return Err(anyhow!(
|
||||
"usage: gc-trace verify-tie-records <unpacked-dir> <level> <class> <lod> <src>"
|
||||
))
|
||||
}
|
||||
};
|
||||
let idx = std::fs::read(dir.join(format!("level{level}/core_index.bin")))
|
||||
.with_context(|| format!("level{level}/core_index.bin"))?;
|
||||
let core = std::fs::read(dir.join(format!("level{level}/core_data.bin")))
|
||||
.with_context(|| format!("level{level}/core_data.bin"))?;
|
||||
let bytes = src.load()?;
|
||||
let ram = EeRam::new(&bytes)?;
|
||||
let report = gc_trace::tie_verify::verify(&idx, &core, class, lod, &ram)?;
|
||||
let mut text = String::new();
|
||||
gc_trace::tie_verify::print_report(&report, &mut text)?;
|
||||
println!("{text}");
|
||||
Ok(report.exit_code())
|
||||
}
|
||||
"compare-tfrag-light" => {
|
||||
let (src, rest) = Source::parse_with_rest(&args[1..])?;
|
||||
let dir = rest
|
||||
@@ -95,6 +123,7 @@ fn run(args: &[String]) -> Result<i32> {
|
||||
const USAGE: &str = "\
|
||||
usage: gc-trace <command> ...
|
||||
compare-tfrag-light <unpacked-dir> [--level N] <src>
|
||||
verify-tie-records <unpacked-dir> <level> <class> <lod> <src>
|
||||
info <src>
|
||||
dump-ee <src> [--out FILE]
|
||||
find <src> --bytes HEX
|
||||
|
||||
Reference in New Issue
Block a user