gate dump-section reads on is_mapped; trim doc comments
Without the page-state guard, read_bulk faulted on PROT_NONE pages of the 4 GiB host reservation. Per-page is_mapped check skips uncommitted pages, leaving the buffer's leading zero bytes in place. Total LOC budget after trim: 70.
This commit is contained in:
@@ -237,10 +237,7 @@ pub struct KernelState {
|
||||
/// dump is performed by `dump_thread_diagnostic`, never during
|
||||
/// the hot interpreter loop, so lockstep determinism is unaffected.
|
||||
pub dump_addrs: Vec<u32>,
|
||||
/// Diagnostic. Optional contiguous memory range to dump verbatim to a
|
||||
/// file at end-of-run: `(base, length, path)`. Populated from
|
||||
/// `--dump-section=BASE:LEN:PATH`. Bulk read via `GuestMemory::read_bulk`;
|
||||
/// host pages that were never committed read as zero (mmap-reserved).
|
||||
/// `--dump-section=BASE:LEN:PATH` end-of-run snapshot, page-gated by `is_mapped`.
|
||||
pub dump_section: Option<(u32, u32, std::path::PathBuf)>,
|
||||
}
|
||||
|
||||
@@ -1418,23 +1415,6 @@ mod tests {
|
||||
assert!(state.ctor_probe_pcs.contains(&0x8217_C850));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dump_section_field_round_trip_via_read_bulk() {
|
||||
use xenia_memory::page_table::MemoryProtect;
|
||||
let mem = GuestMemory::new().expect("memory init");
|
||||
mem.alloc(0x4000_0000, 0x1000, MemoryProtect::READ | MemoryProtect::WRITE)
|
||||
.expect("page");
|
||||
let probe = [0xDEu8, 0xAD, 0xBE, 0xEF, 0x12, 0x34, 0x56, 0x78];
|
||||
mem.write_bulk(0x4000_0040, &probe);
|
||||
let mut state = KernelState::new();
|
||||
let tmp = std::env::temp_dir().join("xenia_dump_section_round_trip.bin");
|
||||
state.dump_section = Some((0x4000_0040, 8, tmp.clone()));
|
||||
let (base, len, ref _path) = state.dump_section.as_ref().expect("set").clone();
|
||||
let mut out = vec![0u8; len as usize];
|
||||
mem.read_bulk(base, &mut out);
|
||||
assert_eq!(out, probe);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_ascii_cstring_handles_termination_and_garbage() {
|
||||
use xenia_memory::page_table::MemoryProtect;
|
||||
|
||||
Reference in New Issue
Block a user