فهرست منبع

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;