34 releases

0.23.0 Dec 4, 2024
0.22.2 Oct 10, 2024
0.22.1 Sep 5, 2024
0.22.0 Jul 3, 2024
0.1.0 Dec 21, 2017

#63 in Parser implementations

Download history 2401/week @ 2024-08-21 2300/week @ 2024-08-28 2727/week @ 2024-09-04 2386/week @ 2024-09-11 2169/week @ 2024-09-18 2830/week @ 2024-09-25 6092/week @ 2024-10-02 5552/week @ 2024-10-09 6122/week @ 2024-10-16 6982/week @ 2024-10-23 7568/week @ 2024-10-30 8838/week @ 2024-11-06 7200/week @ 2024-11-13 8026/week @ 2024-11-20 7583/week @ 2024-11-27 7427/week @ 2024-12-04

31,927 downloads per month
Used in 11 crates (8 directly)

MIT license

765KB
15K SLoC

minidump

crates.io

Basic parsing of the minidump format.

If you want richer analysis of the minidump (such as stackwalking and symbolication), use minidump-processor.

Usage

The primary API for this library is the Minidump struct, which can be instantiated by calling the Minidump::read or Minidump::read_path methods.

Succesfully parsing a Minidump struct means the minidump has a minimally valid header and stream directory. Individual streams are only parsed when they're requested.

Although you may enumerate the streams in a minidump with methods like Minidump::all_streams, this is only really useful for debugging. Instead you should statically request streams with Minidump::get_stream.

Depending on what analysis you're trying to perform, you may:

  • Consider it an error for a stream to be missing (using ? or unwrap)
  • Branch on the presence of stream to conditionally refine your analysis
  • Use a stream's Default implementation to get an "empty" instance (with unwrap_or_default)
use minidump::*;

fn main() -> Result<(), Error> {
    // Read the minidump from a file
    let mut dump = minidump::Minidump::read_path("../testdata/test.dmp")?;

    // Statically request (and require) several streams we care about:
    let system_info = dump.get_stream::<MinidumpSystemInfo>()?;
    let exception = dump.get_stream::<MinidumpException>()?;

    // Combine the contents of the streams to perform more refined analysis
    let crash_reason = exception.get_crash_reason(system_info.os, system_info.cpu);

    // Conditionally analyze a stream
    if let Ok(threads) = dump.get_stream::<MinidumpThreadList>() {
        // Use `Default` to try to make progress when a stream is missing.
        // This is especially natural for MinidumpMemoryList because
        // everything needs to handle memory lookups failing anyway.
        let mem = dump.get_memory().unwrap_or_default();

        for thread in &threads.threads {
            let stack = thread.stack_memory(&mem);
            // ...
        }
    }
    Ok(())
}

Dependencies

~6.5MB
~179K SLoC