minidump_processor/
lib.rs

1//! A library for producing stack traces and other useful information from minidump files.
2//!
3//! The JSON Schema is stable and documented in the next section.
4//!
5//! You can use the [minidump](https://crates.io/minidump) crate to parse a minidump file, and then
6//! use the [`process_minidump`] function to produce stack traces. If you provide paths to
7//! Breakpad-format .sym files, the stack traces will include function and source line information.
8//!  
9//! For a CLI application that wraps this library, see [minidump-stackwalk][].
10//! **This is the primary and stable interface for minidump-processor, which
11//! we recommend for most production users.**
12//!  
13//! If you do need to use minidump-processor as a library, we still recommend using
14//! the stabilized JSON output. The native APIs work fine and contain all the same
15//! information, we just haven't stabilized them yet, so updates are more likely
16//! to result in breakage. Here is a minimal example which gets the JSON output
17//! (and parses it with serde_json):
18//!  
19#![cfg_attr(
20    feature = "http",
21    doc = r##"
22```rust
23use minidump::Minidump;
24use minidump_processor::ProcessorOptions;
25use minidump_unwind::{http_symbol_supplier, Symbolizer};
26use serde_json::Value;
27 
28#[tokio::main]
29async fn main() -> Result<(), ()> {
30    // Read the minidump
31    let dump = Minidump::read_path("../testdata/test.dmp").map_err(|_| ())?;
32 
33    // Configure the symbolizer and processor
34    let symbols_urls = vec![String::from("https://symbols.totallyrealwebsite.org")];
35    let symbols_paths = vec![];
36    let mut symbols_cache = std::env::temp_dir();
37    symbols_cache.push("minidump-cache");
38    let symbols_tmp = std::env::temp_dir();
39    let timeout = std::time::Duration::from_secs(1000);
40 
41    // Use ProcessorOptions for detailed configuration
42    let options = ProcessorOptions::default();
43 
44    // Specify a symbol supplier (here we're using the most powerful one, the http supplier)
45    let provider = Symbolizer::new(http_symbol_supplier(
46        symbols_paths,
47        symbols_urls,
48        symbols_cache,
49        symbols_tmp,
50        timeout,
51    ));
52 
53    let state = minidump_processor::process_minidump_with_options(&dump, &provider, options)
54        .await
55        .map_err(|_| ())?;
56 
57    // Write the JSON output to an arbitrary writer (here, a Vec).
58    let mut json_output = Vec::new();
59    state.print_json(&mut json_output, false).map_err(|_| ())?;
60 
61    // Now parse it (here parsed into an arbitrary JSON Object for max flexibility).
62    let json: Value = serde_json::from_slice(&json_output).map_err(|_| ())?;
63 
64    // Now read whatever values you want out of it
65    if let Some(Value::Number(pid)) = json.get("pid") {
66        println!("pid: {}", pid);
67    }
68 
69    Ok(())
70}
71```
72"##
73)]
74//!
75//!
76//!
77//! [`process_minidump`]: fn.process_minidump.html
78//! [minidump-stackwalk]: https://crates.io/crates/minidump-stackwalk
79//!
80#![doc = include_str!("../json-schema.md")]
81
82#[cfg(all(doctest, feature = "http"))]
83doc_comment::doctest!("../README.md");
84
85mod arg_recovery;
86mod evil;
87mod op_analysis;
88mod process_state;
89mod processor;
90
91pub use crate::process_state::*;
92pub use crate::processor::*;