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 <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
This commit is contained in:
Andrew Walbran 2022-04-29 14:51:35 +00:00 committed by Chromeos LUCI
parent 9ef18e4760
commit ecbf9dcfa1
3 changed files with 5 additions and 4 deletions

View file

@ -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 {

View file

@ -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,

View file

@ -68,7 +68,7 @@ bitflags! {
}
/// A file-like object backing `MemoryRegion`.
#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum BackingObject {
Shm(Arc<SharedMemory>),
File(Arc<File>),
@ -95,6 +95,7 @@ impl AsRef<dyn AsRawDescriptor + Sync + Send> 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]>,
}