浏览代码

multiboot2: custom Debug impl for efi_memory_map

It makes no sense to print the raw buffer. This is long and has less
value.
Philipp Schuster 10 月之前
父节点
当前提交
347695596b
共有 1 个文件被更改,包括 14 次插入1 次删除
  1. 14 1
      multiboot2/src/memory_map.rs

+ 14 - 1
multiboot2/src/memory_map.rs

@@ -284,7 +284,7 @@ impl AsBytes for EFIMemoryDesc {}
 
 /// EFI memory map tag. The embedded [`EFIMemoryDesc`]s follows the EFI
 /// specification.
-#[derive(ptr_meta::Pointee, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
+#[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[repr(C)]
 pub struct EFIMemoryMapTag {
     typ: TagTypeId,
@@ -377,6 +377,19 @@ impl EFIMemoryMapTag {
     }
 }
 
+impl Debug for EFIMemoryMapTag {
+    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
+        f.debug_struct("EFIMemoryMapTag")
+            .field("typ", &self.typ)
+            .field("size", &self.size)
+            .field("desc_size", &self.desc_size)
+            .field("buf", &self.memory_map.as_ptr())
+            .field("buf_len", &self.memory_map.len())
+            .field("entries", &self.memory_areas().len())
+            .finish()
+    }
+}
+
 impl TagTrait for EFIMemoryMapTag {
     const ID: TagType = TagType::EfiMmap;