Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion mythril_core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,18 @@ impl<'a> fmt::Display for PortWriteRequest<'a> {
}
}

#[derive(Debug)]
pub struct MemWriteRequest<'a> {
data: &'a [u8],
}

impl fmt::Debug for MemWriteRequest<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("MemWriteRequest")
.field("data", &format_args!("{:02x?}", self.data))
.finish()
}
}

impl<'a> MemWriteRequest<'a> {
pub fn new(data: &'a [u8]) -> Self {
Self { data }
Expand Down
23 changes: 21 additions & 2 deletions mythril_core/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use alloc::vec::Vec;
use bitflags::bitflags;
use core::borrow::{Borrow, BorrowMut};
use core::default::Default;
use core::fmt;
use core::ops::{Add, Deref, Index, IndexMut};
use derive_try_from_primitive::TryFromPrimitive;
use ux;
Expand Down Expand Up @@ -142,8 +143,9 @@ impl Add<usize> for Guest4LevelPagingAddr {
}
}

#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Debug)]
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone)]
pub struct GuestPhysAddr(u64);

impl GuestPhysAddr {
pub fn new(addr: u64) -> Self {
Self(addr)
Expand Down Expand Up @@ -182,8 +184,17 @@ impl Add<usize> for GuestPhysAddr {
}
}

#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Debug)]
impl fmt::Debug for GuestPhysAddr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("GuestPhysAddr")
.field(&format_args!("0x{:x}", self.0))
.finish()
}
}

#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone)]
pub struct HostPhysAddr(u64);

impl HostPhysAddr {
pub fn new(addr: u64) -> Self {
Self(addr)
Expand All @@ -198,6 +209,14 @@ impl HostPhysAddr {
}
}

impl fmt::Debug for HostPhysAddr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("HostPhysAddr")
.field(&format_args!("0x{:x}", self.0))
.finish()
}
}

#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Debug)]
pub struct HostPhysFrame(HostPhysAddr);
impl HostPhysFrame {
Expand Down