Skip to content

Commit

Permalink
x86_64: Added pagetable pretty printing function for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
jounathaen committed Nov 20, 2024
1 parent 279aa7e commit 44756d8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/arch/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,27 @@ pub fn initialize_pagetables(mem: &mut [u8]) {
}
}

#[allow(dead_code)]
/// Helper fn for debugging pagetables
fn pretty_print_pagetable(pt: &PageTable) {
println!("Idx Address Idx Address Idx Address Idx Address ");
println!("--------------------------------------------------------------------------------------------------------");
for i in (0..512).step_by(4) {
println!(
"{:3}: {:#18x}, {:3}: {:#18x}, {:3}: {:#18x}, {:3}: {:#18x}",
i,
pt[i].addr(),
i + 1,
pt[i + 1].addr(),
i + 2,
pt[i + 2].addr(),
i + 3,
pt[i + 3].addr()
);
}
println!("--------------------------------------------------------------------------------------------------------");
}

/// Converts a virtual address in the guest to a physical address in the guest
pub fn virt_to_phys(
addr: GuestVirtAddr,
Expand Down

0 comments on commit 44756d8

Please sign in to comment.