minidump-writer
Rust rewrite of Breakpad's minidump_writer (client)
This project is currently being very actively brought up from nothing, and is really ultimately many separate client implementations for different platforms.
Usage / Examples
The primary use case of this crate is for creating a minidump for an external process (ie a process other than the one that writes the minidump) as writing minidumps from within a crashing process is inherently unreliable. That being said, there are scenarios where creating a minidump can be useful outside of a crash scenario thus each supported platforms has a way to generate a minidump for a local process as well.
For more information on how to dump an external process you can check out the documentation or code for the minidumper crate.
Linux
Local process
fn write_minidump() {
let mut writer = minidump_writer::minidump_writer::MinidumpWriter::new(
std::process::id() as _,
unsafe { libc::syscall(libc::SYS_gettid) } as i32
);
let mut minidump_file = std::fs::File::create("example_dump.mdmp").expect("failed to create file");
writer.dump(&mut minidump_file).expect("failed to write minidump");
}
External process
fn write_minidump(crash_context: crash_context::CrashContext) {
let mut writer = minidump_writer::minidump_writer::MinidumpWriter::new(crash_context.pid, crash_context.tid);
writer.set_crash_context(minidump_writer::crash_context::CrashContext { inner: crash_context });
let mut minidump_file = std::fs::File::create("example_dump.mdmp").expect("failed to create file");
writer.dump(&mut minidump_file).expect("failed to write minidump");
}
Windows
Local process
fn write_minidump() {
let mut minidump_file = std::fs::File::create("example_dump.mdmp").expect("failed to create file");
minidump_writer::minidump_writer::MinidumpWriter::dump_local_context(
None,
Some(unsafe { windows_sys::Win32::System::Threading::GetCurrentThreadId() }),
&mut minidump_file,
).expect("failed to write minidump");;
}
External process
fn write_minidump(crash_context: crash_context::CrashContext) {
use std::io::{Read, Seek};
let mut minidump_file = std::fs::File::create("example_dump.mdmp").expect("failed to create file");
minidump_writer::minidump_writer::MinidumpWriter::dump_crash_context(crash_context, &mut minidump_file).expect("failed to write minidump");;
let mut minidump_contents = Vec::with_capacity(minidump_file.stream_position().expect("failed to get stream length") as usize);
minidump_file.rewind().expect("failed to rewind minidump file");
minidump_file.read_to_end(&mut minidump_contents).expect("failed to read minidump");
}
MacOS
Local process
fn write_minidump() {
let mut writer = minidump_writer::minidump_writer::MinidumpWriter::new(None, None)?;
let mut minidump_file = std::fs::File::create("example_dump.mdmp").expect("failed to create file");
writer.dump(&mut minidump_file).expect("failed to write minidump");
}
External process
fn write_minidump(crash_context: crash_context::CrashContext) {
let mut writer = minidump_writer::minidump_writer::MinidumpWriter::with_crash_context(crash_context)?;
let mut minidump_file = std::fs::File::create("example_dump.mdmp").expect("failed to create file");
writer.dump(&mut minidump_file).expect("failed to write minidump");
}
Client Statuses
- ✅ Usable, but care should be taken in production environments
- ⚠️ Implemented (ie compiles), but untested and needs more work to be usable
- ⭕️ Unimplemented, but could be implemented in the future
- ❌ Unimplemented, and unlikely to ever be implemented
Arch |
unknown-linux-gnu |
unknown-linux-musl |
linux-android |
pc-windows-msvc |
apple-darwin |
apple-ios |
x86_64 |
✅ |
✅ |
⚠️ |
✅ |
✅ |
⭕️ |
i686 |
✅ |
✅ |
❌ |
⚠️ |
❌ |
❌ |
arm |
⚠️ |
⚠️ |
⚠️ |
⭕️ |
❌ |
❌ |
aarch64 |
⚠️ |
⚠️ |
⚠️ |
⭕️ |
✅ |
⭕️ |
mips |
⭕️ |
⭕️ |
❌ |
❌ |
❌ |
❌ |
mips64 |
⭕️ |
⭕️ |
❌ |
❌ |
❌ |
❌ |
powerpc |
⭕️ |
⭕️ |
❌ |
❌ |
❌ |
❌ |
powerpc64 |
⭕️ |
⭕️ |
❌ |
❌ |
❌ |
❌ |