rust-minidump / rust-minidump

Type definitions, parsing, and analysis for the minidump file format.
MIT License
420 stars 62 forks source link

minidump_dump: Support dumping the stack as 32/64bit words #375

Closed jrmuizel closed 2 years ago

jrmuizel commented 2 years ago

This would make it a lot easier to read.

i.e. something like

@@ -1518,22 +1519,22 @@ Memory
 ",
             self.desc.start_of_memory_range, self.desc.memory.data_size, self.desc.memory.rva,
         )?;
         self.print_contents(f)?;
         writeln!(f)
     }

     /// Write the contents of this `MinidumpMemory` to `f` as a hex string.
     pub fn print_contents<T: Write>(&self, f: &mut T) -> io::Result<()> {
         write!(f, "0x")?;
-        for byte in self.bytes.iter() {
-            write!(f, "{:02x}", byte)?;
+        for bytes in self.bytes.chunks_exact(8) {
+            writeln!(f, "{:016x}", u64::from_le_bytes(bytes.try_into().unwrap()))?;
         }
         writeln!(f)?;
         Ok(())
     }

     pub fn memory_range(&self) -> Option<Range<u64>> {
         if self.size == 0 {
             return None;
         }
         Some(Range::new(
Gankra commented 2 years ago

Seems fine and a good starter given the OP basically include a patch already.

I'm assuming this is "standard" for a hexdumper (don't use them enough to recall).