29 releases (14 breaking)

0.21.1 Mar 1, 2024
0.20.0 Jan 31, 2024
0.19.1 Nov 2, 2023
0.17.0 May 17, 2023
0.1.0 Dec 21, 2017

#3 in #analysis

Download history 1326/week @ 2023-12-21 547/week @ 2023-12-28 902/week @ 2024-01-04 1387/week @ 2024-01-11 1466/week @ 2024-01-18 1990/week @ 2024-01-25 1494/week @ 2024-02-01 2085/week @ 2024-02-08 2814/week @ 2024-02-15 2663/week @ 2024-02-22 3214/week @ 2024-02-29 2218/week @ 2024-03-07 2846/week @ 2024-03-14 3300/week @ 2024-03-21 3012/week @ 2024-03-28 2563/week @ 2024-04-04

12,111 downloads per month
Used in 8 crates (7 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
~177K SLoC