Skip to content

Conversation

@marti4d
Copy link
Collaborator

@marti4d marti4d commented Jul 11, 2025

Merges PtraceDumper and MinidumpWriter

While I'm at it, also reorganize a bunch of code and update some things to use emerging Rust best-practices.

  • Change use statements to use blocks
  • Prefer to use super:: rather than crate:: where applicable
  • Use mod.rs in a directory instead of .rs when a module has submodules
  • Move error type definitions closer to where they are used
    • Most error types are pretty specific to a tight scope, so put them there
    • Exception is the MinidumpWriter's error type - There's so much code that it's better to put it in its own module
  • Merge PtraceDumper and MinidumpWriter
    • The split between them has been blurry for a while
    • Merge them and their error types together
    • A nice thing about the split was that MinidumpWriter had a bit of a "builder config" behavior for PtraceDumper. Let's keep that!
    • There is now a MinidumpWriterConfig that is explicitly a fluent API used to configure MinidumperWriter
  • Change functions that were tightly coupled to MinidumpWriter to just be impls on it
  • Update tests to accept new structure

Fixes #154

@marti4d
Copy link
Collaborator Author

marti4d commented Jul 11, 2025

Needless to say, this is a breaking change in the API (albeit not a huge one)

Reorganizes a bunch of code and also updates some things to use emerging Rust
best-practices.

- Change use statements to use blocks
- Prefer to use `super::` rather than `crate::` where applicable
- Use mod.rs in a directory instead of <modname>.rs when a module has
  submodules
- Move error type definitions closer to where they are used
  - Most error types are pretty specific to a tight scope, so put them there
  - Exception is the MinidumpWriter's error type - There's so much code that
    it's better to put it in its own module
- Merge PtraceDumper and MinidumpWriter
  - The split between them has been blurry for a while
  - Merge them and their error types together
  - A nice thing about the split was that `MinidumpWriter` had a bit of a
    "builder config" behavior for `PtraceDumper`. Let's keep that!
  - There is now a `MinidumpWriterConfig` that is explicitly a fluent API used
    to configure `MinidumperWriter`
- Change functions that were tightly coupled to `MinidumpWriter` to just be
  impls on it
- Update tests to accept new structure

Fixes rust-minidump#154
Copy link
Contributor

@gabrielesvelto gabrielesvelto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking very good, I think it makes the overall structure easier to follow and sheds some legacy we had inherited from Breakpad and didn't make sense anymore in the current code. However I'd like to hear @Jake-Shadle 's opinion on this given it's a breaking change in terms of API.

} else {
Err(DumperError::PtraceDetachError(child, e))
impl MinidumpWriterConfig {
pub fn new(process_id: Pid, blamed_thread: Pid) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought for the future: we do this in pretty much all our crates but we should really have a separate Tid types for threads. Obviously something for a follow-up.

Copy link
Collaborator

@Jake-Shadle Jake-Shadle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me.

@gabrielesvelto
Copy link
Contributor

Thanks @Jake-Shadle! I'm merging it

@gabrielesvelto gabrielesvelto merged commit b6ed779 into rust-minidump:main Jul 28, 2025
16 checks passed
@marti4d marti4d deleted the merge_dumper_writer branch September 29, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merge PtraceDumper and MinidumpWriter

3 participants