-
Notifications
You must be signed in to change notification settings - Fork 24
Add initial MacOS implementation #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
b4c50cb
Move memory write to be a shared module
Jake-Shadle d777ecc
Begin fleshing out MacOS implementation
Jake-Shadle 977ebb2
Further fleshing out
Jake-Shadle cbf84f3
Add remaining streams
Jake-Shadle b3c8c10
Begin refactor
Jake-Shadle b439d66
Update branch name for path
Jake-Shadle 9c0fe44
Make DirSection shared
Jake-Shadle c73f1f4
Finish up refactoring and actually get it compiling
Jake-Shadle cc84ce9
Add macos dump test
Jake-Shadle 22b5d7f
Build mac in CI
Jake-Shadle a721515
Fixup x86_64
Jake-Shadle c166609
Remove unused import
Jake-Shadle 3825266
Verify we get valid misc info
Jake-Shadle 717312b
Add debug prints
Jake-Shadle 396b2ac
Actually these were what I wanted
Jake-Shadle 915caa3
Use TASK_BASIC_INFO_64 instead
Jake-Shadle 22a5aad
Add busy loop so we don't have 0 seconds of user time
Jake-Shadle 589bf61
uhm
Jake-Shadle 05b10df
Check both
Jake-Shadle 13edc95
Properly pack structs
Jake-Shadle aa7bcc4
oops
Jake-Shadle a2010cd
Use a thread to force timings?
Jake-Shadle 97ad56c
Try harder to use user cpu time
Jake-Shadle 3c36479
Just give up on process times for now
Jake-Shadle 1695497
Cleanup/docs pass
Jake-Shadle 3e473b0
Add task_dumper test for load command iteration
Jake-Shadle 7dbd4c5
Verify test works on macos
Jake-Shadle 5852ffa
Remove unneeded crash-context patch
Jake-Shadle 1360967
oops, remove dbg! code
Jake-Shadle 0f361da
Oops, we were dropping a register
Jake-Shadle 7d4aecf
Use correct arm64 processor arch
Jake-Shadle ff3c98b
Remove superfluous 'what' comment
Jake-Shadle 4342fde
Hopefully fix slide calculation
Jake-Shadle b57038a
Checkpoint of fail
Jake-Shadle f44a51c
Fix formatting
Jake-Shadle 4ec6a9a
Using as a path dep for now
Jake-Shadle 4af3274
Use crash-context to properly send process info
Jake-Shadle 73c53c8
Remove minidump-processor temporarily due to openssl
Jake-Shadle ccada3b
Fix windows
Jake-Shadle fe4e0d9
Fix it better
Jake-Shadle b67946e
oops
Jake-Shadle a8e0783
Get rid of needless functions now that pid is part of context
Jake-Shadle b18c572
Shame
Jake-Shadle a563388
Fix windows test compilation
Jake-Shadle 8fa66d8
Gracefully handle invalid addresses for thread stacks
Jake-Shadle 9189c8d
Remove crash-context patch
Jake-Shadle 46e3999
Add CHANGELOG.md
Jake-Shadle 2082ff7
Reenable test with patches
Jake-Shadle 41c1768
Fix build
Jake-Shadle 0b62a95
Fix it for real this time
Jake-Shadle 699f248
Replace cargo-audit with cargo-deny
Jake-Shadle 1018093
Remove minidump* patches now that 0.11 was released
Jake-Shadle 4e44566
Ensure aarch64 compiles as well
Jake-Shadle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| /target | ||
| Cargo.lock | ||
| .test-symbols |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <!-- markdownlint-disable blanks-around-headings blanks-around-lists no-duplicate-heading --> | ||
|
|
||
| # Changelog | ||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
| ### Added | ||
| - Initial implementation of support for `x86_64-apple-darwin` and `aarch64-apple-darwin` | ||
|
|
||
| ## [0.1.0] - 2022-04-26 | ||
| ### Added | ||
| - Initial release, including basic support for `x86_64-unknown-linux-gnu/musl` and `x86_64-pc-windows-msvc` | ||
|
|
||
| [Unreleased]: https://github.com/rust-minidump/minidump-writer/compare/0.1.0...HEAD | ||
| [0.1.0]: https://github.com/rust-minidump/minidump-writer/releases/tag/0.1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| [advisories] | ||
| ignore = [ | ||
| # chrono can segfault due to use of localtime_r, however this is only used | ||
| # via the `cab` crate, which is not using local time | ||
| "RUSTSEC-2020-0159", | ||
| # This is an old version of time that can segfault due to local time, but | ||
| # again, this functionality is not being used | ||
| "RUSTSEC-2020-0071", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| use crate::{ | ||
| mem_writer::{Buffer, MemoryArrayWriter, MemoryWriterError}, | ||
| minidump_format::MDRawDirectory, | ||
| }; | ||
| use std::io::{Error, Seek, SeekFrom, Write}; | ||
|
|
||
| pub type DumpBuf = Buffer; | ||
|
|
||
| #[derive(Debug, thiserror::Error)] | ||
| pub enum FileWriterError { | ||
| #[error("IO error")] | ||
| IOError(#[from] Error), | ||
| #[error("Failed to write to memory")] | ||
| MemoryWriterError(#[from] MemoryWriterError), | ||
| } | ||
|
|
||
| /// Utility that wraps writing minidump directory entries to an I/O stream, generally | ||
| /// a [`std::fs::File`]. | ||
| #[derive(Debug)] | ||
| pub struct DirSection<'a, W> | ||
| where | ||
| W: Write + Seek, | ||
| { | ||
| curr_idx: usize, | ||
| section: MemoryArrayWriter<MDRawDirectory>, | ||
| /// If we have to append to some file, we have to know where we currently are | ||
| destination_start_offset: u64, | ||
| destination: &'a mut W, | ||
| last_position_written_to_file: u64, | ||
| } | ||
|
|
||
| impl<'a, W> DirSection<'a, W> | ||
| where | ||
| W: Write + Seek, | ||
| { | ||
| pub fn new( | ||
| buffer: &mut DumpBuf, | ||
| index_length: u32, | ||
| destination: &'a mut W, | ||
| ) -> std::result::Result<Self, FileWriterError> { | ||
| let dir_section = | ||
| MemoryArrayWriter::<MDRawDirectory>::alloc_array(buffer, index_length as usize)?; | ||
|
|
||
| Ok(Self { | ||
| curr_idx: 0, | ||
| section: dir_section, | ||
| destination_start_offset: destination.seek(SeekFrom::Current(0))?, | ||
| destination, | ||
| last_position_written_to_file: 0, | ||
| }) | ||
| } | ||
|
|
||
| #[inline] | ||
| pub fn position(&self) -> u32 { | ||
| self.section.position | ||
| } | ||
|
|
||
| pub fn dump_dir_entry( | ||
| &mut self, | ||
| buffer: &mut DumpBuf, | ||
| dirent: MDRawDirectory, | ||
| ) -> std::result::Result<(), FileWriterError> { | ||
| self.section.set_value_at(buffer, dirent, self.curr_idx)?; | ||
|
|
||
| // Now write it to file | ||
|
|
||
| // First get all the positions | ||
| let curr_file_pos = self.destination.seek(SeekFrom::Current(0))?; | ||
| let idx_pos = self.section.location_of_index(self.curr_idx); | ||
| self.curr_idx += 1; | ||
|
|
||
| self.destination.seek(std::io::SeekFrom::Start( | ||
| self.destination_start_offset + idx_pos.rva as u64, | ||
| ))?; | ||
| let start = idx_pos.rva as usize; | ||
| let end = (idx_pos.rva + idx_pos.data_size) as usize; | ||
| self.destination.write_all(&buffer[start..end])?; | ||
|
|
||
| // Reset file-position | ||
| self.destination | ||
| .seek(std::io::SeekFrom::Start(curr_file_pos))?; | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| /// Writes 2 things to file: | ||
| /// 1. The given dirent into the dir section in the header (if any is given) | ||
| /// 2. Everything in the in-memory buffer that was added since the last call to this function | ||
| pub fn write_to_file( | ||
| &mut self, | ||
| buffer: &mut DumpBuf, | ||
| dirent: Option<MDRawDirectory>, | ||
| ) -> std::result::Result<(), FileWriterError> { | ||
| if let Some(dirent) = dirent { | ||
| self.dump_dir_entry(buffer, dirent)?; | ||
| } | ||
|
|
||
| let start_pos = self.last_position_written_to_file as usize; | ||
| self.destination.write_all(&buffer[start_pos..])?; | ||
| self.last_position_written_to_file = buffer.position(); | ||
| Ok(()) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,21 @@ cfg_if::cfg_if! { | |
| mod windows; | ||
|
|
||
| pub use windows::*; | ||
| } else if #[cfg(target_os = "macos")] { | ||
| mod mac; | ||
|
|
||
| pub use mac::*; | ||
| } | ||
| } | ||
|
|
||
| pub mod minidump_cpu; | ||
| pub mod minidump_format; | ||
|
|
||
| // Non-windows platforms need additional code since they are essentially | ||
| // replicating functionality we get for free on Windows | ||
| cfg_if::cfg_if! { | ||
| if #[cfg(not(target_os = "windows"))] { | ||
| pub(crate) mod mem_writer; | ||
| pub(crate) mod dir_section; | ||
| } | ||
| } | ||
|
Comment on lines
+20
to
+27
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like the comment says, these modules are shared code that non-windows can use to help write minidump streams. |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is just a move of the
DirSectionand related code so that it can be shared between Linux and Mac.