diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /third_party/rust/minidump-writer/examples | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/minidump-writer/examples')
-rw-r--r-- | third_party/rust/minidump-writer/examples/synthetic.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/third_party/rust/minidump-writer/examples/synthetic.rs b/third_party/rust/minidump-writer/examples/synthetic.rs new file mode 100644 index 0000000000..58ddc7d268 --- /dev/null +++ b/third_party/rust/minidump-writer/examples/synthetic.rs @@ -0,0 +1,36 @@ +//! Emits default minidump with no streams to specified path + +use std::fs::File; + +use minidump_writer::{ + dir_section::DirSection, + mem_writer::{Buffer, MemoryWriter}, + minidump_format::{MDRawHeader, MD_HEADER_SIGNATURE, MD_HEADER_VERSION}, +}; + +// usage: `cargo run --example synthetic /tmp/micro-minidump.dmp` +fn main() { + let output_path = std::env::args() + .nth(1) + .expect("missing argument: output file path"); + + let num_writers = 0u32; + let buffer_capacity = 32; + + let mut destination = File::create(output_path).expect("failed to create file"); + let mut buffer = Buffer::with_capacity(buffer_capacity); + let mut header_section = MemoryWriter::<MDRawHeader>::alloc(&mut buffer).unwrap(); + let mut dir_section = DirSection::new(&mut buffer, num_writers, &mut destination).unwrap(); + + let header = MDRawHeader { + signature: MD_HEADER_SIGNATURE, + version: MD_HEADER_VERSION, + stream_count: num_writers, + stream_directory_rva: dir_section.position(), + checksum: 0, + time_date_stamp: 0u32, + flags: 0, + }; + header_section.set_value(&mut buffer, header).unwrap(); + dir_section.write_to_file(&mut buffer, None).unwrap(); +} |