From ecbf9dcfa19cf20eaf9f808ae82ee3127a70bc6e Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Fri, 29 Apr 2022 14:51:35 +0000 Subject: [PATCH] Derive Debug for SharedMemory. This is useful when adding temporary logs to dump it for debugging. TEST=tools/dev_container tools/run_tests --target=vm:aarch64 Change-Id: Ia982104943b214b67472f7bdd03c9511191c35cb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3627452 Tested-by: kokoro Commit-Queue: Dmitry Torokhov Auto-Submit: Andrew Walbran Reviewed-by: Dmitry Torokhov --- base/src/shm.rs | 2 +- base/src/sys/unix/shm.rs | 2 +- vm_memory/src/guest_memory.rs | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/base/src/shm.rs b/base/src/shm.rs index bad212b688..fca6055778 100644 --- a/base/src/shm.rs +++ b/base/src/shm.rs @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; /// See [SharedMemory](crate::platform::SharedMemory) for struct- and method-level /// documentation. -#[derive(Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize)] #[serde(transparent)] pub struct SharedMemory(pub(crate) SysUtilSharedMemory); impl SharedMemory { diff --git a/base/src/sys/unix/shm.rs b/base/src/sys/unix/shm.rs index dfb10ac686..4c897e0dd5 100644 --- a/base/src/sys/unix/shm.rs +++ b/base/src/sys/unix/shm.rs @@ -23,7 +23,7 @@ use crate::SharedMemory as CrateSharedMemory; use crate::{AsRawDescriptor, IntoRawDescriptor, RawDescriptor, SafeDescriptor}; /// A shared memory file descriptor and its size. -#[derive(Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize)] pub struct SharedMemory { #[serde(with = "super::with_as_descriptor")] fd: File, diff --git a/vm_memory/src/guest_memory.rs b/vm_memory/src/guest_memory.rs index 47c3ba4fd1..7a13851987 100644 --- a/vm_memory/src/guest_memory.rs +++ b/vm_memory/src/guest_memory.rs @@ -68,7 +68,7 @@ bitflags! { } /// A file-like object backing `MemoryRegion`. -#[derive(Clone)] +#[derive(Clone, Debug)] pub enum BackingObject { Shm(Arc), File(Arc), @@ -95,6 +95,7 @@ impl AsRef for BackingObject { /// A regions of memory mapped memory. /// Holds the memory mapping with its offset in guest memory. /// Also holds the backing object for the mapping and the offset in that object of the mapping. +#[derive(Debug)] pub struct MemoryRegion { mapping: MemoryMapping, guest_base: GuestAddress, @@ -162,7 +163,7 @@ impl MemoryRegion { /// Tracks memory regions and where they are mapped in the guest, along with shm /// fds of the underlying memory regions. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct GuestMemory { regions: Arc<[MemoryRegion]>, }