Struct minidump::Minidump

source ·
pub struct Minidump<'a, T>
where T: Deref<Target = [u8]> + 'a,
{ pub header: MINIDUMP_HEADER, pub endian: Endian, /* private fields */ }
Expand description

An index into the contents of a minidump.

The Minidump struct represents the parsed header and indices contained at the start of a minidump file. It can be instantiated by calling the Minidump::read or Minidump::read_path methods.

§Examples

use minidump::Minidump;

let dump = Minidump::read_path("../testdata/test.dmp")?;

Fields§

§header: MINIDUMP_HEADER

The raw minidump header from the file.

§endian: Endian

The endianness of this minidump file.

Implementations§

source§

impl Minidump<'static, Mmap>

source

pub fn read_path<P>(path: P) -> Result<MmapMinidump, Error>
where P: AsRef<Path>,

Read a Minidump from a Path to a file on disk.

See the type definition for an example.

source§

impl<'a, T> Minidump<'a, T>
where T: Deref<Target = [u8]> + 'a,

source

pub fn read(data: T) -> Result<Minidump<'a, T>, Error>

Read a Minidump from the provided data.

Typically this will be a Vec<u8> or &[u8] with the full contents of the minidump, but you can also use something like memmap::Mmap.

source

pub fn get_stream<S>(&'a self) -> Result<S, Error>
where S: MinidumpStream<'a>,

Read and parse the specified MinidumpStream S from the Minidump, if it exists.

Because Minidump Streams can have totally different formats and meanings, the only way to coherently access one is by specifying a static type that provides an interpretation and interface of that format.

As such, typical usage of this interface is to just statically request every stream your care about. 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 make progress (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 some 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(())
}

Some streams are impossible to fully parse/interpret without the contents of other streams (for instance, many things require MinidumpSystemInfo to interpret hardware-specific details). As a result, some parsing of the stream may be further deferred to methods on the Stream type where those dependencies can be provided (e.g. MinidumpException::get_crash_reason).

Note that the lifetime of the returned stream is bound to the lifetime of the Minidump struct itself and not to the lifetime of the data backing this minidump. This is a consequence of how this struct relies on Deref to access the data.

§Currently Supported Streams
source

pub fn get_raw_stream(&'a self, stream_type: u32) -> Result<&'a [u8], Error>

Get a stream of raw data from the minidump.

This can be used to get the contents of arbitrary minidump streams. For streams of known types you almost certainly want to use Minidump::get_stream instead.

Note that the lifetime of the returned stream is bound to the lifetime of the this Minidump struct itself and not to the lifetime of the data backing this minidump. This is a consequence of how this struct relies on Deref to access the data.

source

pub fn get_memory(&'a self) -> Option<UnifiedMemoryList<'a>>

Get whichever of the two MemoryLists are available in the minidump, preferring MinidumpMemory64List.

source

pub fn unimplemented_streams( &self ) -> impl Iterator<Item = MinidumpUnimplementedStream> + '_

A listing of all the streams in the Minidump that this library is aware of, but has no further analysis for.

If there are multiple copies of the same stream type (which should not happen for well-formed Minidumps), then only one of them will be yielded, arbitrarily.

source

pub fn unknown_streams( &self ) -> impl Iterator<Item = MinidumpUnknownStream> + '_

A listing of all the streams in the Minidump that this library has no knowledge of.

If there are multiple copies of the same stream (which should not happen for well-formed Minidumps), then only one of them will be yielded, arbitrarily.

source

pub fn all_streams(&self) -> impl Iterator<Item = &MINIDUMP_DIRECTORY> + '_

A listing of all the streams in the Minidump.

If there are multiple copies of the same stream (which should not happen for well-formed Minidumps), then only one of them will be yielded, arbitrarily.

source

pub fn print<W: Write>(&self, f: &mut W) -> Result<()>

Write a verbose description of the Minidump to f.

Trait Implementations§

source§

impl<'a, T> Debug for Minidump<'a, T>
where T: Deref<Target = [u8]> + 'a + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> RefUnwindSafe for Minidump<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Minidump<'a, T>
where T: Send,

§

impl<'a, T> Sync for Minidump<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Minidump<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for Minidump<'a, T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more