Skip to content

Commit

Permalink
convert to scroll for I/O, rework Minidump to use &[u8] instead of Read.
Browse files Browse the repository at this point in the history
This patch changes how we read the raw minidump structures. Instead of
declaring them as `#[repr(C, packed)]` and transmuting them from raw bytes,
we now use scroll and `#[derive(Pread)]` which is much more sensible. To
facilitate this we also switch from having Minidump take a `Read` type
to taking a `Deref<[u8]>` type, so we can use an owned `Vec<u8>` or
a borrowed `&[u8]` as well as an `memmap::Mmap` if desired. This additionally
makes it possible to have streams and other derived objects with borrowed
data, although this patch does not make such changes yet.
  • Loading branch information
luser committed Sep 17, 2018
1 parent 5758292 commit e73f08c
Show file tree
Hide file tree
Showing 18 changed files with 586 additions and 573 deletions.
10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "minidump"
description = "A parser for the minidump format."
version = "0.1.0"
version = "0.2.0"
authors = ["Ted Mielczarek <ted@mielczarek.org>"]
license = "MIT"
documentation = "https://luser.github.io/rust-project-docs/minidump/minidump/"
Expand All @@ -20,9 +20,11 @@ exclude = [
failure = "0.1.1"
range-map = "0.1.5"
libc = "0.2.34"
minidump-common = { version = "0.1.0", path = "minidump-common" }
minidump-common = { version = "0.2.0", path = "minidump-common" }
encoding = "0.2"
chrono = "0.4.6"
scroll = "0.9.0"
memmap = "0.6.2"

[dev-dependencies]
test-assembler = "0.1.5"
Expand All @@ -34,3 +36,7 @@ members = [
"minidump-processor",
"minidump-tools",
]

[replace]
"scroll:0.9.0" = { path = "../scroll" }
"scroll_derive:0.9.4" = { path = "../scroll_derive" }
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ It's fairly heavily modeled after the [Google Breakpad](https://chromium.googles
Print the raw details of the exception stream from a minidump:

```rust
extern crate failure;
extern crate minidump;

use minidump::{Minidump, MinidumpException, MinidumpStream};
use minidump::{Error, Minidump, MinidumpException, MinidumpStream};
use std::io::{self, Write};

fn work() -> Result<(), failure::Error> {
fn work() -> Result<(), Error> {
let mut dump = minidump::Minidump::read_path("testdata/test.dmp")?;
let exception: MinidumpException = dump.get_stream()?;
drop(exception.print(&mut io::stdout()));
Expand Down
2 changes: 1 addition & 1 deletion breakpad-symbols/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exclude = [ "testdata/*" ]
travis-ci = { repository = "luser/rust-minidump" }

[dependencies]
minidump-common = { version = "0.1.0", path = "../minidump-common" }
minidump-common = { version = "0.2.0", path = "../minidump-common" }
range-map = "0.1.5"
nom = "~1.2.2"
log = "0.4.1"
Expand Down
2 changes: 1 addition & 1 deletion examples/dumpmodules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum Verbose {

fn print_minidump_modules<T: AsRef<Path>>(path: T, verbose: Verbose) {
match Minidump::read_path(path.as_ref()) {
Ok(mut dump) => {
Ok(dump) => {
if let Ok(module_list) = dump.get_stream::<MinidumpModuleList>() {
for module in module_list.iter() {
print!("{}", module.code_file());
Expand Down
4 changes: 2 additions & 2 deletions minidump-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "minidump-common"
description = "Some common types for working with minidump files."
version = "0.1.0"
version = "0.2.0"
authors = ["Ted Mielczarek <ted@mielczarek.org>"]
readme = "README.md"
license = "MIT"
Expand All @@ -14,4 +14,4 @@ travis-ci = { repository = "luser/rust-minidump" }

[dependencies]
libc = "0.2.34"
scroll = "0.9.0"
scroll = { version = "0.9.0", features = ["derive"] }
Loading

0 comments on commit e73f08c

Please sign in to comment.